EIP-1895 · Stagnant · Core · 2018-03-31
EIP-1895: Support for an Elliptic Curve Cycle
Proposed EVM precompiles for addition, multiplication and pairings on the MNT4 curve, part of a pairing-friendly curve cycle that would let SNARKs verify other SNARKs recursively.
What problem does it solve?
The EVM's elliptic-curve precompiles (EIP-196 add/mul and EIP-197 pairing) only support the alt_bn128 (BN254) curve. That is enough to verify a single zk-SNARK, but verifying thousands of proofs on-chain would be far too expensive.
Recursive SNARKs solve this by proving "I verified these proofs" inside another proof, so many proofs collapse into one. Doing that efficiently needs a cycle of pairing-friendly curves, where each curve's group order matches the other's field size. BN254 has no such partner. The MNT4 and MNT6 families are the known pairing-friendly curves that form cycles, so EIP-1895 proposes adding MNT4 support to the EVM.
How it works
- Three new precompiles:
ecadd,ecmulandecpairingon MNT4, mirroring the existing BN254 set. - The spec lists the curve parameters: prime field
pand group orderqof about 298 bits, the curveY^2 = X^3 + aX + bwitha = 2, generator points for G1 and G2 (G2 over a quadratic extension field). - Points would use a compressed encoding: the X coordinate plus a byte
smarking the point at infinity (0x00) or whether Y is even (0x02) or odd (0x03). - Gas costs were left as "to be estimated" pending benchmarks.
Sample code
How a contract would call such a precompile. The address and input layout below are placeholders, because the spec never assigned them:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract Mnt4Caller {
// Placeholder only: EIP-1895 did not assign a precompile address.
address constant MNT4_ADD = address(0);
function add(bytes calldata p1, bytes calldata p2) external view returns (bytes memory out) {
(bool ok, bytes memory ret) = MNT4_ADD.staticcall(abi.encodePacked(p1, p2));
require(ok, "precompile failed");
return ret;
}
}
Things to know
- Status: Stagnant. The precompiles were never added to Ethereum.
- The spec is incomplete: precompile addresses, input encoding details and gas prices are missing, and part of the G2 field definition is marked "to be completed".
- The author notes the proposed MNT4 curve offers only about 80 bits of security, and that field elements exceed 256 bits.
- A generic approach covering many curves was proposed in EIP-1962. The curve precompiles Ethereum did eventually adopt were for BLS12-381 via EIP-2537.