Module gcd

Module gcd 

Source

Functions§

euclid_udpate 🔒
extended_gcd
Uses the lehemer algorithm. Based on https://github.com/golang/go/blob/master/src/math/big/int.go#L612 If extended is set, the Bezout coefficients are calculated, otherwise they are None.
lehmer_gcd 🔒
lehmerGCD sets z to the greatest common divisor of a and b, which both must be != 0, and returns z. If x or y are not nil, their values are set such that z = ax + by. See Knuth, The Art of Computer Programming, Vol. 2, Section 4.5.2, Algorithm L. This implementation uses the improved condition by Collins requiring only one quotient and avoiding the possibility of single Word overflow. See Jebelean, “Improving the multiprecision Euclidean algorithm”, Design and Implementation of Symbolic Computation Systems, pp 45-58. The cosequences are updated according to Algorithm 10.45 from Cohen et al. “Handbook of Elliptic and Hyperelliptic Curve Cryptography” pp 192.
lehmer_simulate 🔒
Attempts to simulate several Euclidean update steps using leading digits of a and b. It returns u0, u1, v0, v1 such that a and b can be updated as: a = u0 * a + v0 * b b = u1 * a + v1 * b
lehmer_update 🔒
xgcd
XGCD sets z to the greatest common divisor of a and b and returns z. If extended is true, XGCD returns their value such that z = ax + by.