Pollard's rho algorithm for logarithms is an algorithm introduced by John Pollard in 1978 to solve the discrete logarithm problem, analogous to Pollard's rho algorithm to solve the integer factorization problem.
The goal is to compute γ {\displaystyle \gamma } such that α γ = β {\displaystyle \alpha ^{\gamma }=\beta } , where β {\displaystyle \beta } belongs to a cyclic group G {\displaystyle G} generated by α {\displaystyle \alpha } . The algorithm computes integers a {\displaystyle a} , b {\displaystyle b} , A {\displaystyle A} , and B {\displaystyle B} such that α a β b = α A β B {\displaystyle \alpha ^{a}\beta ^{b}=\alpha ^{A}\beta ^{B}} . If the underlying group is cyclic of order n {\displaystyle n} , by substituting β {\displaystyle \beta } as α γ {\displaystyle {\alpha }^{\gamma }} and noting that two powers are equal if and only if the exponents are equivalent modulo the order of the base, in this case modulo n {\displaystyle n} , we get that γ {\displaystyle \gamma } is one of the solutions of the equation ( B − b ) γ = ( a − A ) ( mod n ) {\displaystyle (B-b)\gamma =(a-A){\pmod {n}}} . Solutions to this equation are easily obtained using the extended Euclidean algorithm.
To find the needed a {\displaystyle a} , b {\displaystyle b} , A {\displaystyle A} , and B {\displaystyle B} the algorithm uses Floyd's cycle-finding algorithm to find a cycle in the sequence x i = α a i β b i {\displaystyle x_{i}=\alpha ^{a_{i}}\beta ^{b_{i}}} , where the function f : x i ↦ x i + 1 {\displaystyle f:x_{i}\mapsto x_{i+1}} is assumed to be random-looking and thus is likely to enter into a loop of approximate length π n 8 {\displaystyle {\sqrt {\frac {\pi n}{8}}}} after π n 8 {\displaystyle {\sqrt {\frac {\pi n}{8}}}} steps. One way to define such a function is to use the following rules: Partition G {\displaystyle G} into three disjoint subsets S 0 {\displaystyle S_{0}} , S 1 {\displaystyle S_{1}} , and S 2 {\displaystyle S_{2}} of approximately equal size using a hash function. If x i {\displaystyle x_{i}} is in S 0 {\displaystyle S_{0}} then double both a {\displaystyle a} and b {\displaystyle b} ; if x i ∈ S 1 {\displaystyle x_{i}\in S_{1}} then increment a {\displaystyle a} , if x i ∈ S 2 {\displaystyle x_{i}\in S_{2}} then increment b {\displaystyle b} .