Montgomery curve x-only formulas (Costello–Smith §4) #
For a Montgomery curve
E : B y² = x³ + A x² + x
over a field F, the x-only differential-addition and doubling
formulas operate on projective pairs (X, Z) representing the
x-coordinate X/Z. The formulas use only field operations (no y).
What this file provides #
Basic algebraic properties of the formulas (projective invariance, commutativity of
xdbl's output shape, etc.).MontyParamsstructure capturing the curve parameters(A, B, p).The Costello–Smith §4 key identities stated as a hypothesis class
MontyCurveGroup, which axiomatises the correspondence between the x-only formulas and scalar multiplication on the abstract group.xdbl_eq:xdbl(X/Z) = x(2 · P)whenx(P) = X/Zxdadd_eq:xdadd(x(P), x(Q), x(P-Q)) = x(P + Q)
Why this is a hypothesis, not a theorem (yet) #
Proving xdbl_eq and xdadd_eq from first principles requires
- The Montgomery-form group law in affine coordinates (~2 pages of polynomial algebra).
- A birational map to Weierstrass form (or a direct point-addition formula).
- Case analysis for the point at infinity / doubling singularities.
This is the classical Costello–Smith §4 algebra. It's a page of
polynomial manipulation, doable in Lean in a few dozen lines once
the affine-coordinate group law is set up, but the group law itself
requires a Montgomery-curve structure in Mathlib that does not yet
exist (Mathlib has WeierstrassCurve but not MontgomeryCurve).
The correspondence is axiomatised and connected to the ladder
correctness proof in MontgomeryLadder.lean.
References #
- Costello, Smith, "Montgomery curves and the Montgomery ladder", IACR eprint 2017/212, §4 (equations 8, 9, 12, 13).
- Bernstein, "Curve25519: new Diffie-Hellman speed records", PKC 2006.
x-only formulas as pure field computation #
Projective x-only doubling (Costello–Smith eq. 12). Given (X, Z) with
X/Z = x(P), returns (X', Z') with X'/Z' = x(2 · P). Formula:
X' = (X + Z)² · (X − Z)² Z' = 4·X·Z · ((X − Z)² + ((A + 2)/4) · 4·X·Z)
We use the equivalent form with a single curve-parameter a24 = (A+2)/4.
Equations
Instances For
Projective x-only differential addition (Costello–Smith eq. 13).
Given (XP, ZP) for P, (XQ, ZQ) for Q, and (XD, ZD) for P−Q,
returns the projective x-coordinate of P + Q. Formula:
DA = (XP − ZP)(XQ + ZQ) CB = (XP + ZP)(XQ − ZQ) X' = ZD · (DA + CB)² Z' = XD · (DA − CB)²
Equations
Instances For
Algebraic properties #
Curve parameters #
Curve25519 parameters: A = 486662, a24 = 121666 = (486662 + 2)/4.
Note: some implementations use the constant 121665 = (A − 2)/4 with a
different doubling-formula variant. Here we use the (A + 2)/4 variant
corresponding to Costello–Smith eq. 12.
Equations
- CatCrypt.Crypto.ECC.curve25519Params F = { A := ↑486662, a24 := ↑121666 }
Instances For
Well-formedness: 4 * a24 = A + 2. Verifies for Curve25519 over any
field where the characteristic doesn't divide the value.
Costello–Smith §4 — polynomial identities #
The identities below are the algebraic content of Costello–Smith §4.
Each is a pure field identity, provable by the ring tactic. They
state that the x-only projective formulas compute the same values as
the affine slope-based formulas evaluated under the Montgomery curve
equation y² = x³ + A x² + x.
Once a Montgomery-curve group structure is in place (with affine
point addition), these identities are the core algebraic fact needed
to prove MontyCurveGroup.xdbl_spec and xdadd_spec.
xdbl polynomial identity (Costello–Smith §4, doubling).
The projective x-coordinate numerator xdbl.1 at input (x, 1)
equals (x² − 1)², matching the affine formula
x(2P) = λ² − A − 2x with λ = (3x² + 2Ax + 1) / (2y).
Specifically, over any commutative ring, the identity
(3x² + 2Ax + 1)² − 4(A + 2x)(x³ + Ax² + x) = (x² − 1)²
holds. This is the numerator identity that falls out of clearing
the common denominator 4(x³ + Ax² + x) = 4y² from the affine
expression for x(2P).
xdadd polynomial identity (Costello–Smith §4, differential
addition). Given points P, Q with x-coordinates xP, xQ and
their difference P − Q with x-coordinate xD, the projective
output of xdadd has numerator ((xP − 1)(xQ + 1) + (xP + 1)(xQ − 1))² = (2(xP xQ − 1))²
and denominator xD · ((xP − 1)(xQ + 1) − (xP + 1)(xQ − 1))² = xD · (2(xQ − xP))²
when Z coordinates are all normalised to 1.
The xdadd output with Z = 1 for all three projective inputs simplifies
to (2(xP xQ − 1))² · 1 and xD · (2(xQ − xP))² — the classical form.
Costello–Smith §4 correspondence (hypothesised group form) #
A Montgomery curve with a distinguished abelian group of points and an x-coordinate map. The key hypotheses encode Costello–Smith §4 §4.
xdbl_spec and xdadd_spec state that the x-only formulas agree with
scalar multiplication (equivalently: group addition) on the abstract
group. Proving these from the affine Montgomery curve group law is
the remaining work; see the header.
- xProj : G → F × F
Project a curve point to its projective x-coordinate
(X, Z). - xdbl_spec (P : G) : match xdbl params.a24 (xProj params P) with | (Xd, Zd) => match xProj params (P + P) with | (X2, Z2) => Xd * Z2 = X2 * Zd
xdblcomputes the x-coordinate of doubling, up to projective equivalence (both outputs represent the sameX/Z). - xdadd_spec (P Q : G) : match xdadd (xProj params P) (xProj params Q) (xProj params (P - Q)) with | (Xs, Zs) => match xProj params (P + Q) with | (Xa, Za) => Xs * Za = Xa * Zs
xdaddcomputes the x-coordinate of addition, up to projective equivalence, given the difference as auxiliary input.
Instances
Field-level x-only ladder #
The ladder below is the actual program a Jasmin (or bedrock2, or Rust)
implementation runs: pure field operations on projective pairs (X, Z),
no points, no y-coordinates, no group law. Connect it to the
abstract-group ladder via MontyCurveGroup using ProjEquiv.
One step of the field-level x-only ladder. Takes the projective
x-coordinate of the base point xP (as the invariant difference) and
the current (R₀_proj, R₁_proj) state, steps on bit b via xdbl
and xdadd.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Run the field-level ladder over a list of bits (MSB first) starting
from projective (1, 0) (infinity) and xP (the base point).
Equations
- CatCrypt.Crypto.ECC.xladderFold a24 xP [] = ((1, 0), xP)
- CatCrypt.Crypto.ECC.xladderFold a24 xP (b :: bs) = CatCrypt.Crypto.ECC.xladderStep a24 xP (CatCrypt.Crypto.ECC.xladderFold a24 xP bs) b
Instances For
xdbl respects projective equivalence: if two projective inputs
represent the same x-coordinate, their xdbl outputs do too.
Both numerator and denominator of xdbl are homogeneous polynomials
of degree 4 in (X, Z), so scaling both coordinates by a common
factor scales the output uniformly — ProjEquiv is preserved.
xdadd respects projective equivalence in all three arguments.
Key algebraic fact: DA + CB = 2(XPXQ − ZPZQ) and
DA − CB = 2(XPZQ − XQZP), and each of these is homogeneous of
degree 1 in each of (XP, ZP) and (XQ, ZQ). The ZD/XD
factors cancel under ProjEquiv (d, d').
Field-level ladder correctness #
Combines MontyCurveGroup.{xdbl_spec, xdadd_spec} with the invariant
(R₀, R₁) ∼ (xProj (n·P), xProj ((n+1)·P)) from
MontgomeryLadder.ladderFold_correct, where ∼ is projective equivalence.
The field-level ladder invariant: the state (R₀, R₁) projectively
represents (n · P, (n + 1) · P) for some running scalar n.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Restricted ProjEquiv transitivity over an integral domain.
ProjEquiv is transitive when the middle term is nondegenerate
(not both coordinates zero). Over a CommRing that isn't an
integral domain, transitivity can fail; we specialise to the
Field case (integral domain) and require nondegeneracy explicitly.
Doubling step preserves ProjEquiv, given the intermediate
xdbl (xProj (n·P)) is nondegenerate (Z ≠ 0). This is the
composition of xdbl_projEquiv, xdbl_spec, and ProjEquiv.trans.
Differential-addition step preserves ProjEquiv, given the
intermediate xdadd output is nondegenerate, and that xProj is
negation-invariant (xProj (-X) = xProj X).
Field-level ladder step preserves the invariant.
For bit b, scalar n advances to 2n + (if b then 1 else 0).
Requires: