add comments
This commit is contained in:
@@ -33,9 +33,13 @@ func ceilSqrt(x *big.Int) *big.Int {
|
||||
return z
|
||||
}
|
||||
|
||||
// TODO: this can be extended to work with n, b not coprime
|
||||
// https://cp-algorithms.com/algebra/discrete-log.html
|
||||
/*
|
||||
BabyStepGiantStep computes i such that b^i = x (mod n). For more efficient computation, provide the order of the group (i.e. totient(n)).
|
||||
*/
|
||||
func BabyStepGiantStep(n, b, x, order *big.Int) (*big.Int, error) {
|
||||
// TODO: this function be extended to work with n, b not coprime
|
||||
// https://cp-algorithms.com/algebra/discrete-log.html
|
||||
|
||||
z := new(big.Int).GCD(nil, nil, b, n)
|
||||
if z.Cmp(big.NewInt(1)) != 0 {
|
||||
return nil, fmt.Errorf("base %v and modulus %v are not coprime", b, n)
|
||||
|
||||
Reference in New Issue
Block a user