Content deleted Content added
→Java Code: Add java code for Pollards rho method Tags: Reverted Visual edit |
fixed grammar |
||
(46 intermediate revisions by 20 users not shown) | |||
Line 1:
{{Short description|Integer factorization algorithm}}
{{about|the integer factorization algorithm|the discrete logarithm algorithm|Pollard's rho algorithm for logarithms}}
'''Pollard's rho algorithm''' is an [[algorithm]] for [[integer factorization]]. It was invented by [[John Pollard (mathematician)|John Pollard]] in 1975.<ref>{{cite journal |last=Pollard |first=J. M. |year=1975 |title=A Monte Carlo method for factorization |url=https://www.cs.cmu.edu/~avrim/451f11/lectures/lect1122_Pollard.pdf |journal=BIT Numerical Mathematics |volume=15 |issue=3 |pages=331–334 |doi=10.1007/bf01933667 |s2cid=122775546}}</ref> It uses only a small amount of space, and its expected running time is proportional to the [[square root
== Core ideas ==
The algorithm is used to factorize a number <math>n = pq</math>, where <math>p</math> is a non-trivial factor. A [[polynomial]] modulo <math>n</math>, called <math>g(x)</math> (e.g., <math>g(x) = (x^2 + 1) \bmod n</math>), is used to generate a [[pseudorandom sequence]]
Because the number of possible values for these sequences
Once a sequence has a repeated value, the sequence will cycle, because each value depends only on the one before it. This structure of eventual cycling gives rise to the name "rho algorithm", owing to similarity to the shape of the Greek letter ''ρ'' when the values <math>x_1 \bmod p</math>, <math>x_2 \bmod p</math>, etc. are represented as nodes in a [[directed graph]].
[[File:Pollard rho cycle.svg|thumb|Cycle diagram resembling the Greek letter ''ρ'']]
This is detected by [[Floyd's cycle-finding algorithm]]: two nodes <math>i</math> and <math>j</math> (i.e., <math>x_i</math> and <math>x_j</math>) are kept. In each step, one moves to the next node in the sequence and the other moves forward by two nodes. After that, it is checked whether <math>\gcd(x_i - x_j, n) \ne 1</math>. If it is not 1, then this implies that there is a repetition in the <math>\{x_k \bmod p\}</math> sequence (i.e. <math>x_i \bmod p = x_j \bmod p)</math>. This works because if the <math>x_i \bmod p</math> is the same as <math>x_j \bmod p</math>, the difference between <math>x_i</math> and <math>x_j</math> is necessarily a multiple of <math>p</math>. Although this always happens eventually, the resulting [[greatest common divisor]] (GCD) is a divisor of <math>n</math> other than 1. This may be <math>n</math> itself, since the two sequences might repeat at the same time. In this (uncommon) case the algorithm fails, it can be repeated with a different parameter.
== Algorithm ==
The algorithm takes as its inputs {{mvar|n}}, the [[integer]] to be factored; and {{tmath|g(x)}}, a polynomial in {{mvar|x}} computed modulo {{mvar|n}}. In the original algorithm, <math>g(x) = (x^2 - 1) \bmod n</math>, but nowadays it is more common to use <math>g(x) = (x^2 + 1) \bmod n</math>. The output is either a non-trivial factor of {{mvar|n}}, or failure.
It performs the following steps:<ref name=":0">{{cite book | Pseudocode for Pollard's rho algorithm
y ← x
d ← 1
Line 29 ⟶ 35:
'''return''' d
Here {{mvar|x}} and {{mvar|y}} corresponds to {{tmath|x_i}} and {{tmath|x_j}} in the previous section
== Example factorization ==
Line 35 ⟶ 41:
[[File:Rho-example-animated.gif|thumb|348x348px|Pollard's rho algorithm example factorization for <math>n=253</math> and <math>g(x)=x^2 \bmod 253</math>, with starting value 2. The example is using [[Floyd's cycle-finding algorithm]].]]
{| class="wikitable" style="text-align:right"
! width=30 | {{mvar|i}} || width=60 | {{mvar|x}} || width=60 | {{mvar|y}} || {{math|
|-
| 1 || 5 || 26 || 1
Line 46 ⟶ 52:
|}
Now 97 is a non-trivial factor of 8051. Starting values other than {{math|1=''x'' = ''y'' = 2}} may give the cofactor (83) instead of 97. One extra iteration is shown above to make it clear that {{mvar|y}} moves twice as fast as {{mvar|x}}. Note that even after a repetition, the GCD can return to 1.
== Variants ==
In 1980, [[Richard Brent (scientist)|Richard Brent]] published a faster variant of the rho algorithm. He used the same core ideas as Pollard but a different method of cycle detection, replacing [[Floyd's cycle-finding algorithm]] with the related [[Cycle detection#Brent.27s algorithm|Brent's cycle finding method]].<ref>{{cite journal |last=Brent |first=Richard P. |authorlink=Richard Brent (scientist) |year=1980 |title=An Improved Monte Carlo Factorization Algorithm |journal=BIT |volume=20 |issue=2 |pages=176–184 |url=
A further improvement was made by Pollard and Brent. They observed that if <math>\gcd
== Application ==
The algorithm is very fast for numbers with small factors, but slower in cases where all factors are large. The ''ρ'' algorithm's most remarkable success was the 1980 factorization of the [[Fermat number]] {{math|''F''<sub>8</sub>}} = 1238926361552897
==
The following table shows numbers produced by the algorithm, starting with <math>x=2</math> and using the polynomial <math>g(x) = (x^2 + 1) \bmod 10403</math>.
The third and fourth columns of the table contain additional information not known by the algorithm.
They are included to show how the algorithm works.
{| class="wikitable" style="text-align:right;"
! {{tmath|x}} !! {{tmath|
|-
| 2 || 2 || 2 || 2 || 0
Line 236 ⟶ 120:
|}
The first repetition modulo 101 is 97 which occurs in step 17. The repetition is not detected until step 23, when <math>x \equiv
== Complexity ==
If the pseudorandom number <math>x = g(x)</math> occurring in the Pollard ''ρ'' algorithm were an actual random number, it would follow that success would be achieved half the time, by the [[
== See also ==
* [[Pollard's rho algorithm for logarithms]]
* [[Pollard's kangaroo algorithm]]
== Notes ==
{{reflist|group=note}}
== References ==
Line 250 ⟶ 136:
== Further reading ==
* {{cite conference |first1=Shi |last1=Bai |first2=Richard P. |last2=Brent |authorlink2=Richard P. Brent |title=On the Efficiency of Pollard's Rho Method for Discrete Logarithms |conference=The Australasian Theory Symposium (CATS2008) |___location=Wollongong |date=January 2008 |book-title=Conferences in Research and Practice in Information Technology, Vol. 77 |pages=125–131 |url=https://maths-people.anu.edu.au/~brent/pub/pub231.html}} Describes the improvements available from different iteration functions and cycle-finding algorithms.
* {{cite book |last1=Katz |first1=Jonathan |last2=Lindell |first2=Yehuda |chapter=Chapter 8 |title=Introduction to Modern Cryptography | year=2007 |publisher=CRC Press}}
* {{cite book | author =Samuel S. Wagstaff, Jr. | title=The Joy of Factoring | publisher=American Mathematical Society | ___location=Providence, RI | year=2013 | isbn=978-1-4704-1048-3 |url=https://www.ams.org/bookpages/stml-68 |author-link=Samuel S. Wagstaff, Jr. |pages= 135–138 }}
Line 264 ⟶ 151:
{{DEFAULTSORT:Pollard's Rho Algorithm}}
[[Category:Integer factorization algorithms]]
|