Quadratic twists of Weierstrass curves and their point counts #
For a Weierstrass curve W in IsCharNeTwoNF form Y² = X³ + a₂ X² + a₄ X + a₆ over a
commutative ring R and a scalar c : R, the quadratic twist W.quadraticTwist c is the
Weierstrass curve Y² = X³ + c a₂ X² + c² a₄ X + c³ a₆, with discriminant c⁶ W.Δ. Over a field
F with c ≠ 0, the coordinate scaling (x, y) ↦ (c x, c² y) identifies the solutions of the
twisted equation c y² = x³ + a₂ x² + a₄ x + a₆ with the affine solutions of
W.quadraticTwist c (WeierstrassCurve.quadraticTwistEquationEquiv), and when W is elliptic it
identifies (W.quadraticTwist c).toAffine.Point with the point at infinity together with those
solutions (WeierstrassCurve.quadraticTwistPointEquiv).
Over a finite field F, twisting the cubic X³ + α X² + β X + γ by c ≠ 0 multiplies its
character sum cubicCharSum by quadraticChar F c. When c is a quadratic non-residue
(¬ IsSquare c), the character sums of W and W.quadraticTwist c cancel, giving
#E(F) + #Ẽ(F) = 2 #F + 2 (and #Ẽ(F) = #F + 1 + t when #E(F) = #F + 1 - t), as in
Boneh and Shoup, A Graduate Course in Applied Cryptography, Section 15.3.2
(p. 623).
Note that WeierstrassCurve.Manin.twistPoly in ManinTwist.lean is the instance
(ofCubic (C α) (C β) (C γ)).quadraticTwist (cubicPoly α β γ) over Polynomial k (with
WeierstrassCurve.Manin.twist its base change to RatFunc k), used internally in Manin's proof
of Hasse's bound.
Main definitions #
WeierstrassCurve.quadraticTwist W c: the Weierstrass curveY² = X³ + c a₂ X² + c² a₄ X + c³ a₆.WeierstrassCurve.quadraticTwistEquationEquiv: the coordinate-scaling equivalence(x, y) ↦ (c x, c² y)from solutions ofc y² = x³ + a₂ x² + a₄ x + a₆to affine solutions ofW.quadraticTwist c.WeierstrassCurve.quadraticTwistPointEquiv: for ellipticW, the equivalence between(W.quadraticTwist c).toAffine.PointandWithZeroof the solutions ofc y² = x³ + a₂ x² + a₄ x + a₆.
Main results #
WeierstrassCurve.quadraticTwist_Δ:(W.quadraticTwist c).Δ = c ^ 6 * W.Δ.WeierstrassCurve.isElliptic_quadraticTwist:W.quadraticTwist cis elliptic whenWis elliptic inIsCharNeTwoNFform andcis a unit.WeierstrassCurve.ringChar_ne_two_of_isCharNeTwoNF: over a field, an elliptic curve inIsCharNeTwoNFform forcesringChar F ≠ 2.WeierstrassCurve.natCard_point_quadraticTwist_eq_one_add,WeierstrassCurve.natCard_point_quadraticTwist_eq_one_add_of_isShortNF: the number of points ofW.quadraticTwist cis one plus the number of solutions ofc y² = x³ + a₂ x² + a₄ x + a₆(orc y² = x³ + a₄ x + a₆).WeierstrassCurve.cubicCharSum_mul: forc ≠ 0, twisting scalescubicCharSumbyquadraticChar F c.WeierstrassCurve.natCard_point_quadraticTwist: forc ≠ 0and ellipticW,#Ẽ(F) = #F + 1 + χ(c) · cubicCharSum W.a₂ W.a₄ W.a₆.WeierstrassCurve.natCard_point_quadraticTwist_of_isSquare: twisting by a nonzero square preserves#E(F).WeierstrassCurve.natCard_equation_add_quadraticTwist: for¬ IsSquare c, the affine solution sets ofWandW.quadraticTwist chave2 #Fpoints in total, even withoutIsElliptic.WeierstrassCurve.natCard_point_add_quadraticTwist,WeierstrassCurve.natCard_point_add_quadraticTwist_zmod: for¬ IsSquare c,#E(F) + #Ẽ(F) = 2 #F + 2(and2 p + 2overZMod p).WeierstrassCurve.natCard_point_quadraticTwist_eq_of_eq_sub: if#E(F) = #F + 1 - tand¬ IsSquare c, then#Ẽ(F) = #F + 1 + t.
Implementation notes and deviations from the source #
- [BS23], Section 15.3.2 (p. 623) writes the twist of
y² = x³ + a x + bover𝔽_p(p > 3) as the non-monic equationc y² = x³ + a x + b. Because Mathlib'sWeierstrassCurveis monic inY²andX³,W.quadraticTwist cis defined as the isomorphic Weierstrass modelY² = X³ + c a₂ X² + c² a₄ X + c³ a₆, andquadraticTwistPointEquivrecords the explicit bijection withWithZeroof the solutions ofc y² = x³ + a₂ x² + a₄ x + a₆. - The results are stated for any curve satisfying
[W.IsCharNeTwoNF](a₁ = 0anda₃ = 0, which includesofCubic α β γand short Weierstrass curves[W.IsShortNF]) over any finite fieldF, withnatCard_point_add_quadraticTwist_zmodspecializing toZMod p. Over a field,[W.IsCharNeTwoNF]together with[W.IsElliptic]forcesringChar F ≠ 2, so odd characteristic is not needed as a separate hypothesis. - The informal notion of "twist security" and the 256-bit twist-order factorizations of secp256r1 and secp256k1 in [BS23], Section 15.3.2 are not formalized here.
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Section 15.2 (Equation (15.4), p. 618) and Section 15.3.2 (p. 623).
The quadratic twist of a Weierstrass curve #
Every curve ofCubic α β γ (Y² = X³ + α X² + β X + γ) is in IsCharNeTwoNF form
(a₁ = 0 and a₃ = 0).
The quadratic twist of a Weierstrass curve W (in IsCharNeTwoNF form
Y² = X³ + a₂ X² + a₄ X + a₆) by c : R, namely the Weierstrass curve
Y² = X³ + c a₂ X² + c² a₄ X + c³ a₆ ([BS23], Section 15.3.2, p. 623).
When c is a unit, the change of coordinates (x, y) ↦ (c x, c² y) identifies its affine
solutions with those of the twisted equation c y² = x³ + a₂ x² + a₄ x + a₆.
Outside IsCharNeTwoNF, a₁ and a₃ are ignored and W.quadraticTwist c is not the quadratic
twist of W.
Instances For
For a curve W in IsCharNeTwoNF form, the discriminant of W.quadraticTwist c is
c⁶ * W.Δ.
Twisting an elliptic curve in IsCharNeTwoNF form by a unit yields an elliptic curve.
Bijection with solutions of the twisted equation c y² = x³ + a₂ x² + a₄ x + a₆ #
Over a field, an elliptic curve in IsCharNeTwoNF form (a₁ = a₃ = 0) exists only in
characteristic different from two: in characteristic two its discriminant vanishes. This supplies
the hypothesis ringChar F ≠ 2 of natCard_point_eq and hasse_bound for such a curve.
Over a field, (c x, c² y) lies on W.quadraticTwist c iff (x, y) satisfies the twisted
equation c y² = x³ + a₂ x² + a₄ x + a₆.
Scaling coordinates by (x, y) ↦ (c x, c² y) identifies the solutions of the twisted
equation c y² = x³ + a₂ x² + a₄ x + a₆ with the affine solutions of W.quadraticTwist c.
For an elliptic curve W in IsCharNeTwoNF form and c ≠ 0, the points of
W.quadraticTwist c are in bijection with the point at infinity (0) together with the
solutions of c y² = x³ + a₂ x² + a₄ x + a₆.
For an elliptic curve W in IsCharNeTwoNF form over a finite field and c ≠ 0, the number
of points of W.quadraticTwist c is one (the point at infinity) plus the number of solutions of
c y² = x³ + a₂ x² + a₄ x + a₆.
For a short Weierstrass elliptic curve y² = x³ + a₄ x + a₆ over a finite field and c ≠ 0,
the number of points of W.quadraticTwist c is one (the point at infinity) plus the number of
solutions of c y² = x³ + a₄ x + a₆ ([BS23], Section 15.3.2, p. 623).
Character sums and point counts over finite fields #
For c ≠ 0, twisting the cubic X³ + α X² + β X + γ by c multiplies its character sum
cubicCharSum by quadraticChar F c.
For a quadratic non-residue c, twisting the cubic X³ + α X² + β X + γ by c negates its
character sum cubicCharSum.
For a nonzero square c, twisting the cubic X³ + α X² + β X + γ by c preserves its
character sum cubicCharSum.
For an elliptic curve W in IsCharNeTwoNF form over a finite field,
#E(F) = #F + 1 + cubicCharSum W.a₂ W.a₄ W.a₆.
For an elliptic curve W in IsCharNeTwoNF form over a finite field and c ≠ 0,
#Ẽ(F) = #F + 1 + χ(c) · cubicCharSum W.a₂ W.a₄ W.a₆.
Twisting by a nonzero square preserves the number of points.
Even without nonsingularity (IsElliptic), the affine solution sets of W (in
IsCharNeTwoNF form) and of its quadratic twist by a non-square c have 2 #F points in
total.
Point count of the quadratic twist ([BS23], Section 15.3.2, p. 623). For an
elliptic curve W in IsCharNeTwoNF form over a finite field F and a quadratic non-residue
c : F, #E(F) + #Ẽ(F) = 2 #F + 2.
If #E(F) = q + 1 - t and c is a quadratic non-residue, then #Ẽ(F) = q + 1 + t
([BS23], Section 15.3.2, p. 623).
Over ZMod p, an elliptic curve W in IsCharNeTwoNF form and its quadratic twist by a
quadratic non-residue c satisfy #E(F_p) + #Ẽ(F_p) = 2p + 2 ([BS23], Section 15.3.2,
p. 623).