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: 0x0000000000000000000000000000000000000006 Introduced: Byzantium (EIP-196) EIP: EIP-196, EIP-1108 The BN254 Add precompile performs elliptic curve point addition on the BN254 (alt_bn128) curve. It takes two G1 points and returns their sum. This is essential for zkSNARK verification and other zero-knowledge proof systems. EIP-196 introduced BN254 operations in Byzantium. EIP-1108 (Istanbul) reduced gas costs by 91% to enable practical zkSNARK verification. The BN254 curve is defined over a 254-bit prime field and is widely used in Zcash, Ethereum’s zkSNARKs (Groth16), and other privacy protocols.

Gas Cost

Fixed: 150 gas (reduced from 500 in Istanbul via EIP-1108)

Input Format

Total input length: 128 bytes (padded/truncated to this size) Points must satisfy the curve equation: y^2 = x^3 + 3 over the BN254 field. Point at infinity is represented as (0, 0).

Output Format

Total output length: 64 bytes

Usage Example

Error Conditions

  • Out of gas (gasLimit < 150)
  • Point not on curve (x, y don’t satisfy y^2 = x^3 + 3)
  • Coordinate >= field modulus (p = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47)
Invalid points cause the precompile to fail, returning error.

Use Cases

  • zkSNARK verification: Groth16 proof verification requires G1 point operations
  • Rollup verification: zk-Rollups use BN254 for proof aggregation
  • Privacy protocols: Zcash-style shielded transactions
  • Zero-knowledge applications: zkEVMs, private DeFi, anonymous voting
  • Cryptographic commitments: Pedersen commitments on BN254

Implementation Details

  • Zig: Pure Zig implementation using arkworks-rs for point arithmetic
  • TypeScript: Wraps BN254 crypto module (arkworks bindings)
  • Integration: Part of BN254 crypto suite (add, mul, pairing)
  • Curve: BN254 (alt_bn128) with embedding degree 12
  • Field modulus: 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47

BN254 Curve Parameters

  • Curve equation: y² = x³ + 3
  • Field modulus (p): 21888242871839275222246405745257275088696311157297823662689037894645226208583
  • Group order (r): 21888242871839275222246405745257275088548364400416034343698204186575808495617
  • Generator G1: (1, 2)
  • Point at infinity: (0, 0) by convention

Point Addition Rules

  • P + O = P (identity element)
  • P + P = 2P (point doubling)
  • P + (-P) = O (inverse)
  • General addition uses elliptic curve addition formula

Test Vectors

Gas Cost History

HardforkGas CostChange
Byzantium500Initial
Istanbul (EIP-1108)150-70%

References

Specifications