Skip to content

BN254_ADD

Elliptic curve

Point addition on the alt_bn128 (BN254) curve.

Address0x0000000000000000000000000000000000000006
NameBN254_ADD
Minimum gas150
Input128 bytes
Output64 bytes
Available sinceByzantium; repriced at Istanbul (EIP-1108)

Input

x132 B
y132 B
x232 B
y232 B
OffsetLengthFieldDescription
032x1X coordinate of the first point.
3232y1Y coordinate of the first point.
6432x2X coordinate of the second point.
9632y2Y coordinate of the second point.

Output

The sum point as (x, y), 64 bytes.

Gas

150

Failure behaviour

  • Reverts if either input point is not on the curve or a coordinate is not a valid field element.
  • (0, 0) is the point at infinity and is accepted.
  • Input shorter than the expected length is right-padded with zero bytes rather than rejected.

Calling it

Precompiles have no ABI and no function selector: the input is raw bytes at the exact offsets above. Call with staticcall.

// BN254_ADD at 0x06
(bool ok, bytes memory out) = address(0x06).staticcall(input);
require(ok, "BN254_ADD reverted");

Specification

  • EIP-196: Precompiles for alt_bn128 addition and multiplication
  • EIP-1108: Reduce alt_bn128 precompile gas costs