add check for invertibility
This commit is contained in:
parent
78f8efa06a
commit
fffdf712e7
|
|
@ -41,6 +41,11 @@ func ceilSqrt(x *big.Int) *big.Int {
|
|||
}
|
||||
|
||||
func babyStepGiantStep(n, g, x, order *big.Int) (*big.Int, error) {
|
||||
z := new(big.Int).GCD(nil, nil, g, n)
|
||||
if z.Cmp(big.NewInt(1)) != 0 {
|
||||
return nil, fmt.Errorf("base %v is not invertible modulo %v", g, n)
|
||||
}
|
||||
|
||||
var m *big.Int
|
||||
if order == nil {
|
||||
// m = ceil(sqrt(n - 1))
|
||||
|
|
|
|||
Loading…
Reference in New Issue