← LibraryThe Elliptic Curve Method (ECM)Engineering · MathematicsLesson 6/8← PrevNext →
GuidePublished 6 Aug 20265 min readBy Kevin JoginComputational Number TheoryFactoringElliptic Curve MethodECM
Skip to the main content

MathematicsFactoring

The Elliptic Curve Method (ECM)

Lenstra's insight: if the group order is unfavourable, change the group — making the cost depend on the size of the factor rather than the size of n.

Executive summary

Resample the group until its order is smooth

Pollard's p−1 method fails when p − 1 is not smooth, and nothing can be done — the group is fixed. Lenstra replaced it with the group of an elliptic curve modulo n, whose order varies with the curve across the Hasse interval. Trying many curves eventually finds one with smooth order. Because success depends on the size of the factor rather than of n, ECM is the method of choice for finding medium-sized factors of very large numbers.

Learning objectives

  • Explain why arithmetic on a curve modulo a composite reveals factors.
  • Describe the two-stage structure and its bounds.
  • State the complexity in terms of the factor size.
  • Choose curve parameterisations that guarantee useful torsion.
  • Position ECM correctly within a factoring pipeline.

Section 01Curves modulo a composite

The set of points satisfying a Weierstrass equation modulo composite n is not a group — the addition formulas require inverting x2 − x1, which may not be invertible. That failure is precisely the mechanism.

The productive failure

If gcd(x2 − x1, n) is non-trivial, the addition has failed — and that GCD is a factor of n. Geometrically, the points have become equal modulo p but not modulo q, so the computation has detected the difference between the two reductions.

By the Chinese remainder theorem, the curve modulo n corresponds to curves modulo each prime factor. Computing [M]P for a smooth M reaches the identity modulo p as soon as M is a multiple of the order of P in the curve group modulo p — and the inversion then fails.

Section 02The algorithm

AlgorithmECM, one curvein: n, bounds B1, B2  →  out: a factor, or restart
  1. Choose a random curve E and a point P on it modulo n, by choosing the point first and solving for a curve coefficient. Avoids square roots modulo n, which cannot be computed without the factorisation.
  2. Set M ← ∏ q⌊logq B1 over primes q ≤ B1.
  3. Compute [M]P by scalar multiplication, watching every inversion. A failed inversion yields the factor.
  4. If no failure occurs, run stage two: sweep primes in (B1, B2], batching GCDs.
  5. If still nothing, discard the curve and start again with a new one.
Each curve is an independent trial. The expected number of curves depends on the size of the smallest factor, not on n.
Lp[1/2, √2]complexity in terms of the factor p
60 digitslargest factors found in practice
Embarrassingly parallelcurves are fully independent
Cost depends on the factor, not on n

This is what distinguishes ECM from the sieves. A 40-digit factor of a 400-digit number is found as easily as a 40-digit factor of an 80-digit number. No sieve can say that, which is why ECM is run before any sieve.

Section 03Implementation choices

Practical ECM implementation
ChoiceStandard practiceReason
Curve formMontgomery curvesScalar multiplication needs only x-coordinates; the ladder is fast and uniform
ParameterisationSuyama or Edwards familiesGuarantees torsion dividing the order, raising the chance of smoothness
CoordinatesProjective, one inversion at the endDeferring inversion is faster — the GCD is then taken on the accumulated denominator
Stage twoStandard or improved continuationExtends reach for one large prime at a fraction of stage one's cost
Bound selectionB1 chosen for the target factor sizePublished tables give optimal B1 and expected curve counts by digit level
Deferred inversion changes the failure detection

With projective coordinates there are no intermediate inversions to fail, so the factor is found by taking a GCD of the accumulated Z-coordinate with n at the end of each stage. An implementation that simply ports affine code and defers inversion without adding this GCD will never find anything.

Section 04Position in the pipeline

  1. Stage 01After trial division and rhoSmall factors should already be gone; ECM targets the 15 to 60 digit range.
  2. Stage 02Escalate the boundsRun a batch of curves at a modest B1, then increase — cheap attempts first, following the standard digit-level tables.
  3. Stage 03Recurse on cofactorsEvery factor found must be primality tested, and composite cofactors returned to the pipeline.
  4. Stage 04Hand over to a sieveIf ECM has not split n after the effort appropriate to its largest plausible factor, the factors are probably balanced — switch to MPQS or NFS.
The decisive division of labour

ECM handles unbalanced factorisations; the sieves handle balanced ones. An RSA modulus with two equal-sized primes is exactly the case ECM cannot help with, which is why key generation targets that shape.

ReferenceFrequently asked questions

Why choose the point before the curve?

Because constructing a curve first and then finding a point on it requires a square root modulo n, which cannot be computed without the factorisation. Choosing x, y and one coefficient and solving for the other avoids the problem entirely.

How many curves are needed?

It depends on the factor size and the bounds. Published tables give expected curve counts for each digit level — for a 40-digit factor, thousands of curves at appropriate bounds. Since curves are independent, this parallelises perfectly.

Does the torsion of the curve matter?

Yes. Parameterisations that force a torsion subgroup of order 12 or 16 make the group order divisible by that amount, raising the probability of smoothness measurably. This is why structured families are used rather than genuinely random curves.

NavigateContinue in this stream

Curated next steps from this page. The site also surfaces algorithmically related reading below.

ProvenanceSources and further reading

This page is an original KEVOS explanatory article. It presents the underlying mathematics — definitions, algorithms, complexity results and selection criteria — in KEVOS editorial voice. No text is reproduced from any copyrighted source. Where numerical tables are relevant, KEVOS links to live authoritative databases rather than republishing static values.

Page ID
KV-MATH-0054
Taxonomy
ENG-MATH — Engineering / Mathematics
Collection
COL-CANT-001
Topic stream
CANT-FACTORING
Version
1.1.0 / content 2026.08
Last reviewed
2026-08-06

Continue learning

The Continued Fraction Factoring MethodGuide · MathematicsNEXT LESSON →The Quadratic Sieve and MPQSGuide · MathematicsPollard's p−1 Method and Its RelativesGuide · MathematicsThe Number Field SieveGuide · Mathematics