Expand description
§Elliptic-curve primitives over ℤ/N — the additive→multiplicative lift
Pollard’s p−1 gets a single shot at a smooth group order: the multiplicative group (ℤ/p)* has the
fixed order p−1, so if that one number isn’t smooth, you lose. Lenstra’s Elliptic Curve Method
lifts the problem onto E(𝔽_p), whose order — by Hasse — lies in [p+1−2√p, p+1+2√p] and, crucially,
changes when you change the curve. Every curve is a fresh smoothness lottery ticket, and the cost
scales with the size of the smallest factor, not N — which makes ECM the champion for prying a
small-to-medium prime out of an otherwise-huge modulus.
We work in Montgomery form B·y² = x³ + A·x² + x with x-only (X:Z) projective coordinates.
Two payoffs: point arithmetic never needs a modular inverse (only +, −, × mod N), and the ONE
place an inverse would be forced — when a point becomes the identity mod p but not mod q, so its
Z is ≡ 0 (mod p) but ≢ 0 (mod N) — is exactly where gcd(Z, N) hands us the factor. The “failure”
of the group law is the discovery.
This module is the reusable substrate: xdbl, xadd, and ladder are ordinary elliptic-curve
group operations mod N and underpin ECDLP / pairing / isogeny work later; ecm_factor is the
flagship application.
Structs§
- Curve
- A short Weierstrass curve
y² = x³ + a·x + bover the prime field𝔽_p. - Isogeny
- A separable isogeny
φ: E → E'of odd prime degreeℓ, built from a kernel generator by Vélu’s formulas. Stores the codomain and, for each kernel representativeQ(one per±pair), the Vélu quantities(xQ, vQ = 6xQ²+2a, uQ = 4yQ²)used to evaluateφ. - Isogeny
Step - A single
ℓ-isogeny step in a chain: thedomaincurve, the order-ℓkernelpoint quotiented at this step, and the resultingcodomain.
Enums§
- Curve
Weakness - The known STRUCTURAL weaknesses that make an elliptic curve’s ECDLP breakable — the symmetries a sound curve must avoid.
- Point
- An affine point on a curve, or the point at infinity (the group identity).
Functions§
- curve_
security - Audit a curve of known order
#Eover𝔽_pfor the structural ECDLP weaknesses.Nonemeans the only attacks that apply are the genericO(√·)ones — the honest ceiling, not a proof of security. - derive_
isogeny_ path - Torsion-image → path derivation. A degree-
ℓᵃisogeny is pinned down by a single kernel generatorgenof orderℓᵃ— the datum the SIDH/SIKE torsion images reconstruct (via Kani’s gluing). This unfolds that one generator into the explicit chain ofaprime-degreeℓ-isogenies: at stepithe kernel is the order-ℓpoint[ℓ^{a−1−i}]·genᵢ, andgenis pushed forward through each step so its order descendsℓᵃ → ℓᵃ⁻¹ → … → 1. The entire secret path pops out of the one meta-datum — the generator is the rule that emits the per-step rules. Requiresℓan odd prime andgenof order exactlyℓᵃ. - ecdlp_
bsgs - Solve the elliptic-curve discrete log
Q = k·Pby baby-step/giant-step, given the ordernofP.O(√n)group operations — the best generic attack, and exponential in the bit length. This is exactly why a sound (large prime-order) curve resists, and why ECC uses far smaller keys than RSA.NoneifQis not a multiple ofP. - ecm
- ECM stage 3 — the escalating driver. Stages 1 and 2 are the algorithm; this is the orchestration that
makes ECM a complete tool (à la GMP-ECM): run the two-stage method at a schedule of increasing bounds
(b1, b2 = 100·b1)with growing curve counts, so a factor of any size is found at the cheapest level that reaches it — small factors fall almost immediately, larger ones as the bounds climb, without ever paying the big-bound cost up front.budgetcaps the curves per level.Noneif the whole schedule finishes without a factor. - ecm_
factor - Lenstra’s ECM, stage 1 only. Try
curvesSuyama curves at smoothness boundb1; a nontrivial factor ofn, orNone. Cost tracks the smallest factor, notn.Noneforn ≤ 3. - ecm_
two_ stage - ECM with stage 1 + stage 2. Stage 2 (bound
b2 > b1) extends each curve’s reach to a group order that isb1-smooth apart from one prime≤ b2— a large boost per curve for a small extra cost. - kernel_
generator - The SIDH kernel generator
P + [s]·Qfrom a torsion basis(P, Q)and the secret scalars. The secret isogeny is the quotient by⟨P + [s]Q⟩; Kani’s gluing is what lets an attacker recoversfrom the published torsion images, after whichderive_isogeny_pathunfolds the whole chain. - ladder
- Scalar multiplication
k·(X:Z)on a Montgomery curve modnby the Montgomery ladder — a uniform sequence of one double and one differential-add per bit, maintaining the invariantR1 − R0 = P. - point_
of_ order - A single point of prime order
ellon the curve (a candidate isogeny-kernel generator), orNoneif there is no rationalell-torsion. Requiresp ≡ 3 (mod 4). - torsion_
basis - A torsion basis of
E[n](nprime): two independent points of orderngenerating the fulln-torsion(ℤ/n)², orNoneif then-torsion is not fully rational. Requiresp ≡ 3 (mod 4). This is the public torsion basis whose images an SIDH/SIKE key publishes. - weil_
pairing - The Weil pairing
e_N(P, Q) ∈ μ_Nfor independentN-torsion pointsP, Q, via Miller:e_N(P,Q) = (−1)ᴺ · f_{N,P}(Q) / f_{N,Q}(P). Bilinear, alternating, non-degenerate, and (the SIKE- relevant law) isogeny-compatible.Noneif a Miller evaluation degenerates (e.g. dependent points). - xadd
- x-only differential addition on a Montgomery curve mod
n: givenP=(Xp:Zp),Q=(Xq:Zq)and their known differenceP−Q = (Xd:Zd), returnP+Q. Again inversion-free. - xdbl
- x-only doubling on a Montgomery curve mod
n, givena24 = (A+2)/4. Maps(X:Z)to2·(X:Z)using only field+ − ×(no inversion).