BN254_PAIRING
Elliptic curve
Optimal ate pairing check on alt_bn128 — the workhorse of most zkSNARK verifiers.
| Address | 0x0000000000000000000000000000000000000008 |
|---|---|
| Name | BN254_PAIRING |
| Minimum gas | 45,000 |
| Input | a multiple of 192 bytes |
| Output | 32 bytes |
| Available since | Byzantium; repriced at Istanbul (EIP-1108) |
Input
g1_x32 B
g1_y32 B
g2_x64 B
g2_y64 B
| Offset | Length | Field | Description |
|---|---|---|---|
| 0 | 32 | g1_x | X coordinate of the G1 point of pair 1. |
| 32 | 32 | g1_y | Y coordinate of the G1 point of pair 1. |
| 64 | 64 | g2_x | X coordinate of the G2 point of pair 1 (Fp2, imaginary part first). |
| 128 | 64 | g2_y | Y coordinate of the G2 point of pair 1 (Fp2, imaginary part first). |
Output
A 32-byte word: 1 if the pairing product equals one, 0 otherwise.
Gas
45000 + 34000 × (len(input) / 192)
Failure behaviour
- Reverts if the input length is not a multiple of 192, or if any point is not on its curve or not in the correct subgroup.
- Empty input is valid and returns 1.
Calling it
Precompiles have no ABI and no function selector: the input is raw bytes at the exact offsets above. Call with staticcall.
// BN254_PAIRING at 0x08(bool ok, bytes memory out) = address(0x08).staticcall(input);require(ok, "BN254_PAIRING reverted");