EIP-2537 · Final · Core · 2020-02-21
EIP-2537: Precompile for BLS12-381 curve operations
Seven precompiles for the BLS12-381 pairing curve, giving the EVM cheap, ~128-bit-secure BLS signature verification and zk-proof operations.
What problem does it solve?
The EVM has had pairing-friendly curve precompiles since 2017, but only for BN254 (EIP-196, EIP-197), whose security is now estimated at roughly 80 bits. Meanwhile Ethereum's consensus layer signs everything with BLS signatures on BLS12-381, a curve with 120+ bits of security. Without a precompile, verifying those signatures or BLS12-381 zk proofs in a contract is far too expensive.
EIP-2537 adds native BLS12-381 operations so contracts can verify validator signatures, aggregate public keys and check pairing-based proofs at a reasonable gas cost.
How it works
Seven precompiles are added:
| Address | Name | Gas |
|---|---|---|
0x0b |
BLS12_G1ADD |
375 |
0x0c |
BLS12_G1MSM |
discounted, per pair |
0x0d |
BLS12_G2ADD |
600 |
0x0e |
BLS12_G2MSM |
discounted, per pair |
0x0f |
BLS12_PAIRING_CHECK |
32600 * k + 37700 |
0x10 |
BLS12_MAP_FP_TO_G1 |
5500 |
0x11 |
BLS12_MAP_FP2_TO_G2 |
23800 |
Encoding
- A base field element is 64 bytes big-endian (the top 16 bytes must be zero, and the value must be below the modulus).
- An Fp2 element is two of those: 128 bytes.
- A G1 point is 128 bytes (
x || y); a G2 point is 256 bytes. All-zero bytes encode the point at infinity. - Scalars are 32 bytes and need not be reduced.
Operations
- MSM (multi-scalar multiplication) takes
k(point, scalar) pairs and returnsΣ sᵢ·Pᵢ. It replaces separate "multiply" precompiles; a single multiplication is an MSM withk = 1. Gas uses a per-kdiscount table, so batching is cheaper per pair. - Pairing check takes
k(G1, G2) pairs and returns 32 bytes ending in0x01ife(P1,Q1)·…·e(Pk,Qk) == 1, else0x00. - Map to curve turns a field element into a curve point. Hashing a message to a field element is left to the caller.
MSM and pairing inputs are subgroup-checked; the ADD precompiles are not. Any error (bad length, invalid encoding, point off the curve) burns all gas passed to the call. Empty inputs are an error.
Sample code
Calling the pairing precompile from Solidity, e.g. to verify a BLS signature as e(pk, H(m)) · e(-G1, sig) == 1:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
library BLS12 {
address constant PAIRING = address(0x0f);
/// @param input concatenation of k slices: 128-byte G1 point || 256-byte G2 point
function pairingCheck(bytes memory input) internal view returns (bool) {
require(input.length > 0 && input.length % 384 == 0, "bad length");
(bool ok, bytes memory out) = PAIRING.staticcall(input);
require(ok, "pairing precompile failed");
return out.length == 32 && uint8(out[31]) == 1;
}
}
Things to know
- Status is Final. The precompiles went live on mainnet with the Pectra upgrade.
- The spec does not include hash-to-field. To verify standard BLS signatures you must implement the hash-to-field step yourself (typically following the IETF hash-to-curve construction) before calling the map precompile.
- Because ADD precompiles skip subgroup checks, do not treat their output as validated input. MSM and pairing do check.
- Keep the BN254 precompiles for existing proof systems; BLS12-381 is preferred for new designs that need higher security or compatibility with consensus-layer signatures.