Pollard's rho factoring and Floyd cycle-detection bounds #
Pollard's rho algorithm ([KL20], Section 10.1.2, Algorithm 10.2, pp. 368–369) searches for a nontrivial factor of a composite integer $N$ by iterating a pseudorandom walk $F : (\mathbb{Z}/N\mathbb{Z})^\times \to (\mathbb{Z}/N\mathbb{Z})^\times$ with Floyd's tortoise-and-hare cycle-finding schedule $(x_t, y_t) = (F^{[t]}(x_0), F^{[2t]}(x_0))$ and testing whether $d = \gcd(|x_t - y_t|, N)$ is a nontrivial divisor $1 < d < N$:
- Soundness (
isNontrivialFactor_of_rhoFactorLoop_eq_some,eq_prime_of_rhoFactorLoop_eq_some): Every outputsome dofrhoFactorLoop N F B x ysatisfiesIsNontrivialFactor N d(d ∣ N ∧ 1 < d ∧ d < N). When $N = p \cdot q$ is a product of two primes, any returned factor satisfiesd = p ∨ d = q. - Exact failure characterization (
rhoFactorLoop_eq_none_iff,rhoFactorLoop_start_eq_none_iff):rhoFactorLoop N F B x₀ x₀ = noneif and only if for every step $1 \le t \le B$, the tortoise and hare states $(F^{[t]}(x_0), F^{[2t]}(x_0))$ fail to yield a nontrivial GCD with $N$. - Nontrivial GCD from a modulo-$p$ collision (
isNontrivialFactor_rhoGcd_of_modEq): Whenever $p \mid N$ ($1 < p$), $a \ne b$ in $(\mathbb{Z}/N\mathbb{Z})^\times$, and $a \equiv b \pmod p$, their GCD candidaterhoGcd N a bis a nontrivial divisor of $N$. - Floyd's cycle-detection persistence theorem (
floyd_cycle_modEq): If $F$ is congruence-compatible modulo $p$, any collision $F^{[i]}(x) \equiv F^{[j]}(x) \pmod p$ at indices $i < j$ implies a tortoise-and-hare collision $F^{[t]}(x) \equiv F^{[2t]}(x) \pmod p$ at some step $1 \le t \le j$.
The birthday-bound analysis (via [KL20], Lemma A.15) and the heuristic $O(N^{1/4} \cdot \mathrm{polylog}(N))$ running time are not formalised here.
Main definitions #
Cslib.Crypto.rhoGcd: candidate GCD(((a : ZMod N).val : ℤ) - (b : ZMod N).val).natAbs.gcd Nof the difference of two units in(ZMod N)ˣwithN.Cslib.Crypto.IsNontrivialFactor: predicated ∣ N ∧ 1 < d ∧ d < N.Cslib.Crypto.rhoFactorLoop:B-step Floyd tortoise-and-hare loop of Pollard's rho algorithm ([KL20], Algorithm 10.2, p. 369).
Main results #
Cslib.Crypto.isNontrivialFactor_of_rhoFactorLoop_eq_some,Cslib.Crypto.eq_prime_of_isNontrivialFactor_mul,Cslib.Crypto.eq_prime_of_rhoFactorLoop_eq_some: soundness ofrhoFactorLoopon general composites and semiprimesN = p * q.Cslib.Crypto.rhoFactorLoop_eq_none_iff,Cslib.Crypto.rhoFactorLoop_start_eq_none_iff: exact stepwise characterization of whenrhoFactorLoopreturnsnone.Cslib.Crypto.isNontrivialFactor_rhoGcd_of_modEq: any distinct pair in(ZMod N)ˣthat is congruent modulo a proper factorp ∣ Nyields a nontrivial divisor viarhoGcd.Cslib.Crypto.floyd_cycle_modEq: Floyd's tortoise-and-hare cycle-detection theorem for congruence-compatible walks modulop.
References #
- J. Katz, Y. Lindell, Introduction to Modern Cryptography, 3rd ed., Section 10.1.2 (Pollard's Rho Algorithm, Algorithm 10.2, pp. 368–369) and Section 6.4.2 (Algorithm 6.9, p. 180, the small-space cycle-finding technique credited to Floyd).
A natural number d is a nontrivial factor of N if d ∣ N and 1 < d < N.
Instances For
Soundness and exact failure characterization #
Soundness of rhoFactorLoop: every some d returned by rhoFactorLoop N F B x y is a
nontrivial divisor of N (IsNontrivialFactor N d).
Any nontrivial factor of a semiprime p * q (with p, q prime) equals p or q.
Semiprime soundness of rhoFactorLoop: for N = p * q with p, q prime, any factor d
returned by rhoFactorLoop (p * q) F B x y satisfies d = p ∨ d = q.
Stepwise characterization of when rhoFactorLoop N F B x y returns none.
Exact failure characterization from a common start state x₀:
rhoFactorLoop N F B x₀ x₀ = none if and only if no step 1 ≤ t ≤ B produces a nontrivial GCD
between F^[t] x₀ and F^[2 * t] x₀.
Nontrivial GCD from a modulo-p collision #
Good-pair GCD lemma ([KL20], Section 10.1.2, p. 368): if p ∣ N (1 < p) and
two distinct units a ≠ b in (ZMod N)ˣ are congruent modulo p, then rhoGcd N a b is a
nontrivial factor of N.
Floyd's tortoise-and-hare cycle-detection theorem #
Floyd's cycle-detection persistence theorem (the technique of [KL20],
Section 6.4.2, Algorithm 6.9, p. 180, as used for Pollard's rho in Section 10.1.2, p. 369):
if F is congruence-compatible modulo p, then any collision
(F^[i] x : ZMod N).val ≡ (F^[j] x : ZMod N).val [MOD p] at indices i < j implies that there
exists a step 1 ≤ t ≤ j at which the tortoise F^[t] x and hare F^[2 * t] x collide
modulo p.