This repo demonstrates a basic proof aggregator use case: put multiple proofs into one to reduce onchain verification fee. The idea is from vitalik's article. It comes with an aggregator and two zkevm rollups. Below is a step by step tutorial.
- compile circuits
# in circuit folder
cargo build --profile release --package proof-aggregation --bin proof-aggregation
cp ./target/release/proof-aggregation .- compile contract
# in contract folder
npm install
npx hardhat compile- config
contract/.envto your own key and get some test matic from mumbai faucet
# in contract folder
mv .env.example .env- deploy the aggregator
# in contract folder
npx hardhat run ./scripts/1_deploy_aggregator.ts --network mumbai- register rollup1 & rollup2 onchain
# in contract folder
npx hardhat run ./scripts/2_deploy_and_register_rollups.ts --network mumbai- export aggregation verifier from circuit
# in circuit folder
./proof-aggregation export-verifier AggregationVerifier.yul- set verifier
# in contract folder
npx hardhat run ./scripts/3_deploy_verifier.ts --network mumbai- gen proof for rollup1 & rollup2
# in circuit folder
# gen proof for rollup1
./proof-aggregation gen-circuit1-proof proof1.json
# gen proof for rollup2
./proof-aggregation gen-circuit2-proof proof2.json- submit proof1 & proof2 onchain
npx hardhat run ./scripts/4_submit_proofs.ts --network mumbai- get proof1 and proof2 then gen aggregate proof
# in circuit folder
./proof-aggregation gen-aggregated-proof proof1.json proof2.json agg.json- submit aggregated proof
# in contract folder
npx hardhat run ./scripts/5_submit_batch_proof.ts --network mumbai