AxiomV2Core ZK Circuits
Proving and Verifying Key Generation
For instructions on how to generate the exact proving and verifying keys we use in production on Ethereum Mainnet, see here.
Public Instance Formats
Any Snark has an associated Vec<Fr> of public instances. We describe the format for the ones relevant to the AxiomV2Core circuits below.
EthBlockHeaderChainCircuit
This depends on a max_depth parameter. The public instances are:
prev_hash:H256as twoFrelements in hi-lo formatend_hash:H256as twoFrelements in hi-lo formatstart_block_number . end_block_number: we assume both numbers areu32and encode them to a singleFrelement asstart_block_number * 2^32 + end_block_numbermerkle_mountain_range: a sequence ofmax_depth + 1H256elements, each encoded as twoFrelements in hi-lo format
Notes:
prev_hashis the parent hash of block numberstart_block_numberend_hashis the block hash of block numberend_block_numberend_block_number - start_block_numberis constrained to be<= 2^max_depth- This was previously assumed in
axiom-ethv0.1.1but not enforced because the block numbers are public instances, but we now enforce it for safety
- This was previously assumed in
merkle_mountain_rangeis ordered from largest peak (depthmax_depth) first to smallest peak (depth0) last
EthBlockHeaderChainIntermediateAggregationCircuit
This circuit takes two EthBlockHeaderChainCircuits and aggregates them. The public instances are:
4 * LIMBS = 12Frelements for the two BN254G1points representing the accumulator, used by the verifier for a pairing checkprev_hash:H256as twoFrelements in hi-lo formatend_hash:H256as twoFrelements in hi-lo formatstart_block_number . end_block_number: we assume both numbers areu32and encode them to a singleFrelement asstart_block_number * 2^32 + end_block_numbermerkle_mountain_range: a sequence of2^{max_depth - initial_depth} + initial_depthH256elements, each encoded as twoFrelements in hi-lo format
Notes:
- Same notes as
EthBlockHeaderChainCircuitexcept thatmerkle_mountain_rangeis not actually a Merkle mountain range: we recover a Merkle mountain range of lengthmax_depth + 1by forming a Merkle mountain range from leavesmerkle_mountain_range[..2^{max_depth - initial_depth}]and then appendingmerkle_mountain_range[2^{max_depth - initial_depth}..]to the end of it.- The reason is that we want to delay Keccaks
EthBlockHeaderChainRootAggregationCircuit
This circuit takes two EthBlockHeaderChainIntermediateAggregationCircuits and aggregates them. The public instances are:
4 * LIMBS = 12Frelements for the two BN254G1points representing the accumulator, used by the verifier for a pairing checkprev_hash:H256as twoFrelements in hi-lo formatend_hash:H256as twoFrelements in hi-lo formatstart_block_number . end_block_number: we assume both numbers areu32and encode them to a singleFrelement asstart_block_number * 2^32 + end_block_numbermerkle_mountain_range: a sequence ofmax_depth + 1H256elements, each encoded as twoFrelements in hi-lo format
Notes:
- Same notes as
EthBlockHeaderChainCircuit - This circuit is the same as
EthBlockHeaderChainIntermediateAggregationCircuitexcept that it does do the final Keccaks to form the full Merkle mountain range
Passthrough Aggregation Circuit
This is from axiom-eth.
We will only use this where snarks has length 1 and consists of a single snark. In this case it is an AggregationCircuit that purely passes through the public instances of the single snark in snarks, discarding old accumulators (there is no Merkle root computation because there is only one snark).
We will use this snark on [EthBlockHeaderChainRootAggregationCircuit] or itself if we want multiple rounds of passthrough aggregation.
The public instances are exactly the same as for [EthBlockHeaderChainRootAggregationCircuit].