Skip to main content
This page is a placeholder. All examples on this page are currently AI-generated and are not correct. This documentation will be completed in the future with accurate, tested examples.

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 map e: G1 × G2 → GT with these properties:
  • Bilinearity: e(aP, bQ) = e(P, Q)^(ab) = e(bP, aQ)
  • Non-degeneracy: e(G1, G2) ≠ 1 for generators G1, G2
  • Computability: Can be efficiently calculated
This enables:
  • 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
Note: Higher base cost than BN254 due to larger field size and higher security level.

Input Format

Input must be a multiple of 384 bytes. Each pair consists of:
Each 384-byte chunk represents one (G1, G2) pair.
  • k pairs = 384 * k bytes
  • Empty input (0 bytes) is valid and returns success (empty product = 1)
Field encoding:
  • 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)
BLS12-381 field modulus p:

Output Format

Total output length: 32 bytes (single word)
  • 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
Failures return error (not false). Only valid inputs that fail the pairing check return false (32 zero bytes).

Use Cases

BLS Signature Verification

BLS signatures use pairing to verify:
Rearranged for single pairing check:

BLS Signature Aggregation

Multiple signatures can be aggregated:
Verify with multi-pairing:
Gas cost scales linearly: 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

BLS12-381 is preferred for new applications due to higher security margin.

Test Vectors

Empty Pairing

Single Pair (Generators)

Identity Check