Verifying ZK SNARKS on Ethereum

From SNARKs to EVM

Most of our smart contracts are very simple because the heavy lifting is done in a SNARK. To ensure full trustless-ness, these SNARKs must be verified by the EVM.

We do this by programmatically generating a specialized smart contract for verifying each SNARK that we use. We do this using the snark-verifier library, developed by the Privacy Scaling Explorations group at the Ethereum Foundation, which generates Yul code for verifying any given ZK circuit.

Here is an example of how we generate the Yul code for the AxiomV0 Verifier contract. All of the Yul code we used is open sourced, and we will soon be providing further instructions on how you can check the generation yourself.

We compiled the Yul code to bytecode using the command

solc --yul <YUL FILE> --bin | tail -1 > <BYTECODE FILE>

using solc Version: 0.8.17+commit.8df45f5f.Linux.g++.

We encourage you to check for yourself that the following Yul files match the deployed bytecode!

The constructors for AxiomV0, AxiomV0StoragePf, AccountAge, UniswapV2Twap were called with their respective SNARK verifier contract addresses.

When you call a function in one of the latter contracts, such as AccountAge's verifyAge function, you must supply a ZK SNARK proof in the form of a bytes array in the calldata. The contract then calls the above verifier contract to verify the SNARK proof.

Diving Deeper: SNARK Aggregation

Last updated