Hubbry Logo
Lenstra elliptic-curve factorizationLenstra elliptic-curve factorizationMain
Open search
Lenstra elliptic-curve factorization
Community hub
Lenstra elliptic-curve factorization
logo
7 pages, 0 posts
0 subscribers
Be the first to start a discussion here.
Be the first to start a discussion here.
Lenstra elliptic-curve factorization
Lenstra elliptic-curve factorization
from Wikipedia

The Lenstra elliptic-curve factorization or the elliptic-curve factorization method (ECM) is a fast, sub-exponential running time, algorithm for integer factorization, which employs elliptic curves. For general-purpose factoring, ECM is the third-fastest known factoring method. The second-fastest is the multiple polynomial quadratic sieve, and the fastest is the general number field sieve. The Lenstra elliptic-curve factorization is named after Hendrik Lenstra.

Practically speaking, ECM is considered a special-purpose factoring algorithm, as it is most suitable for finding small factors. Currently, it is still the best algorithm for divisors not exceeding 50 to 60 digits, as its running time is dominated by the size of the smallest factor p rather than by the size of the number n to be factored. Frequently, ECM is used to remove small factors from a very large integer with many factors; if the remaining integer is still composite, then it has only large factors and is factored using general-purpose techniques. The largest factor found using ECM so far has 83 decimal digits and was discovered on 7 September 2013 by R. Propper.[1] Increasing the number of curves tested improves the chances of finding a factor, but they are not linear with the increase in the number of digits.

Algorithm

[edit]

Background

[edit]

Lenstra elliptic-curve factorization method uses a elliptic curve mod n (i.e. the number to be factored) and multiplies a random point P on it. The multiplication is based on elliptic curve point multiplication, which in turn is just the repeated addition of elliptic curve points, described in the article on elliptic curves. This addition would form a group in the non-modular case and in the case when n is prime, because (the integers modulo ) forms a group when n is prime.

When modular numbers are used instead of the whole range of integers, the addition of two points on the same elliptic curve would involve taking the modular slope of a chord joining and , and thus division between residue classes modulo , performed using the extended Euclidean algorithm. In particular, division by some includes calculation of the . Assuming we calculate a slope of the form with , then if , the result of the point addition will be , the point "at infinity" corresponding to the intersection of the "vertical" line joining and the curve. However, if , then the point addition will not produce a meaningful point on the curve; but, more importantly, is a non-trivial factor of : meaning that we have successfully factored the number.

The usual multiplication methods such as multiplication by doubling still apply. Naive successive addition is not required.

Process

[edit]

The Lenstra elliptic-curve factorization method to find a factor of a given natural number works as follows:

  1. Pick a random elliptic curve over (the integers modulo ), with equation of the form together with a non-trivial point on it.
    This can be done by first picking random , and then setting to ensure the point is on the curve.
  2. As discussed above, we have defined addition and multiplication of a point on the curve. With enough repeated additions, we should be able to cause a failure to add, thus finding us a factor. As a result, we compute on the elliptic curve (), where is a product of many small numbers.
    • k can be a product of small primes raised to small powers, as in the p-1 algorithm, or the factorial for some not too large . This can be done efficiently, one small factor at a time. Say, to get , first compute , then , then , and so on. is picked to be small enough so that -wise point addition can be performed in reasonable time.
  3. Check the result of the addition.
    • If we finish all the calculations above without encountering non-invertible elements (), it means that the elliptic curves' (modulo primes) order is not smooth enough, so we need to try again with a different curve and starting point.
    • If we encounter a we are done: it is a non-trivial factor of .

The time complexity depends on the size of the number's smallest prime factor and can be represented by exp[(2 + o(1)) ln p ln ln p], where p is the smallest factor of n, or , in L-notation.

Explanation

[edit]

If p and q are two prime divisors of n, then y2 = x3 + ax + b (mod n) implies the same equation also modulo p and modulo q. These two smaller elliptic curves with the -addition are now genuine groups. If these groups have Np and Nq elements, respectively, then for any point P on the original curve, by Lagrange's theorem, k > 0 is minimal such that on the curve modulo p implies that k divides Np; moreover, . The analogous statement holds for the curve modulo q. When the elliptic curve is chosen randomly, then Np and Nq are random numbers close to p + 1 and q + 1, respectively (see below). Hence it is unlikely that most of the prime factors of Np and Nq are the same, and it is quite likely that while computing eP, we will encounter some kP that is ∞ modulo p but not modulo q, or vice versa. When this is the case, kP does not exist on the original curve, and in the computations we found some v with either gcd(v,p) = p or gcd(vq) = q, but not both. That is, gcd(vn) gave a non-trivial factor of n.

ECM is at its core an improvement of the older p − 1 algorithm. The p − 1 algorithm finds prime factors p such that p − 1 is b-powersmooth for small values of b. For any e, a multiple of p − 1, and any a relatively prime to p, by Fermat's little theorem we have ae ≡ 1 (mod p). Then gcd(ae − 1, n) is likely to produce a factor of n. However, the algorithm fails when p − 1 has large prime factors, as is the case for numbers containing strong primes, for example.

ECM gets around this obstacle by considering the group of a random elliptic curve over the finite field Zp, rather than considering the multiplicative group of Zp which always has order p − 1.

The order of the group of an elliptic curve over Zp varies (quite randomly) between p + 1 − 2p and p + 1 + 2p by Hasse's theorem, and is likely to be smooth for some elliptic curves. Although there is no proof that a smooth group order will be found in the Hasse-interval, by using heuristic probabilistic methods, the Canfield–Erdős–Pomerance theorem with suitably optimized parameter choices, and the L-notation, we can expect to try L[2/2, 2] curves before getting a smooth group order. This heuristic estimate is very reliable in practice.

Example usage

[edit]

The following example is from Trappe & Washington (2006), with some details added.

We want to factor . Let's choose the elliptic curve , with the point on it, and let's try to compute the point .

The slope of the tangent line at some point on the curve is . Using , we can compute point . If the value of does not exist, as a result of not having a modular inverse, then is a non-trivial factor of .

First, we compute . Using point doubling, we have , so the coordinates of point are

yielding the point .

Next, we compute . We have . Since , the modular inverse of 106 exists. Using the extended Euclidean algorithm, we can obtain that .

Given this, we can compute the coordinates of , just as we did above. The coordinates of point are

This yields .

After this, we can compute using point addition. The line joining and has slope , so the coordinates of are

yielding the point

We can similarly compute points , , and so on, but computing requires inverting 599 (mod 455839), which is not possible because . Thus, we found a factorization 455839 = 599·761.

The reason this works is that the curve (mod 599) has 640 = 27·5 points, while (mod 761) it has 777 = 3·7·37 points. Moreover, 640 and 777 are the smallest positive integers k such that kP = ∞ on the curve (mod 599) and (mod 761), respectively. Since 8! is a multiple of 640 but not a multiple of 777, we have 8!P = ∞ on the curve (mod 599), but not on the curve (mod 761), hence the repeated addition broke down here, yielding the factorization.

The algorithm, with projective coordinates

[edit]

Before considering the projective plane over first consider a 'normal' projective space over : Instead of points, lines through the origin are studied. A line may be represented as a non-zero point , under an equivalence relation ~ given by: ⇔ ∃ c ≠ 0 such that x' = cx, y' = cy and z' = cz. Under this equivalence relation, the space is called the projective plane ; points, denoted by , correspond to lines in a three-dimensional space that pass through the origin. Note that the point does not exist in this space since to draw a line in any possible direction requires at least one of x',y' or z' ≠ 0. Now observe that almost all lines go through any given reference plane - such as the (X,Y,1)-plane, whilst the lines precisely parallel to this plane, having coordinates (X,Y,0), specify directions uniquely, as 'points at infinity' that are used in the affine (X,Y)-plane it lies above.

The corrdinate corresponds to in affine space.[2]

In the algorithm, only the group structure of an elliptic curve over the field is used. Since we do not necessarily need the field , a finite field will also provide a group structure on an elliptic curve. However, considering the same curve and operation over with n not a prime does not give a group. The Elliptic Curve Method makes use of the failure cases of the addition law.

We now state the algorithm in projective coordinates. The neutral element is then given by the point at infinity . Let n be a (positive) integer to be factored and consider the elliptic curve (a set of points with some structure on it) .

  1. Pick with a ≠ 0.
  2. Calculate . The elliptic curve E is then in Weierstrass form given by and by using projective coordinates the elliptic curve is given by the homogeneous equation . It has the point .
  3. Choose an upperbound for this elliptic curve.
    • Remark: You will only find factors p if the group order g of the elliptic curve E over (denoted by ) is B-smooth, which means that all prime factors of have to be less or equal to B.
  4. Calculate .
  5. Calculate (multiplication is repeated addition) in the ring .
    • If the calculation successfully returns , it means g is not B-smooth or n is prime. Go back to step 2 to pick another curve.
    • If the calculation fails at some point, it means a non-trivial divisor can be found. It can fail because addition and multiplication are not well-defined if n is not prime, but this only occurs when a inversion of a particular residue v is tried. In this case the factor is found as as above.

In point 5 it is said that under the right circumstances a non-trivial divisor can be found. As pointed out in Lenstra's article (Factoring Integers with Elliptic Curves) the addition needs the assumption . If are not and distinct (otherwise addition works similarly, but is a little different), then addition works as follows:

  • To calculate: ,
  • ,
  • ,
  • ,
  • .

If addition fails, this will be due to a failure calculating In particular, because can not always be calculated if n is not prime (and therefore is not a field). Without making use of being a field, one could calculate:

  • ,
  • ,
  • ,
  • , and simplify if possible.

This calculation is always legal and if the gcd of the Z-coordinate with n ≠ (1 or n), so when simplifying fails, a non-trivial divisor of n is found.

Two-stage variant

[edit]

Analogous to the two-stage variant of Pollard's p − 1 algorithm, Lenstra ECM can too be done in two stages. This allows one to save a time factor of O(log p).[2]

Algorithm Two-Stage ECM.[2]

  • Input: number to be factored n, integer bounds .
  • Output: a factor of n or failure.

Preparation.

  1. Choose a random elliptic curve E mod n.
  2. Pick a point on the curve.

Stages.

  1. Compute a point on the E. The product means that one loops over every prime ; it plays the same role as the large seen in the algorithms above.
  2. For each prime p, ,
    • Compute a point on E.
    • Compute . If , output and exit.
  3. If all primes in range are tried without producing a factor, report failure.

It is possible for stage 1 to yield a factor like previously discussed: a non-invertible denominator implies a factor. is functionally the same as from the standard version, so it too happens when the group order g is B-smooth. In other words, one looks for a prime divisor p such that is the neutral element of in stage 1.

The second stage is very similar to the second stage of p-1 and p+1. It is a continuation of the work in stage 1 and can be described using very similar mathematical terms. It relaxes the condition such that one can find a factor when g is -smooth, or in other words the largest prime factor of g is at most and the second-smallest is at most .

To achieve stage 2, one hopes there is a prime p between and such that ; looking for a failed inversion would produce it after a gcd. Equivalently, one is looking for a prime divisor q such that has small prime order in . Checking for a small order of is done in stage 2 by computing modulo n for each prime l.[2]

The above describe the "naive" approach, which is amenable to prime-pairing optimization and Brent-Suyama extension. However, a much faster polynomial stage 2 is also available, being derived from the polynomial p-1 stage 2 (Montgomery and Kruppa 2008).[3] This new approach is found in GMP-ECM and Prime95.[4]

Twisted Edwards curves

[edit]

The use of Edwards curves needs fewer modular multiplications and less time than the use of Montgomery curves or Weierstrass curves (other used methods). Using Edwards curves you can also find more primes.

Definition. Let be a field in which , and let with . Then the twisted Edwards curve is given by An Edwards curve is a twisted Edwards curve in which .

There are five known ways to build a set of points on an Edwards curve: the set of affine points, the set of projective points, the set of inverted points, the set of extended points and the set of completed points.

The set of affine points is given by:

.

The addition law is given by

The point (0,1) is its neutral element and the inverse of is .

The other representations are defined similar to how the projective Weierstrass curve follows from the affine.

Any elliptic curve in Edwards form has a point of order 4. So the torsion group of an Edwards curve over is isomorphic to either or .

The most interesting cases for ECM are and , since they force the group orders of the curve modulo primes to be divisible by 12 and 16 respectively. The following curves have a torsion group isomorphic to :

  • with point where and
  • with point where and

Every Edwards curve with a point of order 3 can be written in the ways shown above. Curves with torsion group isomorphic to and may be more efficient at finding primes.[5]

Software implementations

[edit]

GMP-ECM of Paul Zimmerman is a general-purpose implementation of the Lenstra algorithm based on the GNU Multiple Precision Arithmetic Library. It has been continually updated, with the latest version as of September 2025 being 7.0.6 from July 2024. It allows Montgomery, Weierstrass, and (twisted) Hessian curves. It can run stage 1 for a subset of Montgomery curves on a CUDA GPU, with the earlier implementation by Cyril Bouvier in 2012 having been replaced by Seth Troisi's newer implementation in 2021. Version 7.0.6 also includes an implmentation of the HECM method, (described below), the p-1 and p+1 methods, and primality proving using APRCL.[6] GMP-ECM is used in SageMath.

Daniel J. Bernstein and coworkers have published a series of implementations based on Twisted Edwards elliptic curves between 2008 and 2010. They all claim to outperform the contemporary version of GMP-ECM, with the latest being EECM-MPFQ of 2008. Two GPU implementations are also available from Bernstein, the newer and faster one being CUDA-EECM of 2009.[5][7]

Prime95 includes an implementation of Lenstra ECM for Montgomery and Edwards curves. It is used for the ECM subproject of Great Internet Mersenne Prime Search, which seeks to factor composite Mersenne numbers no smaller than 21213.[8] It can produce stage 1 output compatible with GMP-ECM as well as consume stage 1 output from GMP-ECM.[9] It is faster than GMP-ECM at stage 1.[10]

John Wloka and coworkers published ecmongpu, an implementation of both stage 1 and stage 2 of Lenstra ECM based on Twisted Edwards elliptic curves, in 2020. Their paper report on performance for factoring moduli up to 448 bits long (between 2447 and 2448-1).[11]

All software listed above are open-source. In addition, the open-source PARI/GP and proprietary Magma (computer algebra system) also contain "good ECM implementations" according to Paul Zimmerman.[10] An earlier 16-bit software implementation[12] is giantint by Richard Crandall.[10]

Hyperelliptic-curve method (HECM)

[edit]

There are recent developments in using hyperelliptic curves to factor integers. Cosset shows in his article (of 2010) that one can build a hyperelliptic curve with genus two (so a curve with f of degree 5), which gives the same result as using two "normal" elliptic curves at the same time. By making use of the Kummer surface, calculation is more efficient. The disadvantages of the hyperelliptic curve (versus an elliptic curve) are compensated by this alternative way of calculating. Therefore, Cosset roughly claims that using hyperelliptic curves for factorization is no worse than using elliptic curves.

Quantum version (GEECM)

[edit]

Bernstein, Heninger, Lou, and Valenta suggest GEECM, a quantum version of ECM with Edwards curves.[13] It uses Grover's algorithm to roughly double the length of the primes found compared to standard EECM, assuming a quantum computer with sufficiently many qubits and of comparable speed to the classical computer running EECM.

References

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
The Lenstra elliptic-curve factorization method (ECM) is a probabilistic for , introduced by Hendrik Willem Lenstra Jr. in 1985, that leverages defined over the modulo a n to identify small prime factors of n. Drawing inspiration from Pollard's p-1 method, ECM replaces computations in the of units with scalar multiplications on groups, where the order of the group modulo a prime factor p is likely to be smooth (i.e., composed of small prime powers) under Hasse's theorem, enabling efficient point multiplication until a gcd computation reveals a non-trivial of n. The proceeds by randomly selecting and points, performing bounded scalar multiplications, and repeating with new curves if no factor is found, achieving an expected running time of approximately e^{ (√2 + o(1)) √(log p log log p) } (log n)^2 , where p is the smallest prime factor of n, making it subexponential in log p and particularly efficient for factors up to about 50-60 digits. _ Unlike general-purpose methods such as the quadratic sieve or number field sieve, which have running times exponential in √(log n), ECM's performance scales primarily with the size of the target factor rather than n itself, requiring only O(log n) storage and rendering it ideal for parallelization and practical use in scenarios like primality testing or factoring Cunningham numbers. Key enhancements include Richard Brent's 1986 addition of a second stage exploiting the birthday paradox to search for factors in a bounded range, and J. L. Montgomery's 1987 optimizations using homogeneous coordinates and fast Fourier transform-based polynomial multiplication to reduce the cost of elliptic curve additions. By the early 2000s, ECM had successfully discovered record factors of up to 55 digits, such as in the factorization of Fermat numbers and other challenging composites. As of 2025, the largest factor found using ECM has 83 digits, discovered in 2013, and it remains a staple in computational number theory tools like GMP-ECM for its balance of speed and simplicity in detecting medium-sized factors. _

Introduction and History

Development and Key Contributors

The Lenstra elliptic-curve factorization method (ECM) was invented in 1985 by Hendrik Willem Lenstra Jr. as a probabilistic for , generalizing John Pollard's 1974 p-1 method by replacing the of integers the unknown prime factor with the group of points on a randomly chosen . This approach leverages the variability in the order of elliptic curve groups over finite fields, as bounded by Hasse's , to detect factors more effectively for primes in a moderate size range. Lenstra's foundational work was published in 1987 under the title "Factoring Integers with Elliptic Curves" in the Annals of Mathematics, where he provided a detailed analysis of the method's expected running time and its subexponential complexity. The development of ECM occurred contemporaneously with the independent proposals for elliptic curve cryptography by Neal Koblitz and Victor Miller in 1985, which established the mathematical foundations for elliptic curves over finite fields in computational number theory. Early practical implementations of ECM emerged in the late 1980s, with significant optimizations introduced by Peter L. Montgomery in 1987, including improvements to point multiplication and stage 2 processing using fast techniques. In the 1990s, further refinements focused on stage 2 efficiency, such as those analyzed by Robert D. Silverman and Samuel S. Wagstaff Jr. in 1993, which provided empirical data on parameter choices and performance for factoring primes up to around 40 digits. Modern implementations, including the widely used GMP-ECM library developed by Paul Zimmermann starting in the late 1990s, incorporate these advancements and continue to evolve for environments. Records have progressed, with the largest factor found using ECM reaching 83 digits in 2013 from numbers like 7^{337} + 1, and recent contributions including 78-digit factors in 2023 from numbers.

Overview and Applications

The Lenstra elliptic-curve factorization method (ECM) is a probabilistic algorithm designed to discover small to medium-sized prime factors of a composite integer NN. It leverages elliptic curves defined modulo NN and relies on the randomness of curve selection to increase the likelihood of success. Specifically, ECM detects a prime factor pp of NN when the order of the elliptic curve group over the finite field Fp\mathbb{F}_p divides a chosen scalar multiple, causing a failure in point inversion during scalar multiplication; this failure allows computation of gcd\gcd with NN to isolate pp. The method's probabilistic nature stems from the variability in the trace of Frobenius for different curves, which influences the smoothness of the group order modulo pp. Heuristically, the expected running time for ECM to find a pp-bit prime factor is O(exp(2logploglogp))O\left(\exp\left(\sqrt{2 \log p \log \log p}\right)\right)
Add your contribution
Related Hubs
User Avatar
No comments yet.