← LibraryECM Stage Two and Practical TuningEngineering · MathematicsLesson 374/385← PrevNext →
ArticlePublished 7 Aug 20263 min readBy Kevin JoginECMstage twoB2 boundlarge prime

Modern Factoring Methods

ECM Stage Two and Practical Tuning

ECM stage two, the large prime search, and how the two bounds are tuned together.

Engineering / MathematicsModern Factoring Methods2 min readKV-MATH-0671

Stage two handles the common case where the curve order is smooth except for one prime above the stage one bound. Searching for that single prime is far cheaper than extending stage one to cover it.

The situation

After stage one the point has been multiplied by every prime power below the first bound. If the order equals that smooth part times one larger prime, multiplying by that prime completes the job.

order = (smooth part below B1) x q, B1 < q <= B2Stage two searches for the single remaining prime q.

The search

ECM stage two

  1. Take the stage one resultThe point after multiplication by the smooth scalar.
  2. Precompute small multiplesA table of multiples spanning the step size.
  3. Step through the rangeGiant steps across the interval between the bounds.
  4. Accumulate differencesMultiply coordinate differences together rather than taking a GCD each time.
  5. Take one GCDAt the end of the accumulation.

Tuning the two bounds

The two ECM bounds
BoundControlsTypical relation
Stage one boundThe smooth part coveredSet by target factor size
Stage two boundThe single large prime rangeCommonly around a hundred times the first

How many curves

The expected number of curves needed for a factor of a given size is computed from the smoothness probability at the chosen bounds. Tables of recommended bounds and curve counts by digit size are standard and should be used rather than derived.

Improvements

Brent-Suyama extension

Uses polynomial evaluation to cover the stage two range more efficiently, effectively extending the reach for the same work.

Batch stage two

Runs stage two for many curves together, sharing the precomputed tables.

FFT-based stage two

Uses fast polynomial arithmetic to evaluate many candidates at once; the standard approach in high-performance implementations.

Where ECM fits

ECM is used to strip medium factors before a sieve is applied, and to factor the cofactors arising in smoothness testing. See method comparison.

Source. Henri Cohen, A Course in Computational Algebraic Number Theory, Springer GTM 138 — 10.3.4. Structural reference unverified: the source file was not available during authoring; chapter and section numbers are taken from the published edition and have not been checked against a physical copy.

Continue learning

The Elliptic Curve Method: Stage OneArticle · MathematicsNEXT LESSON →Quadratic Sieve Factor Base SelectionArticle · MathematicsElliptic Curve Arithmetic Modulo NArticle · MathematicsThe Quadratic Sieve: Sieving StageArticle · Mathematics