Modern Elliptic Curve Factorization, Part 2
April 27, 2010
The elliptic curve factorization algorithm is remarkably similar to Pollard’s p1 algorithm:
define p1 (n, B_{1}, B_{2})

1 
define ecf (n, B_{1}, B_{2}, C)

q = 2  2  Q_{x,z} ∈ C // random point 
for p ∈ π(2 … B_{1})  3  for p ∈ π(2 … B_{1}) 
a = ⌊log _{p} B_{1}⌋

4 
a = ⌊log _{p} B_{1}⌋

q = q^{pa} (mod n)

5  Q = p^{a} ⊗_{C} Q 
g = gcd (q, n)

6 
g = gcd (Q_{z}, n)

if (1 < g < n) return g  7  if (1 < g < n) return g 
for p ∈ π(B_{1} … B_{2})  8  for p ∈ π(B_{1} … B_{2}) 
q = q^{p} (mod n)

9  Q = p ⊗_{C} Q 
10 
g = g × Q_{z} (mod n)


g = gcd (q, n)

11 
g = gcd (g, n)

if (1 < g < n) return g  12  if (1 < g < n) return g 
return failure  13  return failure 
Lines 3 and 8 loop over the same lists of primes. Line 4 computes the same maximum exponent. Lines 6 and 7, and lines 11 and 12, compute the same greatest common divisor. And line 13 returns the same failure. The structures of the two algorithms are identical. Also, note that both algorithms use variables that retain their meaning from the first stage (lines 2 to 7) to the second stage (lines 8 to 12).
Lines 2, 5, 9 and 10 differ because p1 is based on modular arithmetic and ecf
is based on elliptic arithmetic (note that the ⊗_{C} operator, otimessubC, indicates elliptic multiplication on curve C). The most important difference is on the first line, where ecf
has an extra argument C indicating the choice of elliptic curve. If the p1 method fails, there is nothing to do, but if the ecf
method fails, you can try again with a different curve.
Use of Montgomery’s elliptic curve parameterization from the previous exercise is a huge benefit. Lenstra’s original algorithm, which is the first stage of the modern algorithm, required that we check the greatest common divisor at each step, looking for a failure of the elliptic arithmetic. With the modern algorithm, we compute the greatest common divisor only once, at the end, because Montgomery’s parameterization has the property that a failure of the elliptic arithmetic propagates through the calculation. And without inversions, Montgomery’s parameterization is also much faster to calculate. Brent’s parameterization of the randomlyselected curve is also important, as it guarantees that the order of the curve (the number of points) will be a multiple of 12, which has various good mathematical properties that we won’t enumerate here.
There is a simple coding trick that can speed up the second stage. Instead of multiplying each prime times Q, we iterate over i from B_{1} + 1 to B_{2}, adding 2Q at each step; when i is prime, the current Q can be accumulated into the running solution. Again, we defer the calculation of the greatest common divisor until the end of the iteration.
Your task is to write a function that performs elliptic curve factorization. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.
Two questions:
in line 6 of ecf, what is ‘q’
in line 11 of ecf, is that supposed to be g = gcd(*q*,n) like in the p1 function?
In line 6, q should read Qsubz (it’s the z parameter of the point Q). I’ll fix that.
In line 11, g is the g that is initialized on line 6 and accumulated on line 11.
Since no one posted the source code for this so here is mine.How ever running this algorithm and Lenstra implementation, Lenstra seems to be good.
Lenstra Implementation
http://mukeshiiitm.wordpress.com/2011/01/17/ellipticcurveprimefactorisation/
[…] is almost similar to previous example except using Montgomery curve rather than Lenstra curve. Programmingpraxis used Montgomery curve to find the prime factorisation. I personally feel that Lenstra algorithm […]
A solution in Python, borrowing the functions from https://programmingpraxis.com/2010/04/23/modernellipticcurvefactorizationpart1/#comment1192:
I cannot wrap my head around the concept of Elliptic Curves let alone the ECM but I think I found a P195 factor. Is that a record as your article implies the current record stands at P73?
Here is the C227 composite and here are its factors using Yet Another Factorization Utility 1.34 from http://yafu.sourceforge.net
72862001761201652067512910912311143529912811111098135112781186477227938869603430735445831828875855453895937353829184560496255789629222413141111181212305252442828205640315040464229193625221719263020152111881958811118395473635456
=
2 x
2 x
2 x
2 x
2 x
2 x
2 x
7 x
5527 x
137885520290732817351584663 x
106705047172471266468660928563317852379901416010404723328566172957737395755840658022032569277618563231217065120661299797289022426791599936582159383554005399760617203071477939525944722428007054711
What am I missing ???
Also I currently I am factoring this number:
65453637459381111885198811211520302619172225361929424640503140562028284452523012121811111413242229967855624960451829383537598953548575881828345547330346069889322777641187811213598110111128995243111123109129752061651201762002867
Again a C227
Thank you for any feedback,
Email: pureprimes@yahoo.com
Web: http://www.heliwave.com
It seems the numbers have been truncated so I will break them into multiple 50digit lines, sorry for the double post.
72862001761201652067512910912311143529912811111098
13511278118647722793886960343073544583182887585545
38959373538291845604962557896292224131411111812123
05252442828205640315040464229193625221719263020152
111881958811118395473635456
=
2 x
2 x
2 x
2 x
2 x
2 x
2 x
7 x
5527 x
137885520290732817351584663 x
10670504717247126646866092856331785237990141601040
47233285661729577373957558406580220325692776185632
31217065120661299797289022426791599936582159383554
005399760617203071477939525944722428007054711
Is the above P195 a record for ECMs?
And here is the number being currently factored:
65453637459381111885198811211520302619172225361929
42464050314056202828445252301212181111141324222996
78556249604518293835375989535485758818283455473303
46069889322777641187811213598110111128995243111123
109129752061651201762002867
Thank you for any feedback
You found seven factors of 2, one factor of 7, one factor of 5527, and one 27digit factor of 137885520290732817351584663. You did not find the remaining P195 cofactor, it is just “left over” after all the factors that you did find. Sorry, not a record.