Overview
Address:0x0000000000000000000000000000000000000007
Introduced: Byzantium (EIP-196)
EIP: EIP-196, EIP-1108
The BN254 Mul precompile performs scalar multiplication on the BN254 (alt_bn128) curve. It multiplies a G1 point by a scalar, computing scalar * point. This operation is crucial for zkSNARK verification and cryptographic protocols.
EIP-1108 (Istanbul) reduced gas costs by 99% compared to Byzantium, making zkSNARK verification practical.
Gas Cost
Fixed:6000 gas (reduced from 40,000 in Istanbul via EIP-1108)
Input Format
y^2 = x^3 + 3 over BN254 field.
Scalar can be any 256-bit value (automatically reduced modulo curve order).
Output Format
Usage Example
Error Conditions
- Out of gas (gasLimit < 6000)
- Point not on curve (x, y don’t satisfy
y^2 = x^3 + 3) - Coordinate >= field modulus
Use Cases
- zkSNARK verification: Groth16 proofs require scalar multiplications
- Key derivation: Generate public keys from private scalars
- Commitment schemes: Pedersen commitments use scalar multiplication
- Signature schemes: BLS-like signatures on BN254
- Zero-knowledge protocols: Privacy-preserving applications
Implementation Details
- Zig: Pure Zig implementation using arkworks-rs bindings
- TypeScript: Wraps BN254 crypto module scalar multiplication
- Integration: Part of BN254 crypto suite
- Algorithm: Double-and-add (windowed for performance)
- Optimization: Constant-time execution to prevent timing attacks
Special Cases
- Scalar = 0: Returns point at infinity (0, 0)
- Scalar = 1: Returns input point unchanged
- Scalar = group order: Returns point at infinity (nP = O)
- Point at infinity input: Returns point at infinity regardless of scalar
- Scalar > group order: Automatically reduced modulo group order
Scalar Arithmetic
Scalars are elements of F_r where r is the curve order:- Group order (r): 21888242871839275222246405745257275088548364400416034343698204186575808495617
- Scalars wrap around:
(r + k) * P = k * P - Scalar = 0 or r: result is point at infinity
Test Vectors
Gas Cost History
| Hardfork | Gas Cost | Change |
|---|---|---|
| Byzantium | 40,000 | Initial |
| Istanbul (EIP-1108) | 6,000 | -85% |
Performance Considerations
- Scalar multiplication is ~40x more expensive than addition (6000 vs 150 gas)
- Prefer addition when possible (e.g., precompute multiples)
- Batch operations to amortize costs
- Typical Groth16 proof verification uses 2-3 scalar multiplications
References
Specifications
- Yellow Paper - Appendix E (Precompiled Contracts)
- EIP-196: Precompiled Contracts for Addition and Scalar Multiplication on alt_bn128
- EIP-1108: Reduce alt_bn128 Gas Costs

