EIP-2539 · Stagnant · Core · 2020-02-26
EIP-2539: BLS12-377 curve operations
A stagnant proposal for nine precompiles performing arithmetic and pairings on the BLS12-377 curve, aimed at cheap BLS signature checks and recursive SNARK verification.
What problem does it solve?
Ethereum's original pairing precompiles (EIP-196, EIP-197) work on the BN254 curve, whose security the spec puts at roughly 80 bits. Protocols that want stronger, modern pairing-friendly curves had to implement them in Solidity, which is far too expensive.
BLS12-377 (from the Zexe paper) offers 120+ bits of security and has a special property: pairings over it can be checked efficiently inside another SNARK. That makes it attractive for one-step recursive proof aggregation and for verifying BLS signatures produced by systems built on this curve.
How it works
The proposal adds nine precompiles at proposed addresses 0x15–0x1d:
| Precompile | Operation |
|---|---|
G1ADD, G1MUL, G1MULTIEXP |
Add, scalar-multiply, multi-scalar-multiply points in G1 |
G2ADD, G2MUL, G2MULTIEXP |
Same operations in G2 (over Fp2) |
PAIRING |
Check whether the product of pairings of k (G1, G2) pairs is 1 |
MAP_FP_TO_G1, MAP_FP2_TO_G2 |
Map a field element to a curve point (for hash-to-curve) |
Encoding follows the same pattern as the BLS12-381 precompile proposal:
- A base-field element is 64 bytes, big-endian, with the top 16 bytes zero (keeps 32-byte ABI alignment). An Fp2 element is two of these (128 bytes).
- A G1 point is 128 bytes (
x || y), a G2 point 256 bytes.(0, 0)encodes the point at infinity. - Scalars are 32 bytes and need not be reduced modulo the group order.
- Pairing input is
kslices of 384 bytes; output is 32 bytes ending in0x01(true) or0x00. Subgroup checks are mandatory for pairing inputs.
Proposed gas: G1ADD 600, G1MUL 12000, G2ADD 4500, G2MUL 55000, pairing 55000*k + 65000, map-to-G1 5500, map-to-G2 75000. Multi-exponentiation gets a discount table for larger k. Any error must consume all gas supplied to the call.
Sample code
Calling the proposed G1 addition precompile from Solidity (illustrative: the address is only proposed and is not active on mainnet):
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
library BLS12377 {
address constant G1ADD = address(0x15); // proposed, not deployed
// p and q are 128-byte encoded G1 points (x||y, each 64 bytes big-endian)
function g1Add(bytes memory p, bytes memory q) internal view returns (bytes memory out) {
require(p.length == 128 && q.length == 128, "bad length");
(bool ok, bytes memory res) = G1ADD.staticcall(bytes.concat(p, q));
require(ok && res.length == 128, "G1ADD failed");
return res;
}
}
Things to know
- Status: Stagnant. It has not been scheduled for any network upgrade.
- The related BLS12-381 precompiles of EIP-2537 are the ones that were adopted on Ethereum (in the Pectra upgrade). If you need BLS on mainnet, that is the curve available.
- The spec explicitly does not require constant-time implementations.
- It builds on EIP-1109 (cheaper precompile calls) and EIP-2046 (reduced STATICCALL cost to precompiles), both of which it lists as requirements and both of which are themselves stagnant.