ERC-2494 Baby Jubjub elliptic curve

Stagnant · Other · created 2020-01-29

Defines a dedicated elliptic curve usable inside zk-SNARK proof circuits, allowing curve-based cryptographic operations such as signatures (EdDSA) or hashing (Pedersen Hash) to be implemented inside the circuit.

Why it is needed

The curve Ethereum uses to verify zk-SNARK proofs is alt_bn128 (BN254). This curve can be used to verify the computation results of F_r arithmetic circuits, but performing elliptic curve operations themselves inside the circuit requires another curve whose coordinates lie over F_r. Without such a curve, logic that uses elliptic curve cryptography, such as proof of private key ownership, signature verification, or hash preimage proofs, cannot be placed inside a zero-knowledge circuit. As a result, applications that prove signatures or hashes while preserving privacy, such as zk-Rollup projects, become hard to implement, and if each team arbitrarily picks a different curve, transparency of the generation process and interoperability between implementations also become hard to guarantee.

In depth

Curve definition and parameters

Baby Jubjub is a curve defined by the twisted Edwards equation ax^2+y^2=1+dx^2y^2 (a=168700, d=168696) over the finite field F_r, where r is the prime r = 21888242871839275222246405745257275088548364400416034343698204186575808495617. This r equals the order of the alt_bn128 curve that Ethereum uses for zk-SNARK verification, which is why Baby Jubjub operations can be used directly inside circuits verified with alt_bn128.

Curve order and cofactor

The order of Baby Jubjub factors as n = h x l. The cofactor h is 8, and l is the 251-bit prime 2736030358979909402780800718157159386076813972158567259200215660948447373041.

Generator point and base point

The generator point G=(x,y) generates all n points of the curve. The base point B=(x,y) satisfies l*P=O, meaning it generates the subgroup of prime order l. The coordinates of both points are given explicitly, and it is safer to use B, which has prime order, for actual cryptographic operations.

Point addition formula

The sum P1+P2=(x3,y3) of two points P1=(x1,y1) and P2=(x2,y2) is computed as x3=(x1y2+y1x2)/(1+dx1x2y1y2), y3=(y1y2-ax1x2)/(1-dx1x2y1y2). Twisted Edwards curves can handle addition and doubling with a single unified formula, making them efficient to implement inside a circuit without conditional branching.

Why the twisted Edwards form was chosen

EdDSA is based on twisted Edwards curves, and this form has a complete single formula for addition, making circuit implementation efficient. It is also birationally equivalent to a Montgomery curve, enabling a combination where computation outside the circuit is done in the faster Montgomery form and converted to the twisted Edwards form inside the circuit.

Transparent and deterministic generation process

To reduce the possibility of a backdoor, the curve was generated using a deterministic algorithm based on RFC7748 Appendix A.1. Taking r as input, a Montgomery curve with cofactor 8 (A=168698) was first derived, then converted into twisted Edwards form. The generator point G was chosen as the point of order n with the smallest positive x-coordinate in F_r, and the base point B was chosen as 8 times that point (B=8G).

Three curve representations and conversion formulas

Baby Jubjub is expressed in three forms: the standard twisted Edwards form, the Montgomery form (By^2=x^3+Ax^2+x, A=168698, B=1), and the reduced twisted Edwards form (a'=-1, with d' given explicitly), with conversion formulas between them all provided using a scale factor f. This allows different implementations to convert point coordinates consistently and remain interoperable.

Proposal status

This EIP is in Stagnant status, meaning it is no longer actively discussed or has halted. It should be referenced with the understanding that its content may change or discussion may resume.

Things to watch out for

Original ERC · ← ERCs