Purpose: Factor an integer using elliptic curves. Its running time depends on the size of the smallest prime factor, not on itself — which makes it the best method for pulling medium-sized factors (up to ~60-70 digits) out of very large numbers.
From Pollard’s to elliptic curves
Pollard’s method: if is -smooth, then for we have by Fermat, so reveals . The fatal weakness: it only works when that particular happens to be smooth, and you cannot change .
Lenstra’s insight: replace the group (order , fixed) with the group of points on an elliptic curve mod (order in by Hasse’s theorem, and different for every curve). Now if one curve’s order is not smooth, you simply try another. You get unlimited retries.
Algorithm
- Pick a random curve and a random point on it. (Trick: pick at random and define , so is on the curve by construction.)
- Compute on modulo , where , using repeated point addition.
- Point addition requires inverting a denominator mod . If that inversion fails, the gcd computed during the extended Euclid gives a non-trivial factor of — that failure is the success condition.
- If no failure occurs, pick a new curve and repeat. Optionally add a stage 2 that handles one additional prime factor between and a larger .
Complexity
where is the smallest prime factor — plus per curve operation.
Suggested by factor size
| Digits of the factor | Curves needed | |
|---|---|---|
| 15 | 2 000 | ~25 |
| 20 | 11 000 | ~90 |
| 30 | 250 000 | ~700 |
| 40 | 3 000 000 | ~2 400 |
| 50 | 44 000 000 | ~7 500 |
Why the failure is the point
Working “mod ” on a curve is not really a group — it is a group modulo each prime factor simultaneously. When (the identity) modulo but not modulo another prime factor , the addition formula tries to invert something divisible by but not by . The extended Euclid inside modinv then hands you . This happens exactly when the curve’s order modulo is -smooth — and since curve orders vary, enough tries will find one.
Variants / Use Cases
- Montgomery curves and the ladder — the standard implementation; avoids inversions in the inner loop entirely
- Stage 2 (continuation) — catches factors whose order is smooth except for one larger prime; roughly doubles effectiveness for the same cost
- Pollard’s rho — better for small factors (< 20 digits); simpler, no curve arithmetic
- Quadratic Sieve / GNFS — better when is a semiprime with two equally large factors, which ECM handles poorly
- Integer Factorization — the topic page and the strategy for combining these methods