Proofs: Pollard's rho algorithm for discrete logarithms
These are the human proofs of Pollard's rho algorithm for discrete logarithms, at full length.
Correctness of Pollard's rho algorithm for discrete logarithms full
This proof shows: correctness, termination.
Let be prime, of order , and . All exponent arithmetic is modulo , which is well defined because and, when , .
Lemma 1 (membership). if and only if .
Proof. If then . Conversely, is cyclic of order , and . A cyclic group has exactly one subgroup of each order dividing its order, and that subgroup is the set of solutions of , which has at most elements since it is the set of roots of a polynomial of degree over a field. has elements and all satisfy , so is exactly this set.
So line L1 returns NONE exactly when . From now on assume , say with . If then and line L2 is correct, so assume .
Lemma 2 (invariant). Throughout an attempt, and .
Proof. Line L5 sets with , and line L6 copies it. Each case of STEP preserves the relation: (line L17), (line L18) and (line L19); reducing exponents modulo changes nothing since .
Lemma 3 (each attempt ends). Let and , where is the element part of STEP for the current partition. After round of the loop of lines L7 to L10, and , and the loop ends after at most rounds.
Proof. The first claim follows by induction, since line L8 applies once and line L9 twice; the element part of STEP depends only on the element, not on the exponents. The sequence lies in the finite set of size , so there are and with for all , and . Let be the least multiple of with ; then and because is a multiple of and .
Lemma 4 (the congruence). When the loop of line L10 ends, with .
Proof. By Lemma 2, . Substituting gives , so since has order .
Lemma 5 (the candidates). If and , then , and the solutions in of are exactly for , where is computed at line L13. In particular is one of them.
Proof. By Lemma 4 the congruence has the solution , so , which divides and , divides . Dividing by , is equivalent to . Since , is invertible modulo , and the unique solution modulo is , with . The solutions modulo are the integers with , all in .
Soundness. Line L15 returns a value only after checking for it, with ; since has order , such a equals . Line L1 returns NONE only if , which by Lemma 1 means . So every output is correct.
Completeness of an attempt. If line L12 passes, then by Lemma 5 one of the candidates is , and line L15 returns it. So an attempt fails only when or .
Termination with probability one. Each attempt ends by Lemma 3, so it remains to show that some attempt succeeds. In line L16 the partition is a uniformly random map and are uniform, independently of earlier attempts. We exhibit one choice that succeeds; since there are finitely many choices, each attempt after the first then succeeds with probability at least some , and the number of attempts is finite with probability (it is dominated by a geometric random variable).
Take , so , and the partition with , and . Then with . Since , the next steps multiply by : with , and these differ from for . At the walk returns to . So and , and every pass around the cycle visits exactly once. Floyd's loop stops at , where the tortoise has made one pass and the hare two, so and (exponents of grow only at line L17). Hence , , line L12 passes, and by the completeness of an attempt the algorithm returns .
This proves termination with probability one for the algorithm as stated, with uniformly random partitions. An implementation draws the partition from a small keyed family, such as for a random unit ; for such a family, the success probability of an attempt is the subject of the random walk heuristic rather than of this proof. Under that heuristic is uniform modulo , so for prime an attempt fails with probability about .