LogoLogo
LogoLogo
  • Introduction
    • About Us
    • Notations & Definitions
      • MPC
      • ZK
    • Contribute to this Site!
  • Primitives
    • Multiplication
      • Karatsuba Multiplication
      • Toom-Cook Multiplication
    • NAF (Non-adjacent form)
    • Chinese Remainder Theorem (CRT)
    • Euclidean Algorithm
      • Extended Euclidean Algorithm
      • Binary Euclidean Algorithm
      • Extended Binary Euclidean Algorithm
    • Coding Theory
      • Linear Code
    • Number Theoretic Transform
    • Abstract Algebra
      • Group
        • -Morphisms
        • Batch Inverse
      • Elliptic Curve
        • Weierstrass Curve
          • Coordinate Forms
          • Fast Elliptic Curve Arithmetic and Improved WEIL Pairing Evaluation
        • Edwards Curve
          • Coordinate Forms
          • Twisted Edwards ↔ Short Weierstrass Transformation
        • Batch Inverse for Batch Point Additions
        • Scalar Multiplication
          • Double-and-add
          • GLV Decomposition
        • MSM
          • Pippenger's Algorithm
          • Signed Bucket Index
          • CycloneMSM
          • EdMSM
          • cuZK
        • 2-Chain and 2-Cycle of Elliptic Curves
    • Encryption Scheme
      • ElGamal Encryption
    • Modular Arithmetic
      • Modular Reduction
        • Barrett Reduction
        • Montgomery Reduction
      • Modular Inverse
        • Bernstein-Yang's Inverse
    • Multiset Check
    • Sumcheck
    • Commitment Scheme
      • Fflonk
      • SHPlonk
      • Zeromorph
  • MPC
    • Yao's Garbled Circuits
    • GMW
    • BMR
  • ZK
    • Arithmetization
      • R1CS
      • PLONK
      • AIR
    • Folding
      • LatticeFold
      • Nova
        • Nova over Cycles of Curves
    • Lookup
      • Lasso
      • LogUp-GKR
    • SNARK
      • Groth16
      • HyperPlonk
      • Spartan
        • SPARK
    • STARK
      • Additive NTT
      • Basefold
      • Binius
      • Brakedown
      • CircleSTARK
      • FRI
        • FRI Security Features and Optimizations
      • DEEP FRI
      • STIR
      • WHIR
    • Distributed ZK
      • Ryan's Trick for Distributed Groth16
  • Application
    • zkLogin
    • zkHoldem
    • zkTLS
      • DECO
      • Proxying is enough
  • zkVM
Powered by GitBook
On this page
  • Motivation
  • Algorithm
  • Conclusion
Export as PDF
  1. Primitives
  2. Abstract Algebra
  3. Elliptic Curve
  4. Weierstrass Curve

Fast Elliptic Curve Arithmetic and Improved WEIL Pairing Evaluation

PreviousCoordinate FormsNextEdwards Curve

Last updated 1 month ago

This explains .

Motivation

Compute 2P+Q2P + Q2P+Q without the intermediate results 2P2P2P and P+QP + QP+Q given E:y2=x3+a⋅x+bE: y^2 = x^3 + a \cdot x + bE:y2=x3+a⋅x+b, where 4a3+27b2≠04a^3 + 27b^2 \ne 04a3+27b2=0,

  • 2P2P2P: 1 multiplication, 2 squarings and 1 division. If P=(x1,y1)P = (x_1, y_1)P=(x1​,y1​), R=2P=(x2,y2)R = 2P = (x_2, y_2)R=2P=(x2​,y2​) is computed as follows:

λ=3x12+a2y1x2=λ2−2x1y2=(x1−x2)λ−y1\lambda = \frac{3 {x_1}^2 + a}{2 y_1} \\x_2 = \lambda^2 - 2x_1 \\ y_2 = (x_1 - x_2) \lambda - y_1λ=2y1​3x1​2+a​x2​=λ2−2x1​y2​=(x1​−x2​)λ−y1​
  • P+QP + QP+Q: 1 multiplication, 1 squaring and 1 division. If P=(x1,y1)P = (x_1, y_1)P=(x1​,y1​) and Q=(x2,y2)Q = (x_2, y_2)Q=(x2​,y2​), R=P+Q=(x3,y3)R = P + Q = (x_3, y_3)R=P+Q=(x3​,y3​) is computed as follows:

λ1=(y2−y1)/(x2−x1),x3=λ12−x1−x2,y3=(x1−x3)λ1−y1\lambda_1 = (y_2 - y_1) / (x_2 - x_1),\\ x_3 = {\lambda_1}^2 - x_1 -x_2, \\ y_3 = (x_1 - x_3)\lambda_1 - y_1λ1​=(y2​−y1​)/(x2​−x1​),x3​=λ1​2−x1​−x2​,y3​=(x1​−x3​)λ1​−y1​
  • Naive 2P+Q2P + Q2P+Q: 2 multiplications, 3 squarings and 2 divisions

How can we improve this?

Algorithm

Suppose P=(x1,y1)P = (x_1, y_1)P=(x1​,y1​) and Q=(x2,y2)Q = (x_2, y_2)Q=(x2​,y2​) are distinct points on EEE, with x1≠x2x_1 \ne x_2x1​=x2​. The sum P+QP + QP+Q has coordinates (x3,y3)(x_3, y_3)(x3​,y3​), where:

λ1=(y2−y1)/(x2−x1),x3=λ12−x1−x2,y3=(x1−x3)λ1−y1\lambda_1 = (y_2 - y_1) / (x_2 - x_1),\\ x_3 = {\lambda_1}^2 - x_1 -x_2, \\ y_3 = (x_1 - x_3)\lambda_1 - y_1λ1​=(y2​−y1​)/(x2​−x1​),x3​=λ1​2−x1​−x2​,y3​=(x1​−x3​)λ1​−y1​

Now suppose we want to add (P+Q)(P + Q)(P+Q) to PPP. To do this, we add (x1,y1)(x_1, y_1)(x1​,y1​) to (x3,y3)(x_3, y_3)(x3​,y3​) using the same addition rule. Assuming x3≠x1x_3 \ne x_1x3​=x1​, the resulting coordinates are (x4,y4)(x_4, y_4)(x4​,y4​), where

λ2=(y3−y1)/(x3−x1),x4=λ22−x1−x3,y4=(x1−x4)λ2−y1\lambda_2 = (y_3 - y_1) / (x_ 3 - x_1), \\ x_4 = {\lambda_2}^2 - x_1 - x_3, \\ y_4 = (x_1 - x_4)\lambda_2 - y_1λ2​=(y3​−y1​)/(x3​−x1​),x4​=λ2​2−x1​−x3​,y4​=(x1​−x4​)λ2​−y1​

We can omit the explicit computation of y3y_3y3​ since it is used only to calculate λ2\lambda_2λ2​. Instead, λ2\lambda_2λ2​ can be computed directly as:

λ2=(y3−y1)/(x3−x1)=((x1−x3)λ1−2y1)/(x3−x1)=−λ1−2y1/(x3−x1)\begin{align*} \lambda_2 &= (y_3 - y_1) / (x_3 - x_1)\\ &= ((x_1 - x_3) \lambda_1 - 2y_1) / (x_3 - x_1) \\ &= -\lambda_1 - 2y_1 / (x_3 - x_1) \\ \end{align*}λ2​​=(y3​−y1​)/(x3​−x1​)=((x1​−x3​)λ1​−2y1​)/(x3​−x1​)=−λ1​−2y1​/(x3​−x1​)​

Which means you can compute λ2\lambda_2λ2​ using x1,y1x_1, y_1x1​,y1​ and λ1\lambda_1λ1​.

λ2=−λ1−2y1/(λ12−x2−2x1)\lambda_2 = -\lambda_1 - 2y_1 / ({\lambda_1}^2 -x_2 - 2x_1)λ2​=−λ1​−2y1​/(λ1​2−x2​−2x1​)

Additionally, you can compute x4x_4x4​ using x2,λ1x_2, \lambda_1x2​,λ1​ and λ2\lambda_2λ2​.

x3=λ12−x1−x2x3−x4=λ12−x1−x2−(λ22−x1−x3)−x4=λ12−x2−λ22x4=x2+λ22−λ12\begin{align*} x_3 &= {\lambda_1}^2 - x_1 - x_2 \\ x_3 - x_4 &= {\lambda_1}^2 - x_1 - x_2 -( {\lambda_2}^2 - x_1 - x_3 ) \\ -x_4 &={\lambda_1}^2 - x_2 - \lambda_2^2 \\ x_4 &= x_2 + {\lambda_2}^2 - {\lambda_1}^2 \end{align*}x3​x3​−x4​−x4​x4​​=λ1​2−x1​−x2​=λ1​2−x1​−x2​−(λ2​2−x1​−x3​)=λ1​2−x2​−λ22​=x2​+λ2​2−λ1​2​

This trick can also be applied when computing 3P3P3P. Thus, 3P+Q=((P+Q)+P)+P3P + Q = ((P + Q) + P) + P3P+Q=((P+Q)+P)+P saves 2 multiplicaitons.

Conclusion

The cost of this algorithm is as follows:

  • Optimized 2P+Q2P + Q2P+Q: 1 multiplication, 2 squarings and 2 divisions (+ 1 squaring when P=QP = QP=Q)

    • Idea: (P+Q)+P(P + Q) +P(P+Q)+P instead of 2P+Q2P + Q2P+Q and yyy-coordinate is not computed when computing (P+Q)(P + Q)(P+Q) ⇒ This saves a field multiplication

    • if P=QP = QP=Q

      • 2 * (1 multiplication, 2 squarings and 1 division) - 1 multiplication

    • otherwise

      • 2 * (1 multiplication, 1 squaring and 1 division) - 1 multiplication

Written by from

https://arxiv.org/abs/math/0208038
A41
ryan Kim