Exemple #1
0
func (s *secret) Inv(x abstract.Secret) abstract.Secret {
	xs := x.(*secret)
	if C.BN_mod_inverse(s.bignum.bn, xs.bignum.bn, s.c.n.bn,
		s.c.ctx) == nil {
		panic("BN_mod_inverse: " + getErrString())
	}
	return s
}
Exemple #2
0
func (s *secret) Div(x, y abstract.Secret) abstract.Secret {
	xs := x.(*secret)
	ys := y.(*secret)

	// First compute inverse of y, then multiply by x.
	// Must use a temporary in the case x == s.
	t := &s.bignum
	if x == s {
		t = newBigNum()
	}
	if C.BN_mod_inverse(t.bn, ys.bignum.bn, s.c.n.bn,
		s.c.ctx) == nil {
		panic("BN_mod_inverse: " + getErrString())
	}
	if C.BN_mod_mul(s.bignum.bn, xs.bignum.bn, t.bn, s.c.n.bn,
		s.c.ctx) == 0 {
		panic("BN_mod_mul: " + getErrString())
	}
	return s
}