Skip to main content

factor_from_order

Function factor_from_order 

Source
pub fn factor_from_order(base: u64, n: u64, r: u64) -> Option<u64>
Expand description

Classical reduction from a period r (order of base mod n) to a factor.

Implements the textbook step: if r is even and a^{r/2} ≢ ±1 (mod n), then gcd(a^{r/2} − 1, n) and gcd(a^{r/2} + 1, n) are non-trivial factors. Returns the first non-trivial factor found, else None.