Skip to content

BN254_PAIRING

Elliptic curve

Optimal ate pairing check on alt_bn128 — the workhorse of most zkSNARK verifiers.

Address0x0000000000000000000000000000000000000008
NameBN254_PAIRING
Minimum gas45,000
Inputa multiple of 192 bytes
Output32 bytes
Available sinceByzantium; repriced at Istanbul (EIP-1108)

Input

g1_x32 B
g1_y32 B
g2_x64 B
g2_y64 B
OffsetLengthFieldDescription
032g1_xX coordinate of the G1 point of pair 1.
3232g1_yY coordinate of the G1 point of pair 1.
6464g2_xX coordinate of the G2 point of pair 1 (Fp2, imaginary part first).
12864g2_yY 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");

Specification

  • EIP-197: Precompiles for optimal ate pairing check on alt_bn128
  • EIP-1108: Reduce alt_bn128 precompile gas costs