Pollard's rho algorithm for logarithms is an algorithm introduced by
John Pollard in 1978 to solve the
discrete logarithm
In mathematics, for given real numbers ''a'' and ''b'', the logarithm log''b'' ''a'' is a number ''x'' such that . Analogously, in any group ''G'', powers ''b'k'' can be defined for all integers ''k'', and the discrete logarithm log''b' ...
problem, analogous to
Pollard's rho algorithm
Pollard's rho algorithm is an algorithm for integer factorization. It was invented by John Pollard in 1975. It uses only a small amount of space, and its expected running time is proportional to the square root of the smallest prime factor of the ...
to solve the
integer factorization
In number theory, integer factorization is the decomposition of a composite number into a product of smaller integers. If these factors are further restricted to prime numbers, the process is called prime factorization.
When the numbers are suf ...
problem.
The goal is to compute
such that
, where
belongs to a
cyclic group
In group theory, a branch of abstract algebra in pure mathematics, a cyclic group or monogenous group is a group, denoted C''n'', that is generated by a single element. That is, it is a set of invertible elements with a single associative bina ...
generated by
. The algorithm computes
integer
An integer is the number zero (), a positive natural number (, , , etc.) or a negative integer with a minus sign (−1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the language ...
s
,
,
, and
such that
. If the underlying
group
A group is a number of persons or things that are located, gathered, or classed together.
Groups of people
* Cultural group, a group whose members share the same cultural identity
* Ethnic group, a group whose members share the same ethnic ide ...
is cyclic of
order , by substituting
as
and noting that two powers are equal
if and only if
In logic and related fields such as mathematics and philosophy, "if and only if" (shortened as "iff") is a biconditional logical connective between statements, where either both statements are true or both are false.
The connective is bicondi ...
the exponents are equivalent modulo the order of the base, in this case modulo
, we get that
is one of the solutions of the equation
. Solutions to this equation are easily obtained using the
extended Euclidean algorithm
In arithmetic and computer programming, the extended Euclidean algorithm is an extension to the Euclidean algorithm, and computes, in addition to the greatest common divisor (gcd) of integers ''a'' and ''b'', also the coefficients of Bézout's ide ...
.
To find the needed
,
,
, and
the algorithm uses
Floyd's cycle-finding algorithm to find a cycle in the sequence
, where the
function
Function or functionality may refer to:
Computing
* Function key, a type of key on computer keyboards
* Function model, a structured representation of processes in a system
* Function object or functor or functionoid, a concept of object-oriente ...
is assumed to be random-looking and thus is likely to enter into a loop of approximate length
after
steps. One way to define such a function is to use the following rules: Divide
into three
disjoint subsets of approximately equal size:
,
, and
. If
is in
then double both
and
; if
then increment
, if
then increment
.
Algorithm
Let
be a
cyclic group
In group theory, a branch of abstract algebra in pure mathematics, a cyclic group or monogenous group is a group, denoted C''n'', that is generated by a single element. That is, it is a set of invertible elements with a single associative bina ...
of order
, and given
, and a partition
, let
be the map
:
and define maps
and
by
:
input: ''a'': a generator of ''G''
''b'': an element of ''G''
output: An integer ''x'' such that ''a
x'' = ''b'', or failure
Initialise ''a''
0 ← 0, ''b''
0 ← 0, ''x''
0 ← 1 ∈ ''G''
''i'' ← 1
loop
''x
i'' ← ''f''(''x''
''i''-1),
''a
i'' ← ''g''(''x''
''i''-1, ''a''
''i''-1),
''b
i'' ← ''h''(''x''
''i''-1, ''b''
''i''-1)
''x''
2''i'' ← ''f''(''f''(''x''
2''i''-2)),
''a''
2''i'' ← ''g''(''f''(''x''
2''i''-2), ''g''(''x''
2''i''-2, ''a''
2''i''-2)),
''b''
2''i'' ← ''h''(''f''(''x''
2''i''-2), ''h''(''x''
2''i''-2, ''b''
2''i''-2))
if ''x
i'' = ''x''
2''i'' then
''r'' ← ''b
i'' - ''b''
2''i''
if r = 0 return failure
''x'' ← ''r''
−1(''a''
2''i'' - ''a
i'') mod ''n''
return ''x''
else
// ''xi'' ≠ ''x''2''i''
''i'' ← ''i'' + 1
end if
end loop
Example
Consider, for example, the group generated by 2 modulo
(the order of the group is
, 2 generates the group of units modulo 1019). The algorithm is implemented by the following
C++
C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
program:
#include
const int n = 1018, N = n + 1; /* N = 1019 -- prime */
const int alpha = 2; /* generator */
const int beta = 5; /* 2^ = 1024 = 5 (N) */
void new_xab(int& x, int& a, int& b)
int main(void)
The results are as follows (edited):
i x a b X A B
------------------------------
1 2 1 0 10 1 1
2 10 1 1 100 2 2
3 20 2 1 1000 3 3
4 100 2 2 425 8 6
5 200 3 2 436 16 14
6 1000 3 3 284 17 15
7 981 4 3 986 17 17
8 425 8 6 194 17 19
..............................
48 224 680 376 86 299 412
49 101 680 377 860 300 413
50 505 680 378 101 300 415
51 1010 681 378 1010 301 416
That is
and so
, for which
is a solution as expected. As
is not
prime
A prime number (or a prime) is a natural number greater than 1 that is not a product of two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways ...
, there is another solution
, for which
holds.
Complexity
The running time is approximately
. If used together with the
Pohlig–Hellman algorithm
In group theory, the Pohlig–Hellman algorithm, sometimes credited as the Silver–Pohlig–Hellman algorithm, Mollin 2006, pg. 344 is a special-purpose algorithm for computing discrete logarithms in a finite abelian group whose order is a smoot ...
, the running time of the combined algorithm is
, where
is the largest prime
factor
Factor, a Latin word meaning "who/which acts", may refer to:
Commerce
* Factor (agent), a person who acts for, notably a mercantile and colonial agent
* Factor (Scotland), a person or firm managing a Scottish estate
* Factors of production, suc ...
of
.
References
*
*
{{Number-theoretic algorithms
Logarithms
Number theoretic algorithms