Documentation

CslibFrontier.Foundations.AlgebraicGeometry.EllipticCurve.QuadraticTwist

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 #

Main results #

Implementation notes and deviations from the source #

References #

The quadratic twist of a Weierstrass curve #

instance WeierstrassCurve.instIsCharNeTwoNFOfCubic {R : Type u_1} [CommRing R] (α β γ : R) :

Every curve ofCubic α β γ (Y² = X³ + α X² + β X + γ) is in IsCharNeTwoNF form (a₁ = 0 and a₃ = 0).

instance WeierstrassCurve.instIsShortNFOfCubicZero {R : Type u_1} [CommRing R] (β γ : R) :
(ofCubic 0 β γ).IsShortNF

Every curve ofCubic 0 β γ (Y² = X³ + β X + γ) is in short Weierstrass normal form (a₁ = a₂ = 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
    @[simp]
    @[simp]
    @[simp]
    @[simp]
    theorem WeierstrassCurve.quadraticTwist_a₄ {R : Type u_1} [CommRing R] (W : WeierstrassCurve R) (c : R) :
    (W.quadraticTwist c).a₄ = c ^ 2 * W.a₄
    @[simp]
    theorem WeierstrassCurve.quadraticTwist_a₆ {R : Type u_1} [CommRing R] (W : WeierstrassCurve R) (c : R) :
    (W.quadraticTwist c).a₆ = c ^ 3 * W.a₆
    theorem WeierstrassCurve.quadraticTwist_Δ {R : Type u_1} [CommRing R] (W : WeierstrassCurve R) [W.IsCharNeTwoNF] (c : R) :
    (W.quadraticTwist c).Δ = c ^ 6 * W.Δ

    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.

    theorem WeierstrassCurve.quadraticTwist_equation_iff {F : Type u_1} [Field F] (W : WeierstrassCurve F) {c : F} (hc : c ≠ 0) (x y : F) :
    (W.quadraticTwist c).toAffine.Equation (c * x) (c ^ 2 * y) ↔ c * y ^ 2 = x ^ 3 + W.a₂ * x ^ 2 + W.a₄ * x + W.a₆

    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₆.

    noncomputable def WeierstrassCurve.quadraticTwistEquationEquiv {F : Type u_1} [Field F] (W : WeierstrassCurve F) {c : F} (hc : c ≠ 0) :
    { xy : F × F // c * xy.2 ^ 2 = xy.1 ^ 3 + W.a₂ * xy.1 ^ 2 + W.a₄ * xy.1 + W.a₆ } ≃ { XY : F × F // (W.quadraticTwist c).toAffine.Equation XY.1 XY.2 }

    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.

    @[simp]
    theorem WeierstrassCurve.quadraticTwistEquationEquiv_apply {F : Type u_1} [Field F] (W : WeierstrassCurve F) {c : F} (hc : c ≠ 0) {x y : F} (h : c * y ^ 2 = x ^ 3 + W.a₂ * x ^ 2 + W.a₄ * x + W.a₆) :
    ↑((W.quadraticTwistEquationEquiv hc) ⟨(x, y), h⟩) = (c * x, c ^ 2 * y)
    @[simp]
    theorem WeierstrassCurve.quadraticTwistEquationEquiv_symm_apply {F : Type u_1} [Field F] (W : WeierstrassCurve F) {c : F} (hc : c ≠ 0) {x y : F} (h : (W.quadraticTwist c).toAffine.Equation x y) :
    noncomputable def WeierstrassCurve.quadraticTwistPointEquiv {F : Type u_1} [Field F] (W : WeierstrassCurve F) [W.IsCharNeTwoNF] [W.IsElliptic] {c : F} (hc : c ≠ 0) :
    (W.quadraticTwist c).toAffine.Point ≃ WithZero { xy : F × F // c * xy.2 ^ 2 = xy.1 ^ 3 + W.a₂ * xy.1 ^ 2 + W.a₄ * xy.1 + W.a₆ }

    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₆.

    theorem WeierstrassCurve.quadraticTwistPointEquiv_symm_coe {F : Type u_1} [Field F] (W : WeierstrassCurve F) [W.IsCharNeTwoNF] [W.IsElliptic] {c : F} (hc : c ≠ 0) {x y : F} (h : c * y ^ 2 = x ^ 3 + W.a₂ * x ^ 2 + W.a₄ * x + W.a₆) (hns : (W.quadraticTwist c).toAffine.Nonsingular (c * x) (c ^ 2 * y)) :
    (W.quadraticTwistPointEquiv hc).symm ↑⟨(x, y), h⟩ = Affine.Point.some (c * x) (c ^ 2 * y) hns
    theorem WeierstrassCurve.natCard_point_quadraticTwist_eq_one_add {F : Type u_1} [Field F] (W : WeierstrassCurve F) [Finite F] [W.IsCharNeTwoNF] [W.IsElliptic] {c : F} (hc : c ≠ 0) :
    Nat.card (W.quadraticTwist c).toAffine.Point = 1 + Nat.card { xy : F × F // c * xy.2 ^ 2 = xy.1 ^ 3 + W.a₂ * xy.1 ^ 2 + W.a₄ * xy.1 + W.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₆.

    theorem WeierstrassCurve.natCard_point_quadraticTwist_eq_one_add_of_isShortNF {F : Type u_1} [Field F] (W : WeierstrassCurve F) [Finite F] [W.IsShortNF] [W.IsElliptic] {c : F} (hc : c ≠ 0) :
    Nat.card (W.quadraticTwist c).toAffine.Point = 1 + Nat.card { xy : F × F // c * xy.2 ^ 2 = xy.1 ^ 3 + W.a₄ * xy.1 + W.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 #

    theorem WeierstrassCurve.cubicCharSum_mul {F : Type u_1} [Field F] [Fintype F] [DecidableEq F] (α β γ : F) {c : F} (hc : c ≠ 0) :
    cubicCharSum (c * α) (c ^ 2 * β) (c ^ 3 * γ) = (quadraticChar F) c * cubicCharSum α β γ

    For c ≠ 0, twisting the cubic X³ + α X² + β X + γ by c multiplies its character sum cubicCharSum by quadraticChar F c.

    theorem WeierstrassCurve.cubicCharSum_mul_of_not_isSquare {F : Type u_1} [Field F] [Fintype F] [DecidableEq F] (α β γ : F) {c : F} (hc : ¬IsSquare c) :
    cubicCharSum (c * α) (c ^ 2 * β) (c ^ 3 * γ) = -cubicCharSum α β γ

    For a quadratic non-residue c, twisting the cubic X³ + α X² + β X + γ by c negates its character sum cubicCharSum.

    theorem WeierstrassCurve.cubicCharSum_mul_of_isSquare {F : Type u_1} [Field F] [Fintype F] [DecidableEq F] (α β γ : F) {c : F} (hc : IsSquare c) (hc0 : c ≠ 0) :
    cubicCharSum (c * α) (c ^ 2 * β) (c ^ 3 * γ) = 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).