Documentation

CslibFrontier.Foundations.AlgebraicGeometry.EllipticCurve.Edwards

Edwards curves and their unified addition law #

An Edwards curve over a commutative ring R is given by the affine equation x² + y² = 1 + d x² y² with d ≠ 0 and d ≠ 1 ([BS23], Section 15.2.1, p. 619). Unlike Weierstrass form, the unified Edwards addition formula (x₁, y₁) + (x₂, y₂) = ((x₁ y₂ + x₂ y₁) / (1 + d x₁ x₂ y₁ y₂), (y₁ y₂ - x₁ x₂) / (1 - d x₁ x₂ y₁ y₂)) requires no case split for doubling or adding the identity (0, 1), and the inverse of (x, y) is (-x, y).

Over any field F, when d is a non-square (¬ IsSquare E.d), the addition denominators never vanish (EdwardsCurve.denom_ne_zero), making EdwardsCurve.add total on E.Point with identity (0, 1), negation (-x, y), commutativity, and inverse cancellation. Associativity and the equivalence with Montgomery and Weierstrass models are left to follow-up modules.

Main definitions #

Main results #

Implementation notes and deviations from the source #

References #

structure EdwardsCurve (R : Type u_1) [CommRing R] :
Type u_1

An Edwards curve x² + y² = 1 + d x² y² over a commutative ring R, with d ≠ 0 and d ≠ 1 ([BS23], Section 15.2.1, p. 619).

  • d : R

    The curve parameter d in x² + y² = 1 + d x² y².

  • d_ne_zero : self.d ≠ 0

    Non-degeneracy condition d ≠ 0.

  • d_ne_one : self.d ≠ 1

    Non-degeneracy condition d ≠ 1.

def EdwardsCurve.Equation {R : Type u_1} [CommRing R] (E : EdwardsCurve R) (x y : R) :

The affine equation x² + y² = 1 + d x² y² defining E.

Instances For
    @[instance_reducible]

    Decidability of E.Equation x y when equality in R is decidable.

    structure EdwardsCurve.Point {R : Type u_1} [CommRing R] (E : EdwardsCurve R) :
    Type u_1

    An affine point on the Edwards curve E.

    • x : R

      The x-coordinate of the point.

    • y : R

      The y-coordinate of the point.

    • eq : E.Equation self.x self.y

      Witness that (x, y) satisfies E.Equation.

    theorem EdwardsCurve.Point.ext {R : Type u_1} {inst✝ : CommRing R} {E : EdwardsCurve R} {x y : E.Point} :
    x.x = y.x → x.y = y.y → x = y
    theorem EdwardsCurve.Point.ext_iff {R : Type u_1} {inst✝ : CommRing R} {E : EdwardsCurve R} {x y : E.Point} :
    x = y ↔ x.x = y.x ∧ x.y = y.y
    def EdwardsCurve.instDecidableEqPoint.decEq {R✝ : Type u_2} {inst✝ : CommRing R✝} {E✝ : EdwardsCurve R✝} [DecidableEq R✝] (x✝ x✝¹ : E✝.Point) :
    Decidable (x✝ = x✝¹)
    @[instance_reducible]
    instance EdwardsCurve.instDecidableEqPoint {R✝ : Type u_2} {inst✝ : CommRing R✝} {E✝ : EdwardsCurve R✝} [DecidableEq R✝] :
    def EdwardsCurve.zero {R : Type u_1} [CommRing R] (E : EdwardsCurve R) :

    The identity point (0, 1) on E.

    @[simp]
    theorem EdwardsCurve.zero_x {R : Type u_1} [CommRing R] (E : EdwardsCurve R) :
    E.zero.x = 0

    The x-coordinate of E.zero is 0.

    @[simp]
    theorem EdwardsCurve.zero_y {R : Type u_1} [CommRing R] (E : EdwardsCurve R) :
    E.zero.y = 1

    The y-coordinate of E.zero is 1.

    def EdwardsCurve.neg {R : Type u_1} [CommRing R] (E : EdwardsCurve R) (P : E.Point) :

    The Edwards negation (x, y) ↦ (-x, y).

    @[simp]
    theorem EdwardsCurve.neg_x {R : Type u_1} [CommRing R] (E : EdwardsCurve R) (P : E.Point) :
    (E.neg P).x = -P.x

    The x-coordinate of E.neg P is -P.x.

    @[simp]
    theorem EdwardsCurve.neg_y {R : Type u_1} [CommRing R] (E : EdwardsCurve R) (P : E.Point) :
    (E.neg P).y = P.y

    The y-coordinate of E.neg P is P.y.

    @[simp]
    theorem EdwardsCurve.neg_neg {R : Type u_1} [CommRing R] (E : EdwardsCurve R) (P : E.Point) :
    E.neg (E.neg P) = P

    Negation is involutive on E.Point.

    The point (1, 0) on E (which has order four when (2 : F) ≠ 0).

    @[simp]

    The x-coordinate of E.order4Point is 1.

    @[simp]

    The y-coordinate of E.order4Point is 0.

    theorem EdwardsCurve.one_sub_d_ne_zero {R : Type u_1} [CommRing R] (E : EdwardsCurve R) :
    1 - E.d ≠ 0

    1 - E.d ≠ 0 follows from E.d ≠ 1.

    theorem EdwardsCurve.equation_add {F : Type u_1} [Field F] (E : EdwardsCurve F) {x₁ y₁ x₂ y₂ : F} (h₁ : E.Equation x₁ y₁) (h₂ : E.Equation x₂ y₂) (hplus : 1 + E.d * x₁ * x₂ * y₁ * y₂ ≠ 0) (hminus : 1 - E.d * x₁ * x₂ * y₁ * y₂ ≠ 0) :
    E.Equation ((x₁ * y₂ + x₂ * y₁) / (1 + E.d * x₁ * x₂ * y₁ * y₂)) ((y₁ * y₂ - x₁ * x₂) / (1 - E.d * x₁ * x₂ * y₁ * y₂))

    The unified Edwards addition formula preserves E.Equation whenever both denominators are nonzero.

    theorem EdwardsCurve.mul_xy_eq_zero_of_two_eq_zero {F : Type u_1} [Field F] (E : EdwardsCurve F) (h2 : 2 = 0) (hd : ¬IsSquare E.d) (R : E.Point) :
    R.x * R.y = 0

    In characteristic two, a non-square parameter forces R.x * R.y = 0 for every point R.

    theorem EdwardsCurve.denom_ne_zero {F : Type u_1} [Field F] (E : EdwardsCurve F) (hd : ¬IsSquare E.d) (P Q : E.Point) :
    1 + E.d * P.x * Q.x * P.y * Q.y ≠ 0 ∧ 1 - E.d * P.x * Q.x * P.y * Q.y ≠ 0

    For non-square E.d, both denominators 1 ± E.d * P.x * Q.x * P.y * Q.y in the unified Edwards addition formula are nonzero over any field F.

    def EdwardsCurve.add {F : Type u_1} [Field F] (E : EdwardsCurve F) (hd : ¬IsSquare E.d) (P Q : E.Point) :

    The unified Edwards addition law P ⊞ Q on E.Point when ¬ IsSquare E.d.

    @[simp]
    theorem EdwardsCurve.add_x {F : Type u_1} [Field F] (E : EdwardsCurve F) (hd : ¬IsSquare E.d) (P Q : E.Point) :
    (E.add hd P Q).x = (P.x * Q.y + Q.x * P.y) / (1 + E.d * P.x * Q.x * P.y * Q.y)

    The x-coordinate of E.add hd P Q.

    @[simp]
    theorem EdwardsCurve.add_y {F : Type u_1} [Field F] (E : EdwardsCurve F) (hd : ¬IsSquare E.d) (P Q : E.Point) :
    (E.add hd P Q).y = (P.y * Q.y - P.x * Q.x) / (1 - E.d * P.x * Q.x * P.y * Q.y)

    The y-coordinate of E.add hd P Q.

    theorem EdwardsCurve.zero_add {F : Type u_1} [Field F] (E : EdwardsCurve F) (hd : ¬IsSquare E.d) (P : E.Point) :
    E.add hd E.zero P = P

    Left identity for E.add.

    theorem EdwardsCurve.add_zero {F : Type u_1} [Field F] (E : EdwardsCurve F) (hd : ¬IsSquare E.d) (P : E.Point) :
    E.add hd P E.zero = P

    Right identity for E.add.

    theorem EdwardsCurve.add_comm {F : Type u_1} [Field F] (E : EdwardsCurve F) (hd : ¬IsSquare E.d) (P Q : E.Point) :
    E.add hd P Q = E.add hd Q P

    Commutativity of E.add.

    theorem EdwardsCurve.neg_add_cancel {F : Type u_1} [Field F] (E : EdwardsCurve F) (hd : ¬IsSquare E.d) (P : E.Point) :
    E.add hd (E.neg P) P = E.zero

    Left inverse cancellation for E.add.