EIP-1895: Support for an Elliptic Curve Cycle


Metadata
Status: StagnantStandards Track: CoreCreated: 2018-03-31
Authors
Alexandre Belling (alexandrebelling8@gmail.com)

Simple Summary


The EVM currently supports elliptic curves operations for curve alt-bn128 thanks to precompiles ecadd and ecmul and ecpairing. The classes MNT4 and 6 contain cycles of curves. Those cycles enable doing operations on one curve inside a SNARK on the other curve (and reversely). This EIP suggests adding support for those curves.

Abstract


Adds supports for the following operations through precompiles:

  • ecadd on MNT4
  • ecmul on MNT4
  • ecpairing on MNT4

Motivation


Elliptic curve is the basic block of recursive SNARKs (ie: verifying a SNARK inside a SNARK) and this addresses the issue of scalable zero-knowledge. More generally this addresses partly the scalability issue as SNARKs verification are constant time in the size of the circuit being verified.

More concretely, today if the EVM has to deal with 1000s of SNARK verification it would take around 1.5 billion gas and would be impractical for Ethereum. Recursive SNARKs for instance make it possible to aggregate multiple proofs into a single one that can be verified like any other SNARK. It results in a massive cost reduction for the verification.

However, this is impossible using alt-bn128 and in my knowledge, the only family of pairing-friendly curves known to produce cycles are MNT4 and MNT6. A complete characterization of the cycles existing between those two families is proposed in On cycles of pairing-friendly elliptic curves

Specification


The curve

The proposed cycle has been introduced in Scalable Zero Knowledge via Cycles of Elliptic Curves.

MNT4 definition

The groups G_1 and G_2 are cyclic groups of prime order :


G_1 is defined over the field F_p of prime order :


with generator P:


Both p and q can be written in 298 bits.

The group G_1 is defined on the curve defined by the equation Y² = X³ + aX + b where:


The twisted group G_2 is defined over the field F_p^2 = F_p / <<To be completed>>

The twisted group G_2 is defined on the curve defined by the equation Y² = X² + aX + b where :


G_2 generator is generated by :


The operations and gas cost

The following operations and their gas cost would be implemented


Where X is either 4.

Encoding

The curves points P(X, Y) over F_p are represented in their compressed form C(X, Y):


where s represents Y as follow:


Compression operation from affine coordinate is trivial:


In the EVM the compressed form allows us to represents curve points with 2 uint256 instead of 3.

Edge cases

  • Several acceptable representations for the point at infinity

Rationale


The curve has 80 bits of security (whereas MNT6 has 120 bits) which might not be considered enough for critical security level, (for instance transferring several billions), but enough for others. If it turns out this is not enough security for adoption, there is another option : another cycle is being used by Coda but is defined over a 753 bits sized field which might also be prohibitively low (no reference to this curve from Coda's publications found).

Independently of the cycle chosen, the groups and field elements are represented with integers larger than 256 bits (even for the 80 bits of security), therefore it might be necessary to also add support for larger field size operations.

We currently don't know more efficient pairing-friendly cycles and don't know if there are. It might be possible to circumvent this problem though by relaxing the constraint that all the curves of the cycle must be pairing friendly). If we had a cycle with only one pairing friendly curve we would still be able to compose proofs by alternating between SNARKs and any other general purpose zero-knowledge cryptosystems.

Assuming we find a convenient cycle, we don't need to implement support for all the curves it contains, only one. The best choice would be the fastest one as the overall security of the recursive snark do not depends on which curve the verification is made.

Proper benchmarks will be done in order to make this choice and to price the operations in gas.

Test Cases


References


Implementation


  • go-boojum : A PoC demo of an application of recursive SNARKs
  • libff : a C++ library for finite fields and elliptic curves
  • coda : a new cryptocurrency protocol with a lightweight, constant sized blockchain.

Copyright


Copyright and related rights waived via CC0.