Overview
Address:0x0000000000000000000000000000000000000011
Introduced: Prague (EIP-2537)
EIP: EIP-2537
The BLS12-381 Pairing precompile performs a pairing check on the BLS12-381 curve. It verifies whether the product of pairings equals identity: e(G1_1, G2_1) * e(G1_2, G2_2) * ... * e(G1_k, G2_k) = 1. This operation is fundamental for BLS signature verification, zkSNARK systems, and advanced cryptographic protocols.
BLS12-381 offers 128-bit security (vs BN254’s ~100 bits), making it the preferred curve for modern applications. It’s used by Ethereum 2.0 for validator signatures.
Pairing-Based Cryptography
A pairing is a bilinear mape: G1 × G2 → GT with these properties:
- Bilinearity:
e(aP, bQ) = e(P, Q)^(ab) = e(bP, aQ) - Non-degeneracy:
e(G1, G2) ≠ 1for generators G1, G2 - Computability: Can be efficiently calculated
- Signature aggregation: Combine multiple signatures into one
- Zero-knowledge proofs: Efficient proof verification
- Identity-based encryption: Encrypt to public identity
Gas Cost
Formula:115000 + 23000 * k where k = number of point pairs
Examples:
- Empty input (k=0): 115,000 gas
- 1 pair: 138,000 gas
- 2 pairs: 161,000 gas
- 5 pairs: 230,000 gas
Input Format
Input must be a multiple of 384 bytes. Each pair consists of:- k pairs = 384 * k bytes
- Empty input (0 bytes) is valid and returns success (empty product = 1)
- G1: Points on E(Fp) where Fp has 381-bit prime modulus
- G2: Points on E’(Fp2) where Fp2 = Fp[u]/(u²+1)
- All coordinates are big-endian, left-padded to 64 bytes
- Point at infinity: all zeros (128 bytes for G1, 256 bytes for G2)
Output Format
- Success:
0x0000...0001(last byte = 1) - Failure:
0x0000...0000(all zeros)
Usage Examples
TypeScript
Zig
Error Conditions
- Out of gas: Gas limit less than required
- Invalid input length: Not multiple of 384 bytes
- Invalid G1 point: Point not on curve or not in correct subgroup
- Invalid G2 point: Point not on curve or not in correct subgroup
- Field element overflow: Coordinate >= field modulus p
- Invalid Fp2 encoding: G2 point coordinates not in Fp2
Use Cases
BLS Signature Verification
BLS signatures use pairing to verify:BLS Signature Aggregation
Multiple signatures can be aggregated:115000 + 23000 * (N+1)
zkSNARK Verification
Pairing enables efficient verification of zero-knowledge proofs:- Groth16 requires multiple pairings
- PLONK uses KZG commitments (pairing-based)
- BLS12-381’s higher security suitable for long-term proofs
Validator Signatures (Ethereum 2.0)
Ethereum 2.0 uses BLS12-381 for:- Block proposal signatures
- Attestation signatures
- Aggregate signatures (efficient verification)
Implementation Details
- Zig: Uses blst library via C FFI for production-grade performance
- TypeScript: Uses @noble/curves BLS12-381 implementation
- Algorithm: Optimal Ate pairing with final exponentiation
- Optimization: Miller loop computed simultaneously for all pairs
- Security: 128-bit security level, suitable for long-term use
Pairing Properties
Bilinearity
Multi-Pairing Optimization
Computing k pairings together is more efficient than k separate calls:- Shared Miller loop computation
- Single final exponentiation
- ~40% gas savings vs individual calls
Empty Pairing
Empty input (0 pairs) returns success because empty product equals 1 (identity element).Comparison: BLS12-381 vs BN254
| Property | BLS12-381 | BN254 |
|---|---|---|
| Security | 128-bit | ~100-bit |
| Field size | 381 bits | 254 bits |
| G1 encoding | 128 bytes | 64 bytes |
| G2 encoding | 256 bytes | 128 bytes |
| Base gas | 115,000 | 45,000 |
| Per-pair gas | 23,000 | 34,000 |
| Use case | Modern (ETH2) | Legacy (zkSNARKs) |

