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:0x0000000000000000000000000000000000000006Introduced: Byzantium (EIP-196)
EIP:EIP-196, EIP-1108The 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
Offset | Length | Description-------|--------|-------------0 | 32 | x1 (first point x-coordinate, big-endian)32 | 32 | y1 (first point y-coordinate, big-endian)64 | 32 | x2 (second point x-coordinate, big-endian)96 | 32 | y2 (second point y-coordinate, big-endian)
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
Offset | Length | Description-------|--------|-------------0 | 32 | x (result point x-coordinate, big-endian)32 | 32 | y (result point y-coordinate, big-endian)
Total output length: 64 bytes
Usage Example
import { execute, PrecompileAddress } from '@tevm/voltaire/precompiles';import { Hardfork } from '@tevm/voltaire/primitives/Hardfork';// Add two G1 points on BN254 curve// Point 1: Generator (1, 2)const x1 = Bytes32('0x0000000000000000000000000000000000000000000000000000000000000001');const y1 = Bytes32('0x0000000000000000000000000000000000000000000000000000000000000002');// Point 2: Generator (1, 2) - will compute 2*Gconst x2 = Bytes32('0x0000000000000000000000000000000000000000000000000000000000000001');const y2 = Bytes32('0x0000000000000000000000000000000000000000000000000000000000000002');const input = new Uint8Array(128);input.set(x1, 0);input.set(y1, 32);input.set(x2, 64);input.set(y2, 96);const result = execute( PrecompileAddress.BN254_ADD, input, 1000n, Hardfork.CANCUN);if (result.success) { const resultX = result.output.slice(0, 32); const resultY = result.output.slice(32, 64); console.log('Result point:', { x: resultX, y: resultY }); console.log('Gas used:', result.gasUsed); // 150} else { console.error('Error:', result.error);}
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