EIPs Explained

EIP-3026 · Stagnant · Core · 2020-10-05

EIP-3026: BW6-761 curve operations

Proposes seven precompiles for the BW6-761 pairing-friendly curve so contracts can efficiently verify 'proofs of proofs': SNARKs that check other SNARKs built on BLS12-377.

What problem does it solve?

Recursive or composed zk-SNARKs let one proof attest that another proof is valid. To do this efficiently you need a pair of curves where the scalar field of the "inner" curve equals the base field of the "outer" curve. BLS12-377 (proposed for Ethereum in EIP-2539) is a common inner curve; BW6-761 is a matching outer curve.

The spec states BW6-761 replaces the earlier CP6-782 outer curve used by Zexe and is much faster, citing Groth16 verification about 30× faster than with CP6-782. Without native support, verifying such outer proofs in EVM bytecode would be prohibitively expensive, so this EIP adds them as precompiles.

How it works

Seven precompiles, following the same design as the BLS12 precompile proposals:

Precompile Proposed address Input Gas
BW6_G1_ADD 0x1e 2 × G1 point (384 bytes) 180
BW6_G1_MUL 0x1f G1 point + scalar (256 bytes) 64000
BW6_G1_MULTIEXP 0x20 k × (point + scalar) discounted per k
BW6_G2_ADD 0x21 2 × G2 point 180
BW6_G2_MUL 0x22 G2 point + scalar 64000
BW6_G2_MULTIEXP 0x23 k × (point + scalar) discounted per k
BW6_PAIRING 0x24 k × (G1, G2) pairs (384 bytes each) 120000·k + 320000

Encoding rules:

  • Base-field elements are 96-byte big-endian integers that must be less than the field modulus.
  • A point is x ‖ y, 192 bytes. Because both G1 and G2 live over the base field (the G2 twist is defined over Fp), they share the same size. The point at infinity is encoded as all zeros.
  • Scalars are 64 bytes (the group order is only 377 bits, but 64 bytes keeps the ABI 32-byte aligned).
  • The pairing returns 32 bytes: 1 if the product of pairings is the identity, else 0. Points must be on the curve and, for pairing, in the right subgroup.
  • On any error, the call consumes all gas allotted for the operation.

Multi-exponentiation exists separately because one call is far cheaper than many CALLs to MUL and ADD.

Sample code

Calling the proposed pairing precompile from Solidity (address as proposed in the spec; it does not exist on mainnet):

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

library BW6Pairing {
    address constant BW6_PAIRING = address(0x24); // proposed, not deployed

    /// @param input concatenation of k (G1 || G2) pairs, 384 bytes each
    function check(bytes memory input) internal view returns (bool) {
        require(input.length > 0 && input.length % 384 == 0, "bad length");
        (bool ok, bytes memory out) = BW6_PAIRING.staticcall(input);
        require(ok && out.length == 32, "pairing failed");
        return abi.decode(out, (uint256)) == 1;
    }
}

Things to know

  • Status: Stagnant. These precompiles are not active on Ethereum mainnet, and the addresses listed are only proposals.
  • It depends on BLS12-377 support (EIP-2539), which is also not on mainnet. Ethereum instead added BLS12-381 precompiles via EIP-2537, a different curve family.
  • The gas numbers come from benchmark timings using the EIP-1962 estimation approach, and the spec notes they do not yet fully include ABI parsing and encoding overhead.

#precompile #cryptography #zk-snark #pairing #elliptic-curve

Details

Authors
Youssef El Housni (@yelhousni), Michael Connor (@iAmMichaelConnor), Aurore Guillevic <[email protected]>, hujw77 (@hujw77)
Status
Stagnant
Type
Standards Track / Core
Created
2020-10-05
Requires

Machine-readable: Markdown · JSON