From 9dcffdbd5856dbf8c7ce46d3ec8b85345b23f8bc Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Fri, 31 May 2024 09:17:48 +0800 Subject: [PATCH 01/18] separate aggregator snark-verifier dependencies --- Cargo.toml | 2 ++ aggregator/Cargo.toml | 4 +-- aggregator/src/aggregation/circuit.rs | 12 ++++---- aggregator/src/aggregation/config.rs | 10 +++---- aggregator/src/compression/circuit.rs | 22 +++++++------- aggregator/src/compression/circuit_ext.rs | 2 +- aggregator/src/compression/config.rs | 10 +++---- aggregator/src/core.rs | 34 +++++++++++----------- aggregator/src/param.rs | 2 +- aggregator/src/tests/aggregation.rs | 4 +-- aggregator/src/tests/compression.rs | 16 +++++----- aggregator/src/tests/mock_chunk.rs | 4 +-- aggregator/src/tests/rlc/dynamic_hashes.rs | 4 +-- 13 files changed, 65 insertions(+), 61 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3977473509..7ae91e1c8f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,6 +58,8 @@ serde_stacker = "0.1" sha3 = "0.10" snark-verifier = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop" } snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"] } +aggregator-snark-verifier = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop", package = "snark-verifier" } +aggregator-snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"], package = "snark-verifier-sdk" } strum = "0.25" strum_macros = "0.25" subtle = "2.4" diff --git a/aggregator/Cargo.toml b/aggregator/Cargo.toml index d34abe90d9..71b55742d0 100644 --- a/aggregator/Cargo.toml +++ b/aggregator/Cargo.toml @@ -24,8 +24,8 @@ rand.workspace = true halo2-base.workspace = true halo2-ecc.workspace = true halo2_proofs.workspace = true -snark-verifier.workspace = true -snark-verifier-sdk.workspace = true +aggregator-snark-verifier.workspace = true +aggregator-snark-verifier-sdk.workspace = true strum.workspace = true strum_macros.workspace = true diff --git a/aggregator/src/aggregation/circuit.rs b/aggregator/src/aggregation/circuit.rs index f1302b0db8..8eb161e234 100644 --- a/aggregator/src/aggregation/circuit.rs +++ b/aggregator/src/aggregation/circuit.rs @@ -14,16 +14,16 @@ use std::rc::Rc; use std::{env, fs::File}; #[cfg(not(feature = "disable_proof_aggregation"))] -use snark_verifier::loader::halo2::halo2_ecc::halo2_base; -use snark_verifier::pcs::kzg::KzgSuccinctVerifyingKey; +use aggregator_snark_verifier::loader::halo2::halo2_ecc::halo2_base; +use aggregator_snark_verifier::pcs::kzg::KzgSuccinctVerifyingKey; #[cfg(not(feature = "disable_proof_aggregation"))] -use snark_verifier::{ +use aggregator_snark_verifier::{ loader::halo2::{halo2_ecc::halo2_base::AssignedValue, Halo2Loader}, pcs::kzg::{Bdfg21, Kzg}, }; #[cfg(not(feature = "disable_proof_aggregation"))] -use snark_verifier_sdk::{aggregate, flatten_accumulator}; -use snark_verifier_sdk::{CircuitExt, Snark, SnarkWitness}; +use aggregator_snark_verifier_sdk::{aggregate, flatten_accumulator}; +use aggregator_snark_verifier_sdk::{CircuitExt, Snark, SnarkWitness}; use zkevm_circuits::util::Challenges; use crate::{ @@ -61,7 +61,7 @@ impl AggregationCircuit { snarks_with_padding: &[Snark], rng: impl Rng + Send, batch_hash: BatchHash, - ) -> Result { + ) -> Result { let timer = start_timer!(|| "generate aggregation circuit"); // sanity check: snarks's public input matches chunk_hashes diff --git a/aggregator/src/aggregation/config.rs b/aggregator/src/aggregation/config.rs index 1db10fd8b1..5671a7997e 100644 --- a/aggregator/src/aggregation/config.rs +++ b/aggregator/src/aggregation/config.rs @@ -1,8 +1,4 @@ -use halo2_proofs::{ - halo2curves::bn256::{Fq, Fr, G1Affine}, - plonk::{Column, ConstraintSystem, Instance}, -}; -use snark_verifier::{ +use aggregator_snark_verifier::{ loader::halo2::halo2_ecc::{ ecc::{BaseFieldEccChip, EccChip}, fields::fp::FpConfig, @@ -10,6 +6,10 @@ use snark_verifier::{ }, util::arithmetic::modulus, }; +use halo2_proofs::{ + halo2curves::bn256::{Fq, Fr, G1Affine}, + plonk::{Column, ConstraintSystem, Instance}, +}; use zkevm_circuits::{ keccak_circuit::{KeccakCircuitConfig, KeccakCircuitConfigArgs}, table::{BitwiseOpTable, KeccakTable, Pow2Table, PowOfRandTable, RangeTable, U8Table}, diff --git a/aggregator/src/compression/circuit.rs b/aggregator/src/compression/circuit.rs index 8c86667b02..f7dbc2a47a 100644 --- a/aggregator/src/compression/circuit.rs +++ b/aggregator/src/compression/circuit.rs @@ -2,14 +2,7 @@ use std::fs::File; -use ark_std::{end_timer, start_timer}; -use halo2_proofs::{ - circuit::{Cell, Layouter, SimpleFloorPlanner, Value}, - halo2curves::bn256::G1Affine, - plonk::{Circuit, ConstraintSystem, Error}, -}; -use rand::Rng; -use snark_verifier::{ +use aggregator_snark_verifier::{ loader::halo2::{ halo2_ecc::{ halo2_base, @@ -25,7 +18,16 @@ use snark_verifier::{ }, pcs::kzg::{Bdfg21, Kzg, KzgSuccinctVerifyingKey}, }; -use snark_verifier_sdk::{aggregate, flatten_accumulator, types::Svk, Snark, SnarkWitness}; +use aggregator_snark_verifier_sdk::{ + aggregate, flatten_accumulator, types::Svk, Snark, SnarkWitness, +}; +use ark_std::{end_timer, start_timer}; +use halo2_proofs::{ + circuit::{Cell, Layouter, SimpleFloorPlanner, Value}, + halo2curves::bn256::G1Affine, + plonk::{Circuit, ConstraintSystem, Error}, +}; +use rand::Rng; use crate::{core::extract_proof_and_instances_with_pairing_check, param::ConfigParams, ACC_LEN}; @@ -170,7 +172,7 @@ impl CompressionCircuit { snark: Snark, has_accumulator: bool, rng: impl Rng + Send, - ) -> Result { + ) -> Result { let svk = params.get_g()[0].into(); // for the proof compression, only ONE snark is under accumulation diff --git a/aggregator/src/compression/circuit_ext.rs b/aggregator/src/compression/circuit_ext.rs index 2fd0394cb9..cb1a571a31 100644 --- a/aggregator/src/compression/circuit_ext.rs +++ b/aggregator/src/compression/circuit_ext.rs @@ -1,7 +1,7 @@ //! CircuitExt implementation for compression circuit. +use aggregator_snark_verifier_sdk::CircuitExt; use halo2_proofs::{halo2curves::bn256::Fr, plonk::Selector}; -use snark_verifier_sdk::CircuitExt; use crate::ACC_LEN; diff --git a/aggregator/src/compression/config.rs b/aggregator/src/compression/config.rs index c301e07361..f75eb6de05 100644 --- a/aggregator/src/compression/config.rs +++ b/aggregator/src/compression/config.rs @@ -1,8 +1,4 @@ -use halo2_proofs::{ - halo2curves::bn256::{Fq, Fr, G1Affine}, - plonk::{Column, ConstraintSystem, Instance}, -}; -use snark_verifier::loader::halo2::halo2_ecc::{ +use aggregator_snark_verifier::loader::halo2::halo2_ecc::{ ecc::{BaseFieldEccChip, EccChip}, fields::fp::FpConfig, halo2_base::{ @@ -10,6 +6,10 @@ use snark_verifier::loader::halo2::halo2_ecc::{ utils::modulus, }, }; +use halo2_proofs::{ + halo2curves::bn256::{Fq, Fr, G1Affine}, + plonk::{Column, ConstraintSystem, Instance}, +}; use crate::{ constants::{BITS, LIMBS}, diff --git a/aggregator/src/core.rs b/aggregator/src/core.rs index 5002d83393..a4e9472f8e 100644 --- a/aggregator/src/core.rs +++ b/aggregator/src/core.rs @@ -1,18 +1,6 @@ use std::iter::repeat; -use ark_std::{end_timer, start_timer}; -use ethers_core::utils::keccak256; -use halo2_proofs::{ - circuit::{AssignedCell, Layouter, Region, Value}, - halo2curves::{ - bn256::{Bn256, Fq, Fr, G1Affine, G2Affine}, - pairing::Engine, - }, - poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, -}; -use itertools::Itertools; -use rand::Rng; -use snark_verifier::{ +use aggregator_snark_verifier::{ loader::native::NativeLoader, pcs::{ kzg::{Bdfg21, Kzg, KzgAccumulator, KzgAs}, @@ -22,10 +10,22 @@ use snark_verifier::{ verifier::PlonkVerifier, Error, }; -use snark_verifier_sdk::{ +use aggregator_snark_verifier_sdk::{ types::{PoseidonTranscript, Shplonk, POSEIDON_SPEC}, Snark, }; +use ark_std::{end_timer, start_timer}; +use ethers_core::utils::keccak256; +use halo2_proofs::{ + circuit::{AssignedCell, Layouter, Region, Value}, + halo2curves::{ + bn256::{Bn256, Fq, Fr, G1Affine, G2Affine}, + pairing::Engine, + }, + poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, +}; +use itertools::Itertools; +use rand::Rng; use zkevm_circuits::{ keccak_circuit::{keccak_packed_multi::multi_keccak, KeccakCircuit, KeccakCircuitConfig}, util::Challenges, @@ -78,7 +78,7 @@ pub(crate) fn extract_accumulators_and_proof( log::trace!("acc extraction {}-th acc check: left {:?}", i, left); log::trace!("acc extraction {}-th acc check: right {:?}", i, right); if left != right { - return Err(snark_verifier::Error::AssertionFailure(format!( + return Err(Error::AssertionFailure(format!( "accumulator check failed {left:?} {right:?}, index {i}", ))); } @@ -110,7 +110,7 @@ pub fn extract_proof_and_instances_with_pairing_check( params: &ParamsKZG, snarks: &[Snark], rng: impl Rng + Send, -) -> Result<(Vec, Vec), snark_verifier::Error> { +) -> Result<(Vec, Vec), Error> { // (old_accumulator, public inputs) -> (new_accumulator, public inputs) let (accumulator, as_proof) = extract_accumulators_and_proof(params, snarks, rng, ¶ms.g2(), ¶ms.s_g2())?; @@ -131,7 +131,7 @@ pub fn extract_proof_and_instances_with_pairing_check( log::trace!("circuit acc check: right {:?}", right); if left != right { - return Err(snark_verifier::Error::AssertionFailure(format!( + return Err(Error::AssertionFailure(format!( "accumulator check failed {left:?} {right:?}", ))); } diff --git a/aggregator/src/param.rs b/aggregator/src/param.rs index 65d26f5b4c..666926f2c6 100644 --- a/aggregator/src/param.rs +++ b/aggregator/src/param.rs @@ -1,4 +1,4 @@ -use snark_verifier::loader::halo2::halo2_ecc::fields::fp::FpStrategy; +use aggregator_snark_verifier::loader::halo2::halo2_ecc::fields::fp::FpStrategy; use crate::{BITS, LIMBS}; diff --git a/aggregator/src/tests/aggregation.rs b/aggregator/src/tests/aggregation.rs index 86185f96fb..59962e9588 100644 --- a/aggregator/src/tests/aggregation.rs +++ b/aggregator/src/tests/aggregation.rs @@ -1,10 +1,10 @@ use std::{fs, path::Path, process}; +use aggregator_snark_verifier::loader::halo2::halo2_ecc::halo2_base::utils::fs::gen_srs; +use aggregator_snark_verifier_sdk::{gen_pk, gen_snark_shplonk, verify_snark_shplonk, CircuitExt}; use ark_std::{end_timer, start_timer, test_rng}; use halo2_proofs::{dev::MockProver, halo2curves::bn256::Fr, poly::commitment::Params}; use itertools::Itertools; -use snark_verifier::loader::halo2::halo2_ecc::halo2_base::utils::fs::gen_srs; -use snark_verifier_sdk::{gen_pk, gen_snark_shplonk, verify_snark_shplonk, CircuitExt}; use crate::{ aggregation::AggregationCircuit, batch::BatchHash, constants::MAX_AGG_SNARKS, layer_0, diff --git a/aggregator/src/tests/compression.rs b/aggregator/src/tests/compression.rs index a9757dc47c..1161fae727 100644 --- a/aggregator/src/tests/compression.rs +++ b/aggregator/src/tests/compression.rs @@ -1,19 +1,19 @@ use std::{fs, path::Path, process}; -use ark_std::{end_timer, start_timer, test_rng}; -use halo2_proofs::{ - dev::MockProver, - halo2curves::bn256::{Bn256, Fr}, - poly::commitment::Params, -}; -use snark_verifier::{ +use aggregator_snark_verifier::{ loader::halo2::halo2_ecc::halo2_base::{halo2_proofs, utils::fs::gen_srs}, pcs::kzg::{Bdfg21, Kzg}, }; -use snark_verifier_sdk::{ +use aggregator_snark_verifier_sdk::{ evm_verify, gen_evm_proof_shplonk, gen_evm_verifier, gen_pk, gen_snark_shplonk, verify_snark_shplonk, CircuitExt, }; +use ark_std::{end_timer, start_timer, test_rng}; +use halo2_proofs::{ + dev::MockProver, + halo2curves::bn256::{Bn256, Fr}, + poly::commitment::Params, +}; use crate::{ compression_layer_evm, compression_layer_snark, layer_0, tests::mock_chunk::MockChunkCircuit, diff --git a/aggregator/src/tests/mock_chunk.rs b/aggregator/src/tests/mock_chunk.rs index a0e0532deb..71db1850ce 100644 --- a/aggregator/src/tests/mock_chunk.rs +++ b/aggregator/src/tests/mock_chunk.rs @@ -1,5 +1,7 @@ use std::iter; +use aggregator_snark_verifier::loader::halo2::halo2_ecc::halo2_base::SKIP_FIRST_PASS; +use aggregator_snark_verifier_sdk::CircuitExt; use ark_std::test_rng; use halo2_proofs::{ circuit::{AssignedCell, Layouter, SimpleFloorPlanner}, @@ -7,8 +9,6 @@ use halo2_proofs::{ halo2curves::bn256::Fr, plonk::{Circuit, Column, ConstraintSystem, Error, Instance}, }; -use snark_verifier::loader::halo2::halo2_ecc::halo2_base::SKIP_FIRST_PASS; -use snark_verifier_sdk::CircuitExt; use zkevm_circuits::{table::KeccakTable, util::Challenges}; use crate::{ diff --git a/aggregator/src/tests/rlc/dynamic_hashes.rs b/aggregator/src/tests/rlc/dynamic_hashes.rs index 1fe228882d..190faaa953 100644 --- a/aggregator/src/tests/rlc/dynamic_hashes.rs +++ b/aggregator/src/tests/rlc/dynamic_hashes.rs @@ -1,3 +1,5 @@ +use aggregator_snark_verifier::loader::halo2::halo2_ecc::halo2_base::utils::fs::gen_srs; +use aggregator_snark_verifier_sdk::{gen_pk, gen_snark_shplonk, verify_snark_shplonk, CircuitExt}; use ark_std::test_rng; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner}, @@ -5,8 +7,6 @@ use halo2_proofs::{ halo2curves::bn256::Fr, plonk::{Circuit, ConstraintSystem, Error}, }; -use snark_verifier::loader::halo2::halo2_ecc::halo2_base::utils::fs::gen_srs; -use snark_verifier_sdk::{gen_pk, gen_snark_shplonk, verify_snark_shplonk, CircuitExt}; use zkevm_circuits::{ keccak_circuit::{ keccak_packed_multi::{self, multi_keccak}, From 13ffce72c59a06f19c2ac979830fdefb74615216 Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Mon, 3 Jun 2024 15:27:51 +0800 Subject: [PATCH 02/18] use halo2 libs from snark-verifier --- Cargo.lock | 1058 ++++++++++++----- Cargo.toml | 4 +- aggregator/Cargo.toml | 7 +- aggregator/src/aggregation/barycentric.rs | 30 +- aggregator/src/aggregation/batch_data.rs | 16 +- aggregator/src/aggregation/blob_data.rs | 16 +- aggregator/src/aggregation/circuit.rs | 27 +- aggregator/src/aggregation/config.rs | 12 +- aggregator/src/aggregation/decoder.rs | 21 +- .../src/aggregation/decoder/seq_exec.rs | 10 +- .../aggregation/decoder/tables/bitstring.rs | 80 +- .../src/aggregation/decoder/tables/fixed.rs | 62 +- .../tables/fixed/fse_table_transition.rs | 3 +- .../decoder/tables/fixed/predefined_fse.rs | 3 +- .../decoder/tables/fixed/seq_code_to_value.rs | 3 +- .../fixed/seq_data_interleaved_order.rs | 3 +- .../decoder/tables/fixed/seq_tag_order.rs | 3 +- .../decoder/tables/fixed/tag_transition.rs | 3 +- .../tables/fixed/variable_bit_packing.rs | 3 +- .../src/aggregation/decoder/tables/fse.rs | 70 +- .../decoder/tables/literals_header.rs | 64 +- .../decoder/tables/seqinst_table.rs | 70 +- aggregator/src/aggregation/decoder/witgen.rs | 4 +- .../src/aggregation/decoder/witgen/types.rs | 11 +- aggregator/src/aggregation/rlc/config.rs | 4 +- aggregator/src/aggregation/rlc/gates.rs | 4 +- aggregator/src/aggregation/util.rs | 4 +- aggregator/src/blob.rs | 6 +- aggregator/src/compression/circuit.rs | 23 +- aggregator/src/compression/circuit_ext.rs | 4 +- aggregator/src/compression/config.rs | 24 +- aggregator/src/core.rs | 41 +- aggregator/src/param.rs | 2 +- aggregator/src/tests.rs | 32 +- aggregator/src/tests/aggregation.rs | 28 +- aggregator/src/tests/blob.rs | 41 +- aggregator/src/tests/compression.rs | 8 +- aggregator/src/tests/mock_chunk.rs | 17 +- aggregator/src/tests/rlc/dynamic_hashes.rs | 51 +- aggregator/src/tests/rlc/gates.rs | 3 +- aggregator/src/util.rs | 28 +- 41 files changed, 1257 insertions(+), 646 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 35e7cb572e..5cd5f6d2ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" dependencies = [ "gimli", ] @@ -44,7 +44,7 @@ version = "0.1.0" dependencies = [ "ark-std 0.3.0", "bitstream-io", - "c-kzg", + "c-kzg 1.0.2", "csv", "ctor", "encoder", @@ -52,21 +52,19 @@ dependencies = [ "eth-types", "ethers-core", "gadgets", - "halo2-base", - "halo2-ecc", - "halo2_proofs", + "halo2curves 0.1.0", "hex", "itertools 0.11.0", "log", "num-bigint", "once_cell", "rand", - "revm-precompile", - "revm-primitives", + "revm-precompile 7.0.0", + "revm-primitives 4.0.0", "serde", "serde_json", - "snark-verifier", - "snark-verifier-sdk", + "snark-verifier 0.1.8", + "snark-verifier-sdk 0.1.8", "strum 0.25.0", "strum_macros 0.25.3", "zkevm-circuits", @@ -99,6 +97,23 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +[[package]] +name = "alloy-primitives" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0628ec0ba5b98b3370bb6be17b12f23bfce8ee4ad83823325a20546d9b03b78" +dependencies = [ + "alloy-rlp", + "bytes", + "cfg-if 1.0.0", + "const-hex", + "derive_more", + "hex-literal", + "itoa", + "ruint", + "tiny-keccak", +] + [[package]] name = "alloy-primitives" version = "0.7.4" @@ -123,14 +138,26 @@ dependencies = [ [[package]] name = "alloy-rlp" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d58d9f5da7b40e9bfff0b7e7816700be4019db97d4b6359fe7f94a9e22e42ac" +checksum = "b155716bab55763c95ba212806cf43d05bcc70e5f35b02bad20cf5ec7fe11fed" dependencies = [ + "alloy-rlp-derive", "arrayvec", "bytes", ] +[[package]] +name = "alloy-rlp-derive" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8037e03c7f462a063f28daec9fda285a9a89da003c552f8637a80b9c8fd96241" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "android-tzdata" version = "0.1.1" @@ -148,47 +175,48 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", + "is_terminal_polyfill", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" [[package]] name = "anstyle-parse" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.2" +version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -196,9 +224,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.82" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "arc-swap" @@ -366,7 +394,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -398,20 +426,20 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] name = "autocfg" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.71" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" +checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" dependencies = [ "addr2line", "cc", @@ -461,6 +489,29 @@ dependencies = [ "serde", ] +[[package]] +name = "bindgen" +version = "0.66.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" +dependencies = [ + "bitflags 2.5.0", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.66", + "which", +] + [[package]] name = "bit-set" version = "0.5.3" @@ -490,9 +541,9 @@ checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "bitstream-io" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c9989a51171e2e81038ab168b6ae22886fe9ded214430dbb4f41c28cf176da" +checksum = "7c12d1856e42f0d817a835fe55853957c85c8c8a470114029143d3f12671446e" [[package]] name = "bitvec" @@ -566,9 +617,9 @@ dependencies = [ [[package]] name = "blst" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c94087b935a822949d3291a9989ad2b2051ea141eda0fd4e478a75f6aa3e604b" +checksum = "62dc83a094a71d43eeadd254b1ec2d24cb6a0bb6cadce00df51f0db594711a32" dependencies = [ "cc", "glob", @@ -604,7 +655,7 @@ dependencies = [ "ethers-signers", "external-tracer", "gadgets", - "halo2_proofs", + "halo2_proofs 1.1.0", "hex", "itertools 0.11.0", "log", @@ -615,7 +666,7 @@ dependencies = [ "pretty_assertions", "rand", "rayon", - "revm-precompile", + "revm-precompile 7.0.0", "serde", "serde_json", "strum 0.25.0", @@ -666,6 +717,21 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "c-kzg" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac926d808fb72fe09ebf471a091d6d72918876ccf0b4989766093d2d0d24a0ef" +dependencies = [ + "bindgen", + "blst", + "cc", + "glob", + "hex", + "libc", + "serde", +] + [[package]] name = "c-kzg" version = "1.0.2" @@ -682,9 +748,9 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" dependencies = [ "serde", ] @@ -706,7 +772,7 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "thiserror", @@ -714,12 +780,22 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.94" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" dependencies = [ "jobserver", "libc", + "once_cell", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", ] [[package]] @@ -744,6 +820,7 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", + "serde", "wasm-bindgen", "windows-targets 0.52.5", ] @@ -768,7 +845,7 @@ dependencies = [ "eth-types", "ethers", "ethers-signers", - "halo2_proofs", + "halo2_proofs 1.1.0", "itertools 0.11.0", "log", "mock", @@ -780,6 +857,17 @@ dependencies = [ "zkevm-circuits", ] +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + [[package]] name = "clap" version = "4.5.4" @@ -811,7 +899,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -897,9 +985,9 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" [[package]] name = "colored" @@ -913,9 +1001,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.11.3" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ba00838774b4ab0233e355d26710fbfc8327a05c017f6dc4873f876d1f79f78" +checksum = "94fb8a24a26d37e1ffd45343323dc9fe6654ceea44c12f2fcb3d7ac29e610bc6" dependencies = [ "cfg-if 1.0.0", "cpufeatures", @@ -975,9 +1063,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if 1.0.0", ] @@ -997,9 +1085,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.12" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" dependencies = [ "crossbeam-utils", ] @@ -1034,9 +1122,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crunchy" @@ -1112,8 +1200,18 @@ version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" dependencies = [ - "darling_core", - "darling_macro", + "darling_core 0.13.4", + "darling_macro 0.13.4", +] + +[[package]] +name = "darling" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +dependencies = [ + "darling_core 0.20.9", + "darling_macro 0.20.9", ] [[package]] @@ -1130,22 +1228,47 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "darling_core" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.11.1", + "syn 2.0.66", +] + [[package]] name = "darling_macro" version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ - "darling_core", + "darling_core 0.13.4", "quote", "syn 1.0.109", ] +[[package]] +name = "darling_macro" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +dependencies = [ + "darling_core 0.20.9", + "quote", + "syn 2.0.66", +] + [[package]] name = "data-encoding" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "der" @@ -1164,6 +1287,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", + "serde", ] [[package]] @@ -1272,9 +1396,9 @@ dependencies = [ [[package]] name = "either" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "elliptic-curve" @@ -1297,9 +1421,9 @@ dependencies = [ [[package]] name = "ena" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c533630cf40e9caa44bd91aadc88a75d75a4c3a12b4cfde353cbed41daa1e1f1" +checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5" dependencies = [ "log", ] @@ -1353,7 +1477,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -1377,9 +1501,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", @@ -1414,7 +1538,7 @@ dependencies = [ "base64 0.13.1", "ethers-core", "ethers-signers", - "halo2curves", + "halo2curves 0.1.0", "hex", "itertools 0.11.0", "log", @@ -1422,11 +1546,11 @@ dependencies = [ "num-bigint", "poseidon-base", "regex", - "revm-precompile", - "revm-primitives", + "revm-precompile 7.0.0", + "revm-primitives 4.0.0", "serde", "serde_json", - "serde_with", + "serde_with 1.14.0", "sha3 0.10.8", "strum 0.25.0", "strum_macros 0.25.3", @@ -1544,7 +1668,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.60", + "syn 2.0.66", "toml 0.7.8", "walkdir", ] @@ -1561,7 +1685,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -1586,7 +1710,7 @@ dependencies = [ "serde", "serde_json", "strum 0.24.1", - "syn 2.0.60", + "syn 2.0.66", "tempfile", "thiserror", "tiny-keccak", @@ -1601,7 +1725,7 @@ dependencies = [ "ethers-core", "ethers-solc", "reqwest", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "thiserror", @@ -1705,7 +1829,7 @@ dependencies = [ "path-slash", "rayon", "regex", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "solang-parser", @@ -1742,9 +1866,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "fastrlp" @@ -1788,9 +1912,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" dependencies = [ "crc32fast", "miniz_oxide", @@ -1893,7 +2017,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -1950,7 +2074,7 @@ name = "gadgets" version = "0.1.0" dependencies = [ "eth-types", - "halo2_proofs", + "halo2_proofs 1.1.0", "rand", "rand_xorshift", "sha3 0.10.8", @@ -1979,20 +2103,32 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if 1.0.0", "libc", "wasi", ] +[[package]] +name = "getset" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e45727250e75cc04ff2846a66397da8ef2b3db8e40e0cef4df67950a07621eb9" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "gimli" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] name = "git-version" @@ -2011,7 +2147,7 @@ checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -2063,7 +2199,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 2.2.6", "slab", "tokio", "tokio-util", @@ -2076,7 +2212,7 @@ version = "0.2.2" source = "git+https://github.com/scroll-tech/halo2-lib?branch=develop#817cace374a9f4b2eca682b1cc36f143255ea25f" dependencies = [ "ff", - "halo2_proofs", + "halo2_proofs 1.1.0", "itertools 0.10.5", "num-bigint", "num-integer", @@ -2085,6 +2221,26 @@ dependencies = [ "rustc-hash", ] +[[package]] +name = "halo2-base" +version = "0.4.1" +source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition#18d7d6e713d7161e1f5aa15e8721e6160eb36776" +dependencies = [ + "getset", + "halo2_proofs 0.3.0", + "itertools 0.11.0", + "log", + "num-bigint", + "num-integer", + "num-traits", + "poseidon-primitives", + "rand_chacha", + "rayon", + "rustc-hash", + "serde", + "serde_json", +] + [[package]] name = "halo2-ecc" version = "0.2.2" @@ -2092,7 +2248,7 @@ source = "git+https://github.com/scroll-tech/halo2-lib?branch=develop#817cace374 dependencies = [ "ff", "group", - "halo2-base", + "halo2-base 0.2.2", "itertools 0.10.5", "num-bigint", "num-integer", @@ -2104,12 +2260,31 @@ dependencies = [ "serde_json", ] +[[package]] +name = "halo2-ecc" +version = "0.4.1" +source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition#18d7d6e713d7161e1f5aa15e8721e6160eb36776" +dependencies = [ + "halo2-base 0.4.1", + "itertools 0.11.0", + "num-bigint", + "num-integer", + "num-traits", + "rand", + "rand_chacha", + "rand_core", + "rayon", + "serde", + "serde_json", + "test-case", +] + [[package]] name = "halo2-gate-generator" version = "0.1.0" source = "git+https://github.com/scroll-tech/halo2gategen?branch=scroll#2fa5c39aa67d0f97d660f37954daa9e897d0a4c1" dependencies = [ - "halo2_proofs", + "halo2_proofs 1.1.0", "lazy_static", "num-bigint", "rand", @@ -2126,7 +2301,7 @@ version = "0.1.0" source = "git+https://github.com/scroll-tech/mpt-circuit.git?branch=v0.7#daa3a06e2e96d00337188280ac43fa879e722804" dependencies = [ "ethers-core", - "halo2_proofs", + "halo2_proofs 1.1.0", "hex", "itertools 0.10.5", "lazy_static", @@ -2146,24 +2321,40 @@ dependencies = [ [[package]] name = "halo2_gadgets" version = "1.1.0" -source = "git+https://github.com/scroll-tech/halo2.git?branch=v1.1#6c5e9eec5088dc8b4a23edcdd1eaf8705b5fc7dc" +source = "git+https://github.com/scroll-tech/halo2.git?branch=v1.1#e5ddf67e5ae16be38d6368ed355c7c41906272ab" dependencies = [ "arrayvec", "bitvec", "ff", "group", - "halo2_proofs", - "halo2curves", + "halo2_proofs 1.1.0", + "halo2curves 0.1.0", "lazy_static", "rand", "subtle", "uint", ] +[[package]] +name = "halo2_proofs" +version = "0.3.0" +source = "git+https://github.com/privacy-scaling-explorations/halo2.git?tag=v0.3.0#73408a140737d8336490452193b21f5a7a94e7de" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "halo2curves 0.6.1", + "rand_chacha", + "rand_core", + "rayon", + "sha3 0.9.1", + "tracing", +] + [[package]] name = "halo2_proofs" version = "1.1.0" -source = "git+https://github.com/scroll-tech/halo2.git?branch=v1.1#6c5e9eec5088dc8b4a23edcdd1eaf8705b5fc7dc" +source = "git+https://github.com/scroll-tech/halo2.git?branch=v1.1#e5ddf67e5ae16be38d6368ed355c7c41906272ab" dependencies = [ "ark-std 0.3.0", "blake2b_simd", @@ -2171,7 +2362,7 @@ dependencies = [ "crossbeam", "ff", "group", - "halo2curves", + "halo2curves 0.1.0", "log", "maybe-rayon", "num-bigint", @@ -2208,6 +2399,31 @@ dependencies = [ "subtle", ] +[[package]] +name = "halo2curves" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db81d01d0bbfec9f624d7590fc6929ee2537a64ec1e080d8f8c9e2d2da291405" +dependencies = [ + "blake2b_simd", + "ff", + "group", + "hex", + "lazy_static", + "num-bigint", + "num-traits", + "pairing", + "pasta_curves", + "paste", + "rand", + "rand_core", + "rayon", + "serde", + "serde_arrays", + "static_assertions", + "subtle", +] + [[package]] name = "handlebars" version = "4.5.0" @@ -2222,6 +2438,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + [[package]] name = "hashbrown" version = "0.13.2" @@ -2233,9 +2455,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash", "allocator-api2", @@ -2273,6 +2495,9 @@ name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +dependencies = [ + "serde", +] [[package]] name = "hex-literal" @@ -2459,6 +2684,17 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + [[package]] name = "indexmap" version = "2.2.6" @@ -2466,7 +2702,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -2480,9 +2716,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if 1.0.0", ] @@ -2495,7 +2731,7 @@ dependencies = [ "env_logger", "eth-types", "ethers", - "halo2_proofs", + "halo2_proofs 1.1.0", "hex", "log", "mock", @@ -2529,6 +2765,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + [[package]] name = "itertools" version = "0.10.5" @@ -2564,9 +2806,9 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jobserver" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685a7d121ee3f65ae4fddd72b25a04bb36b6af81bc0828f7d5434c0fe60fa3a2" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" dependencies = [ "libc", ] @@ -2605,9 +2847,9 @@ dependencies = [ [[package]] name = "keccak-asm" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb8515fff80ed850aea4a1595f2e519c003e2a00a82fe168ebf5269196caf444" +checksum = "47a3633291834c4fbebf8673acbc1b04ec9d151418ff9b8e26dcd79129928758" dependencies = [ "digest 0.10.7", "sha3-asm", @@ -2650,11 +2892,27 @@ dependencies = [ "spin 0.5.2", ] +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libloading" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +dependencies = [ + "cfg-if 1.0.0", + "windows-targets 0.48.5", +] [[package]] name = "libm" @@ -2680,15 +2938,15 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -2759,11 +3017,17 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" dependencies = [ "adler", ] @@ -2785,7 +3049,7 @@ version = "0.1.0" source = "git+https://github.com/scroll-tech/misc-precompiled-circuit.git?branch=main#dcb5018d84e8a9adec59cd33f5348a3971cec194" dependencies = [ "halo2-gate-generator", - "halo2_proofs", + "halo2_proofs 1.1.0", "num-bigint", "rand", "serde", @@ -2815,7 +3079,7 @@ version = "0.1.0" dependencies = [ "env_logger", "eth-types", - "halo2curves", + "halo2curves 0.1.0", "hex", "log", "num-bigint", @@ -2831,11 +3095,21 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + [[package]] name = "num" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135b08af27d103b0a51f2ae0f8632117b7b185ccf931445affa8df530576a41" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" dependencies = [ "num-bigint", "num-complex", @@ -2847,11 +3121,10 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", "num-traits", "rand", @@ -2859,9 +3132,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" dependencies = [ "num-traits", ] @@ -2894,9 +3167,9 @@ dependencies = [ [[package]] name = "num-iter" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", @@ -2905,11 +3178,10 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "autocfg", "num-bigint", "num-integer", "num-traits", @@ -2917,9 +3189,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", @@ -2974,14 +3246,14 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] name = "object" -version = "0.32.2" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" dependencies = [ "memchr", ] @@ -3034,9 +3306,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.9" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" +checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ "arrayvec", "bitvec", @@ -3048,11 +3320,11 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.9" +version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" +checksum = "d830939c76d294956402033aee57a6da7b438f2294eb94864c37b0569053a42c" dependencies = [ - "proc-macro-crate 2.0.0", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 1.0.109", @@ -3060,9 +3332,9 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -3070,15 +3342,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if 1.0.0", "libc", "redox_syscall", "smallvec", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] @@ -3101,17 +3373,19 @@ dependencies = [ "blake2b_simd", "ff", "group", + "hex", "lazy_static", "rand", + "serde", "static_assertions", "subtle", ] [[package]] name = "paste" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "path-slash" @@ -3141,6 +3415,12 @@ dependencies = [ "hmac", ] +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + [[package]] name = "percent-encoding" version = "2.3.1" @@ -3149,9 +3429,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95" +checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" dependencies = [ "memchr", "thiserror", @@ -3160,9 +3440,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73541b156d32197eecda1a4014d7f868fd2bcb3c550d5386087cfba442bf69c" +checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" dependencies = [ "pest", "pest_generator", @@ -3170,22 +3450,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c35eeed0a3fab112f75165fdc026b3913f4183133f19b49be773ac9ea966e8bd" +checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] name = "pest_meta" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2adbf29bb9776f28caece835398781ab24435585fe0d4dc1374a61db5accedca" +checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" dependencies = [ "once_cell", "pest", @@ -3194,12 +3474,12 @@ dependencies = [ [[package]] name = "petgraph" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 2.2.6", ] [[package]] @@ -3242,7 +3522,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -3280,7 +3560,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -3316,7 +3596,7 @@ name = "poseidon" version = "0.2.0" source = "git+https://github.com/scroll-tech/poseidon.git?branch=main#5787dd3d2ce7a9e9601a035c396ac0c03449b54d" dependencies = [ - "halo2curves", + "halo2curves 0.1.0", "subtle", ] @@ -3326,7 +3606,7 @@ version = "0.1.0" source = "git+https://github.com/scroll-tech/poseidon-circuit.git?branch=main#7b96835c6201afdbfaf3d13d641efbaaf5db2d20" dependencies = [ "bitvec", - "halo2curves", + "halo2curves 0.1.0", "lazy_static", ] @@ -3336,7 +3616,7 @@ version = "0.1.0" source = "git+https://github.com/scroll-tech/poseidon-circuit.git?branch=main#7b96835c6201afdbfaf3d13d641efbaaf5db2d20" dependencies = [ "ff", - "halo2_proofs", + "halo2_proofs 1.1.0", "log", "poseidon-base", "rand", @@ -3344,6 +3624,21 @@ dependencies = [ "thiserror", ] +[[package]] +name = "poseidon-primitives" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bd95570f7ea849b4187298b5bb229643e44e1d47ddf3979d0db8a1c28be26a8" +dependencies = [ + "bitvec", + "ff", + "lazy_static", + "log", + "rand", + "rand_xorshift", + "thiserror", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -3374,12 +3669,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ac2cf0f2e4f42b49f5ffd07dae8d746508ef7526c13940e5f524012ae6c6550" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -3422,18 +3717,42 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "2.0.0" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "toml_edit 0.20.7", + "toml_edit 0.21.1", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", ] [[package]] name = "proc-macro2" -version = "1.0.81" +version = "1.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" +checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" dependencies = [ "unicode-ident", ] @@ -3472,7 +3791,7 @@ dependencies = [ "eth-types", "ethers-core", "git-version", - "halo2_proofs", + "halo2_proofs 1.1.0", "hex", "itertools 0.11.0", "log", @@ -3486,8 +3805,8 @@ dependencies = [ "serde_json", "serde_stacker", "sha2", - "snark-verifier", - "snark-verifier-sdk", + "snark-verifier 0.1.0", + "snark-verifier-sdk 0.0.1", "zkevm-circuits", ] @@ -3582,11 +3901,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.5.0", ] [[package]] @@ -3693,38 +4012,93 @@ dependencies = [ "sha3 0.10.8", ] +[[package]] +name = "revm" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f4ca8ae0345104523b4af1a8a7ea97cfa1865cdb7a7c25d23c1a18d9b48598" +dependencies = [ + "auto_impl", + "revm-interpreter", + "revm-precompile 2.2.0", +] + +[[package]] +name = "revm-interpreter" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f959cafdf64a7f89b014fa73dc2325001cf654b3d9400260b212d19a2ebe3da0" +dependencies = [ + "revm-primitives 1.3.0", +] + +[[package]] +name = "revm-precompile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d360a88223d85709d2e95d4609eb1e19c649c47e28954bfabae5e92bb37e83e" +dependencies = [ + "c-kzg 0.1.1", + "k256", + "num", + "once_cell", + "revm-primitives 1.3.0", + "ripemd", + "secp256k1 0.27.0", + "sha2", + "substrate-bn", +] + [[package]] name = "revm-precompile" version = "7.0.0" source = "git+https://github.com/scroll-tech/revm?branch=scroll-evm-executor/v36#8543dd627348907773d8057807b6a310b276bb30" dependencies = [ "aurora-engine-modexp", - "c-kzg", + "c-kzg 1.0.2", "k256", "once_cell", - "revm-primitives", + "revm-primitives 4.0.0", "ripemd", "secp256k1 0.29.0", "sha2", "substrate-bn", ] +[[package]] +name = "revm-primitives" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51187b852d9e458816a2e19c81f1dd6c924077e1a8fccd16e4f044f865f299d7" +dependencies = [ + "alloy-primitives 0.4.2", + "alloy-rlp", + "auto_impl", + "bitflags 2.5.0", + "bitvec", + "c-kzg 0.1.1", + "enumn", + "hashbrown 0.14.5", + "hex", + "once_cell", +] + [[package]] name = "revm-primitives" version = "4.0.0" source = "git+https://github.com/scroll-tech/revm?branch=scroll-evm-executor/v36#8543dd627348907773d8057807b6a310b276bb30" dependencies = [ - "alloy-primitives", + "alloy-primitives 0.7.4", "auto_impl", "bitflags 2.5.0", "bitvec", - "c-kzg", + "c-kzg 1.0.2", "cfg-if 1.0.0", "derive_more", "dyn-clone", "enumn", - "halo2curves", - "hashbrown 0.14.3", + "halo2curves 0.1.0", + "hashbrown 0.14.5", "hex", "once_cell", "poseidon-base", @@ -3852,9 +4226,9 @@ checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" @@ -3883,14 +4257,14 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.22", + "semver 1.0.23", ] [[package]] name = "rustix" -version = "0.38.32" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.5.0", "errno", @@ -3901,9 +4275,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.10" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring 0.17.8", @@ -3942,9 +4316,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.15" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80af6f9131f277a45a3fba6ce8e2258037bb0477a67e610d3c1fe046ab31de47" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "rusty-fork" @@ -3960,9 +4334,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "salsa20" @@ -3984,9 +4358,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.2" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" +checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" dependencies = [ "cfg-if 1.0.0", "derive_more", @@ -3996,11 +4370,11 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.2" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" +checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 1.0.109", @@ -4057,6 +4431,15 @@ dependencies = [ "secp256k1-sys 0.6.1", ] +[[package]] +name = "secp256k1" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" +dependencies = [ + "secp256k1-sys 0.8.1", +] + [[package]] name = "secp256k1" version = "0.29.0" @@ -4076,6 +4459,15 @@ dependencies = [ "cc", ] +[[package]] +name = "secp256k1-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a129b9e9efbfb223753b9163c4ab3b13cff7fd9c7f010fbac25ab4099fa07e" +dependencies = [ + "cc", +] + [[package]] name = "secp256k1-sys" version = "0.10.0" @@ -4096,9 +4488,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.22" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" dependencies = [ "serde", ] @@ -4126,9 +4518,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.198" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] @@ -4144,20 +4536,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.198" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] name = "serde_json" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -4166,9 +4558,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" dependencies = [ "serde", ] @@ -4202,7 +4594,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" dependencies = [ "serde", - "serde_with_macros", + "serde_with_macros 1.5.2", +] + +[[package]] +name = "serde_with" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" +dependencies = [ + "base64 0.13.1", + "chrono", + "hex", + "indexmap 1.9.3", + "serde", + "serde_json", + "serde_with_macros 2.3.3", + "time", ] [[package]] @@ -4211,12 +4619,24 @@ version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" dependencies = [ - "darling", + "darling 0.13.4", "proc-macro2", "quote", "syn 1.0.109", ] +[[package]] +name = "serde_with_macros" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" +dependencies = [ + "darling 0.20.9", + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "sha1" version = "0.10.6" @@ -4263,14 +4683,20 @@ dependencies = [ [[package]] name = "sha3-asm" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bac61da6b35ad76b195eb4771210f947734321a8d81d7738e1580d953bc7a15e" +checksum = "a9b57fd861253bff08bb1919e995f90ba8f4889de2726091c8876f3a4e823b40" dependencies = [ "cc", "cfg-if 1.0.0", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signature" version = "2.2.0" @@ -4309,8 +4735,8 @@ source = "git+https://github.com/scroll-tech/snark-verifier?branch=develop#fe1f8 dependencies = [ "bytes", "ethereum-types", - "halo2-base", - "halo2-ecc", + "halo2-base 0.2.2", + "halo2-ecc 0.2.2", "hex", "itertools 0.12.1", "num-bigint", @@ -4318,13 +4744,34 @@ dependencies = [ "num-traits", "poseidon", "rand", - "revm", + "revm 2.3.1", "rlp", "rustc-hash", "serde", "sha3 0.10.8", ] +[[package]] +name = "snark-verifier" +version = "0.1.8" +source = "git+https://github.com/axiom-crypto/snark-verifier?branch=community-edition#59845ab4a7a175063d02b721343e687199d8ec24" +dependencies = [ + "halo2-base 0.4.1", + "halo2-ecc 0.4.1", + "hex", + "itertools 0.11.0", + "lazy_static", + "num-bigint", + "num-integer", + "num-traits", + "pairing", + "rand", + "revm 3.5.0", + "ruint", + "serde", + "sha3 0.10.8", +] + [[package]] name = "snark-verifier-sdk" version = "0.0.1" @@ -4333,7 +4780,7 @@ dependencies = [ "bincode", "ethereum-types", "ff", - "halo2-base", + "halo2-base 0.2.2", "hex", "itertools 0.12.1", "log", @@ -4344,14 +4791,37 @@ dependencies = [ "rand_chacha", "serde", "serde_json", - "snark-verifier", + "snark-verifier 0.1.0", +] + +[[package]] +name = "snark-verifier-sdk" +version = "0.1.8" +source = "git+https://github.com/axiom-crypto/snark-verifier?branch=community-edition#59845ab4a7a175063d02b721343e687199d8ec24" +dependencies = [ + "bincode", + "ethereum-types", + "getset", + "halo2-base 0.4.1", + "hex", + "itertools 0.11.0", + "lazy_static", + "num-bigint", + "num-integer", + "num-traits", + "rand", + "rand_chacha", + "serde", + "serde_json", + "serde_with 2.3.3", + "snark-verifier 0.1.8", ] [[package]] name = "socket2" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", @@ -4475,7 +4945,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -4508,7 +4978,7 @@ dependencies = [ "home", "once_cell", "reqwest", - "semver 1.0.22", + "semver 1.0.23", "serde", "serde_json", "sha2", @@ -4530,9 +5000,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.60" +version = "2.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" dependencies = [ "proc-macro2", "quote", @@ -4604,6 +5074,39 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "test-case" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb2550dd13afcd286853192af8601920d959b14c401fcece38071d53bf0768a8" +dependencies = [ + "test-case-macros", +] + +[[package]] +name = "test-case-core" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adcb7fd841cd518e279be3d5a3eb0636409487998a4aff22f3de87b81e88384f" +dependencies = [ + "cfg-if 1.0.0", + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "test-case-macros" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "test-case-core", +] + [[package]] name = "testool" version = "0.1.0" @@ -4618,7 +5121,7 @@ dependencies = [ "ethers-signers", "external-tracer", "glob", - "halo2_proofs", + "halo2_proofs 1.1.0", "handlebars", "hex", "itertools 0.11.0", @@ -4644,22 +5147,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -4688,10 +5191,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", + "itoa", "num-conv", "powerfmt", "serde", "time-core", + "time-macros", ] [[package]] @@ -4700,6 +5205,16 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + [[package]] name = "tiny-keccak" version = "2.0.2" @@ -4726,9 +5241,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.37.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes", @@ -4743,13 +5258,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -4779,16 +5294,15 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] @@ -4814,9 +5328,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" dependencies = [ "serde", ] @@ -4827,7 +5341,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap", + "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", @@ -4836,11 +5350,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.7" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap", + "indexmap 2.2.6", "toml_datetime", "winnow", ] @@ -4870,7 +5384,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -4972,9 +5486,9 @@ dependencies = [ [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" [[package]] name = "unicode-xid" @@ -5100,7 +5614,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", "wasm-bindgen-shared", ] @@ -5134,7 +5648,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -5180,6 +5694,18 @@ version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + [[package]] name = "winapi" version = "0.3.9" @@ -5198,11 +5724,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -5423,29 +5949,29 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.32" +version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "zeroize_derive", ] @@ -5458,7 +5984,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.60", + "syn 2.0.66", ] [[package]] @@ -5496,11 +6022,11 @@ dependencies = [ "ethers-signers", "ff", "gadgets", - "halo2-base", - "halo2-ecc", + "halo2-base 0.2.2", + "halo2-ecc 0.2.2", "halo2-mpt-circuits", "halo2_gadgets", - "halo2_proofs", + "halo2_proofs 1.1.0", "hex", "itertools 0.11.0", "log", @@ -5519,8 +6045,8 @@ dependencies = [ "serde", "serde_json", "sha3 0.10.8", - "snark-verifier", - "snark-verifier-sdk", + "snark-verifier 0.1.0", + "snark-verifier-sdk 0.0.1", "strum 0.25.0", "strum_macros 0.25.3", "subtle", @@ -5529,7 +6055,7 @@ dependencies = [ [[package]] name = "zktrie" version = "0.3.0" -source = "git+https://github.com/scroll-tech/zktrie.git?branch=main#2a19ee2155ecb959ba518384e448a638ae9858f2" +source = "git+https://github.com/scroll-tech/zktrie.git?branch=main#23181f209e94137f74337b150179aeb80c72e7c8" dependencies = [ "gobuild", "zktrie_rust", @@ -5538,7 +6064,7 @@ dependencies = [ [[package]] name = "zktrie_rust" version = "0.3.0" -source = "git+https://github.com/scroll-tech/zktrie.git?branch=main#2a19ee2155ecb959ba518384e448a638ae9858f2" +source = "git+https://github.com/scroll-tech/zktrie.git?branch=main#23181f209e94137f74337b150179aeb80c72e7c8" dependencies = [ "hex", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index 7ae91e1c8f..1fc9ecaf98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,8 +58,8 @@ serde_stacker = "0.1" sha3 = "0.10" snark-verifier = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop" } snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"] } -aggregator-snark-verifier = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop", package = "snark-verifier" } -aggregator-snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"], package = "snark-verifier-sdk" } +aggregator-snark-verifier = { git = "https://github.com/axiom-crypto/snark-verifier", branch = "community-edition", package = "snark-verifier", default-features = false, features = ["loader_halo2", "halo2-pse", "loader_evm", "revm"] } +aggregator-snark-verifier-sdk = { git = "https://github.com/axiom-crypto/snark-verifier", branch = "community-edition", default-features = false, features = ["loader_halo2", "halo2-pse", "loader_evm", "revm"], package = "snark-verifier-sdk" } strum = "0.25" strum_macros = "0.25" subtle = "2.4" diff --git a/aggregator/Cargo.toml b/aggregator/Cargo.toml index 71b55742d0..68b62cb33a 100644 --- a/aggregator/Cargo.toml +++ b/aggregator/Cargo.toml @@ -21,9 +21,10 @@ once_cell.workspace = true serde.workspace = true serde_json.workspace = true rand.workspace = true -halo2-base.workspace = true -halo2-ecc.workspace = true -halo2_proofs.workspace = true +# halo2-base.workspace = true +# halo2-ecc.workspace = true +# halo2_proofs.workspace = true +halo2curves.workspace = true aggregator-snark-verifier.workspace = true aggregator-snark-verifier-sdk.workspace = true strum.workspace = true diff --git a/aggregator/src/aggregation/barycentric.rs b/aggregator/src/aggregation/barycentric.rs index 626cf95594..7742e96a7f 100644 --- a/aggregator/src/aggregation/barycentric.rs +++ b/aggregator/src/aggregation/barycentric.rs @@ -1,18 +1,18 @@ -use eth_types::{ToLittleEndian, U256}; -use halo2_base::{ - gates::{range::RangeConfig, GateInstructions}, - utils::{fe_to_biguint, modulus}, - AssignedValue, QuantumCell, -}; -use halo2_ecc::{ - bigint::{CRTInteger, OverflowInteger}, - fields::{fp::FpConfig, FieldChip}, - halo2_base::{utils::decompose_bigint_option, Context}, -}; -use halo2_proofs::{ - circuit::Value, - halo2curves::{bls12_381::Scalar, bn256::Fr, ff::PrimeField}, +use aggregator_snark_verifier::{ + halo2_base::{ + gates::{range::RangeConfig, GateInstructions}, + halo2_proofs::circuit::Value, + utils::{fe_to_biguint, modulus}, + AssignedValue, QuantumCell, + }, + halo2_ecc::{ + bigint::{CRTInteger, OverflowInteger}, + fields::{fp::FpConfig, FieldChip}, + halo2_base::{utils::decompose_bigint_option, Context}, + }, }; +use eth_types::{ToLittleEndian, U256}; +use halo2curves::{bls12_381::Scalar, bn256::Fr, ff::PrimeField}; use itertools::Itertools; use num_bigint::{BigInt, Sign}; use std::{iter::successors, sync::LazyLock}; @@ -50,7 +50,7 @@ pub static ROOTS_OF_UNITY: LazyLock> = LazyLock::new(|| { #[derive(Clone, Debug)] pub struct BarycentricEvaluationConfig { - pub scalar: FpConfig, + pub scalar: FpConfig, } #[derive(Default)] diff --git a/aggregator/src/aggregation/batch_data.rs b/aggregator/src/aggregation/batch_data.rs index e4ed3f993b..b095b19c70 100644 --- a/aggregator/src/aggregation/batch_data.rs +++ b/aggregator/src/aggregation/batch_data.rs @@ -1,11 +1,13 @@ -use ethers_core::utils::keccak256; -use halo2_ecc::bigint::CRTInteger; -use halo2_proofs::{ - circuit::{AssignedCell, Layouter, Region, Value}, - halo2curves::bn256::Fr, - plonk::{Advice, Column, ConstraintSystem, Error, Expression, SecondPhase, Selector}, - poly::Rotation, +use aggregator_snark_verifier::{ + halo2_base::halo2_proofs::{ + circuit::{AssignedCell, Layouter, Region, Value}, + halo2curves::bn256::Fr, + plonk::{Advice, Column, ConstraintSystem, Error, Expression, SecondPhase, Selector}, + poly::Rotation, + }, + halo2_ecc::bigint::CRTInteger, }; +use ethers_core::utils::keccak256; use itertools::Itertools; use zkevm_circuits::{ table::{KeccakTable, LookupTable, RangeTable, U8Table}, diff --git a/aggregator/src/aggregation/blob_data.rs b/aggregator/src/aggregation/blob_data.rs index ab60b14a4b..dc8e9f13e5 100644 --- a/aggregator/src/aggregation/blob_data.rs +++ b/aggregator/src/aggregation/blob_data.rs @@ -1,13 +1,15 @@ use std::io::Write; -use gadgets::util::Expr; -use halo2_ecc::bigint::CRTInteger; -use halo2_proofs::{ - circuit::{AssignedCell, Layouter, Region, Value}, - halo2curves::bn256::Fr, - plonk::{Advice, Column, ConstraintSystem, Error, Expression, SecondPhase, Selector}, - poly::Rotation, +use aggregator_snark_verifier::{ + halo2_base::halo2_proofs::{ + circuit::{AssignedCell, Layouter, Region, Value}, + halo2curves::bn256::Fr, + plonk::{Advice, Column, ConstraintSystem, Error, Expression, SecondPhase, Selector}, + poly::Rotation, + }, + halo2_ecc::bigint::CRTInteger, }; +use gadgets::util::Expr; use itertools::Itertools; use zkevm_circuits::{table::U8Table, util::Challenges}; diff --git a/aggregator/src/aggregation/circuit.rs b/aggregator/src/aggregation/circuit.rs index 8eb161e234..db3e4df531 100644 --- a/aggregator/src/aggregation/circuit.rs +++ b/aggregator/src/aggregation/circuit.rs @@ -1,12 +1,14 @@ use crate::{blob::BatchData, witgen::MultiBlockProcessResult}; -use ark_std::{end_timer, start_timer}; -use halo2_base::{Context, ContextParams}; -use halo2_proofs::{ - circuit::{Layouter, SimpleFloorPlanner, Value}, - halo2curves::bn256::{Bn256, Fr, G1Affine}, - plonk::{Circuit, ConstraintSystem, Error, Selector}, - poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, +use aggregator_snark_verifier::halo2_base::{ + halo2_proofs::{ + circuit::{Layouter, SimpleFloorPlanner, Value}, + halo2curves::bn256::{Bn256, Fr, G1Affine}, + plonk::{Circuit, ConstraintSystem, Error, Selector}, + poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, + }, + Context, }; +use ark_std::{end_timer, start_timer}; use itertools::Itertools; use rand::Rng; #[cfg(not(feature = "disable_proof_aggregation"))] @@ -14,18 +16,20 @@ use std::rc::Rc; use std::{env, fs::File}; #[cfg(not(feature = "disable_proof_aggregation"))] -use aggregator_snark_verifier::loader::halo2::halo2_ecc::halo2_base; +use aggregator_snark_verifier::halo2_base; use aggregator_snark_verifier::pcs::kzg::KzgSuccinctVerifyingKey; #[cfg(not(feature = "disable_proof_aggregation"))] use aggregator_snark_verifier::{ loader::halo2::{halo2_ecc::halo2_base::AssignedValue, Halo2Loader}, - pcs::kzg::{Bdfg21, Kzg}, + pcs::kzg::{Bdfg21, KzgAs}, }; #[cfg(not(feature = "disable_proof_aggregation"))] -use aggregator_snark_verifier_sdk::{aggregate, flatten_accumulator}; +use aggregator_snark_verifier_sdk::halo2::aggregation::aggregate; use aggregator_snark_verifier_sdk::{CircuitExt, Snark, SnarkWitness}; use zkevm_circuits::util::Challenges; +#[cfg(not(feature = "disable_proof_aggregation"))] +use crate::util::flatten_accumulator; use crate::{ aggregation::witgen::process, batch::BatchHash, @@ -120,6 +124,7 @@ impl AggregationCircuit { } impl Circuit for AggregationCircuit { + type Params = (); type Config = (AggregationConfig, Challenges); type FloorPlanner = SimpleFloorPlanner; fn without_witnesses(&self) -> Self { @@ -242,7 +247,7 @@ impl Circuit for AggregationCircuit { // instances from previous accumulators) // - new accumulator to be verified on chain // - let (assigned_aggregation_instances, acc) = aggregate::>( + let (assigned_aggregation_instances, acc) = aggregate::>( &self.svk, &loader, &self.snarks_with_padding, diff --git a/aggregator/src/aggregation/config.rs b/aggregator/src/aggregation/config.rs index 5671a7997e..a7918df50f 100644 --- a/aggregator/src/aggregation/config.rs +++ b/aggregator/src/aggregation/config.rs @@ -1,4 +1,8 @@ use aggregator_snark_verifier::{ + halo2_base::halo2_proofs::{ + halo2curves::bn256::{Fq, Fr, G1Affine}, + plonk::{Column, ConstraintSystem, Instance}, + }, loader::halo2::halo2_ecc::{ ecc::{BaseFieldEccChip, EccChip}, fields::fp::FpConfig, @@ -6,10 +10,6 @@ use aggregator_snark_verifier::{ }, util::arithmetic::modulus, }; -use halo2_proofs::{ - halo2curves::bn256::{Fq, Fr, G1Affine}, - plonk::{Column, ConstraintSystem, Instance}, -}; use zkevm_circuits::{ keccak_circuit::{KeccakCircuitConfig, KeccakCircuitConfigArgs}, table::{BitwiseOpTable, KeccakTable, Pow2Table, PowOfRandTable, RangeTable, U8Table}, @@ -29,7 +29,7 @@ use crate::{ /// This config is hard coded for BN256 curve. pub struct AggregationConfig { /// Non-native field chip configurations - pub base_field_config: FpConfig, + pub base_field_config: FpConfig, /// Keccak circuit configurations pub keccak_circuit_config: KeccakCircuitConfig, /// RLC config @@ -193,7 +193,7 @@ impl AggregationConfig { #[test] fn aggregation_circuit_degree() { - use halo2_ecc::fields::fp::FpStrategy; + use aggregator_snark_verifier::loader::halo2::halo2_ecc::fields::FpStrategy; let mut cs = ConstraintSystem::::default(); let param = ConfigParams { strategy: FpStrategy::Simple, diff --git a/aggregator/src/aggregation/decoder.rs b/aggregator/src/aggregation/decoder.rs index 6d1aed584d..d941c71ebf 100644 --- a/aggregator/src/aggregation/decoder.rs +++ b/aggregator/src/aggregation/decoder.rs @@ -2,22 +2,22 @@ mod seq_exec; mod tables; pub mod witgen; -use gadgets::{ - binary_number::{BinaryNumberChip, BinaryNumberConfig}, - comparator::{ComparatorChip, ComparatorConfig, ComparatorInstruction}, - is_equal::{IsEqualChip, IsEqualConfig, IsEqualInstruction}, - less_than::{LtChip, LtConfig, LtInstruction}, - util::{and, not, select, sum, Expr}, -}; -use halo2_proofs::{ +use aggregator_snark_verifier::halo2_base::halo2_proofs::{ arithmetic::Field, circuit::{AssignedCell, Layouter, Value}, - halo2curves::bn256::Fr, plonk::{ Advice, Column, ConstraintSystem, Error, Expression, Fixed, SecondPhase, VirtualCells, }, poly::Rotation, }; +use gadgets::{ + binary_number::{BinaryNumberChip, BinaryNumberConfig}, + comparator::{ComparatorChip, ComparatorConfig, ComparatorInstruction}, + is_equal::{IsEqualChip, IsEqualConfig, IsEqualInstruction}, + less_than::{LtChip, LtConfig, LtInstruction}, + util::{and, not, select, sum, Expr}, +}; +use halo2curves::bn256::Fr; use itertools::Itertools; use zkevm_circuits::{ evm_circuit::{BaseConstraintBuilder, ConstrainBuilderCommon}, @@ -5434,7 +5434,7 @@ mod tests { witgen::{init_zstd_encoder, process, MultiBlockProcessResult}, DecoderConfig, DecoderConfigArgs, }; - use halo2_proofs::{ + use aggregator_snark_verifier::halo2_base::halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner, Value}, dev::MockProver, halo2curves::bn256::Fr, @@ -5454,6 +5454,7 @@ mod tests { } impl Circuit for DecoderConfigTester { + type Params = (); type Config = (DecoderConfig, U8Table, Challenges); type FloorPlanner = SimpleFloorPlanner; diff --git a/aggregator/src/aggregation/decoder/seq_exec.rs b/aggregator/src/aggregation/decoder/seq_exec.rs index 6d68719bc5..aeccaea57f 100644 --- a/aggregator/src/aggregation/decoder/seq_exec.rs +++ b/aggregator/src/aggregation/decoder/seq_exec.rs @@ -1,11 +1,11 @@ -use gadgets::util::{and, not, select, Expr}; -use halo2_proofs::{ +use aggregator_snark_verifier::halo2_base::halo2_proofs::{ circuit::{AssignedCell, Layouter, Region, Value}, plonk::{ Advice, Any, Column, ConstraintSystem, Error, Expression, Fixed, SecondPhase, VirtualCells, }, poly::Rotation, }; +use gadgets::util::{and, not, select, Expr}; use itertools::Itertools; use tables::SeqInstTable; use witgen::{SequenceExec, SequenceExecInfo, SequenceInfo, ZstdTag}; @@ -1042,9 +1042,10 @@ impl SeqExecConfig { #[cfg(test)] mod tests { use super::*; - use halo2_proofs::{ - circuit::SimpleFloorPlanner, dev::MockProver, halo2curves::bn256::Fr, plonk::Circuit, + use aggregator_snark_verifier::halo2_base::halo2_proofs::{ + circuit::SimpleFloorPlanner, dev::MockProver, plonk::Circuit, }; + use halo2curves::bn256::Fr; use witgen::AddressTableRow; use zkevm_circuits::util::MockChallenges; @@ -1125,6 +1126,7 @@ mod tests { } impl Circuit for SeqExecMock { + type Params = (); type Config = SeqExecMockConfig; type FloorPlanner = SimpleFloorPlanner; fn without_witnesses(&self) -> Self { diff --git a/aggregator/src/aggregation/decoder/tables/bitstring.rs b/aggregator/src/aggregation/decoder/tables/bitstring.rs index e46ffb3f4f..75329a9e66 100644 --- a/aggregator/src/aggregation/decoder/tables/bitstring.rs +++ b/aggregator/src/aggregation/decoder/tables/bitstring.rs @@ -1,10 +1,10 @@ -use gadgets::util::{and, not, select, Expr}; -use halo2_proofs::{ +use aggregator_snark_verifier::halo2_base::halo2_proofs::{ circuit::{Layouter, Value}, - halo2curves::bn256::Fr, plonk::{Advice, Any, Column, ConstraintSystem, Error, Expression, Fixed}, poly::Rotation, }; +use gadgets::util::{and, not, select, Expr}; +use halo2curves::bn256::Fr; use zkevm_circuits::{ evm_circuit::{BaseConstraintBuilder, ConstrainBuilderCommon}, table::{LookupTable, RangeTable}, @@ -702,40 +702,40 @@ impl BitstringTable { } } -impl LookupTable for BitstringTable { - fn columns(&self) -> Vec> { - vec![ - self.byte_idx_1.into(), - self.byte_idx_2.into(), - self.byte_idx_3.into(), - self.byte_1.into(), - self.byte_2.into(), - self.byte_3.into(), - self.bitstring_value.into(), - self.bitstring_len.into(), - self.bit_index.into(), - self.from_start.column.into(), - self.until_end.column.into(), - self.is_reverse.column.into(), - self.is_padding.column.into(), - ] - } - - fn annotations(&self) -> Vec { - vec![ - String::from("byte_idx_1"), - String::from("byte_idx_2"), - String::from("byte_idx_3"), - String::from("byte_1"), - String::from("byte_2"), - String::from("byte_3"), - String::from("bitstring_value"), - String::from("bitstring_len"), - String::from("bit_index"), - String::from("from_start"), - String::from("until_end"), - String::from("is_reverse"), - String::from("is_padding"), - ] - } -} +// impl LookupTable for BitstringTable { +// fn columns(&self) -> Vec> { +// vec![ +// self.byte_idx_1.into(), +// self.byte_idx_2.into(), +// self.byte_idx_3.into(), +// self.byte_1.into(), +// self.byte_2.into(), +// self.byte_3.into(), +// self.bitstring_value.into(), +// self.bitstring_len.into(), +// self.bit_index.into(), +// self.from_start.column.into(), +// self.until_end.column.into(), +// self.is_reverse.column.into(), +// self.is_padding.column.into(), +// ] +// } + +// fn annotations(&self) -> Vec { +// vec![ +// String::from("byte_idx_1"), +// String::from("byte_idx_2"), +// String::from("byte_idx_3"), +// String::from("byte_1"), +// String::from("byte_2"), +// String::from("byte_3"), +// String::from("bitstring_value"), +// String::from("bitstring_len"), +// String::from("bit_index"), +// String::from("from_start"), +// String::from("until_end"), +// String::from("is_reverse"), +// String::from("is_padding"), +// ] +// } +// } diff --git a/aggregator/src/aggregation/decoder/tables/fixed.rs b/aggregator/src/aggregation/decoder/tables/fixed.rs index c07750aee1..3d8c969bad 100644 --- a/aggregator/src/aggregation/decoder/tables/fixed.rs +++ b/aggregator/src/aggregation/decoder/tables/fixed.rs @@ -1,10 +1,10 @@ -use eth_types::Field; -use gadgets::impl_expr; -use halo2_proofs::{ +use aggregator_snark_verifier::halo2_base::halo2_proofs::{ circuit::{Layouter, Value}, - halo2curves::bn256::Fr, - plonk::{Column, ConstraintSystem, Error, Expression, Fixed}, + plonk::{Any, Column, ConstraintSystem, Error, Expression, Fixed}, }; +use eth_types::Field; +// use gadgets::impl_expr; +use halo2curves::bn256::Fr; use itertools::Itertools; use strum::IntoEnumIterator; use strum_macros::EnumIter; @@ -61,7 +61,7 @@ pub enum FixedLookupTag { VariableBitPacking, } -impl_expr!(FixedLookupTag); +// impl_expr!(FixedLookupTag); impl FixedLookupTag { fn values(&self) -> Vec<[Value; 7]> { @@ -130,28 +130,28 @@ impl FixedTable { } } -impl LookupTable for FixedTable { - fn columns(&self) -> Vec> { - vec![ - self.lookup_tag.into(), - self.fixed1.into(), - self.fixed2.into(), - self.fixed3.into(), - self.fixed4.into(), - self.fixed5.into(), - self.fixed6.into(), - ] - } - - fn annotations(&self) -> Vec { - vec![ - String::from("lookup_tag"), - String::from("fixed1"), - String::from("fixed2"), - String::from("fixed3"), - String::from("fixed4"), - String::from("fixed5"), - String::from("fixed6"), - ] - } -} +// impl LookupTable for FixedTable { +// fn columns(&self) -> Vec> { +// vec![ +// self.lookup_tag.into(), +// self.fixed1.into(), +// self.fixed2.into(), +// self.fixed3.into(), +// self.fixed4.into(), +// self.fixed5.into(), +// self.fixed6.into(), +// ] +// } + +// fn annotations(&self) -> Vec { +// vec![ +// String::from("lookup_tag"), +// String::from("fixed1"), +// String::from("fixed2"), +// String::from("fixed3"), +// String::from("fixed4"), +// String::from("fixed5"), +// String::from("fixed6"), +// ] +// } +// } diff --git a/aggregator/src/aggregation/decoder/tables/fixed/fse_table_transition.rs b/aggregator/src/aggregation/decoder/tables/fixed/fse_table_transition.rs index 83a688c683..a44f6bf543 100644 --- a/aggregator/src/aggregation/decoder/tables/fixed/fse_table_transition.rs +++ b/aggregator/src/aggregation/decoder/tables/fixed/fse_table_transition.rs @@ -1,4 +1,5 @@ -use halo2_proofs::{circuit::Value, halo2curves::bn256::Fr}; +use aggregator_snark_verifier::halo2_base::halo2_proofs::circuit::Value; +use halo2curves::bn256::Fr; use super::{FixedLookupTag, FixedLookupValues}; diff --git a/aggregator/src/aggregation/decoder/tables/fixed/predefined_fse.rs b/aggregator/src/aggregation/decoder/tables/fixed/predefined_fse.rs index 12b7837db9..0c10057139 100644 --- a/aggregator/src/aggregation/decoder/tables/fixed/predefined_fse.rs +++ b/aggregator/src/aggregation/decoder/tables/fixed/predefined_fse.rs @@ -1,4 +1,5 @@ -use halo2_proofs::{circuit::Value, halo2curves::bn256::Fr}; +use aggregator_snark_verifier::halo2_base::halo2_proofs::circuit::Value; +use halo2curves::bn256::Fr; use crate::aggregation::decoder::witgen::FseTableKind; diff --git a/aggregator/src/aggregation/decoder/tables/fixed/seq_code_to_value.rs b/aggregator/src/aggregation/decoder/tables/fixed/seq_code_to_value.rs index 819511f7ca..1063cdb2f0 100644 --- a/aggregator/src/aggregation/decoder/tables/fixed/seq_code_to_value.rs +++ b/aggregator/src/aggregation/decoder/tables/fixed/seq_code_to_value.rs @@ -1,4 +1,5 @@ -use halo2_proofs::{circuit::Value, halo2curves::bn256::Fr}; +use aggregator_snark_verifier::halo2_base::halo2_proofs::circuit::Value; +use halo2curves::bn256::Fr; use crate::aggregation::decoder::witgen::FseTableKind; diff --git a/aggregator/src/aggregation/decoder/tables/fixed/seq_data_interleaved_order.rs b/aggregator/src/aggregation/decoder/tables/fixed/seq_data_interleaved_order.rs index 932e236870..a7f6e62181 100644 --- a/aggregator/src/aggregation/decoder/tables/fixed/seq_data_interleaved_order.rs +++ b/aggregator/src/aggregation/decoder/tables/fixed/seq_data_interleaved_order.rs @@ -1,4 +1,5 @@ -use halo2_proofs::{circuit::Value, halo2curves::bn256::Fr}; +use aggregator_snark_verifier::halo2_base::halo2_proofs::circuit::Value; +use halo2curves::bn256::Fr; use crate::aggregation::decoder::{ tables::fixed::{FixedLookupTag, FixedLookupValues}, diff --git a/aggregator/src/aggregation/decoder/tables/fixed/seq_tag_order.rs b/aggregator/src/aggregation/decoder/tables/fixed/seq_tag_order.rs index c41994bf43..e5fe43f0b0 100644 --- a/aggregator/src/aggregation/decoder/tables/fixed/seq_tag_order.rs +++ b/aggregator/src/aggregation/decoder/tables/fixed/seq_tag_order.rs @@ -1,4 +1,5 @@ -use halo2_proofs::{circuit::Value, halo2curves::bn256::Fr}; +use aggregator_snark_verifier::halo2_base::halo2_proofs::circuit::Value; +use halo2curves::bn256::Fr; use crate::aggregation::decoder::{ tables::fixed::FixedLookupTag, diff --git a/aggregator/src/aggregation/decoder/tables/fixed/tag_transition.rs b/aggregator/src/aggregation/decoder/tables/fixed/tag_transition.rs index 3e90910e7a..a7b05438fc 100644 --- a/aggregator/src/aggregation/decoder/tables/fixed/tag_transition.rs +++ b/aggregator/src/aggregation/decoder/tables/fixed/tag_transition.rs @@ -1,4 +1,5 @@ -use halo2_proofs::{circuit::Value, halo2curves::bn256::Fr}; +use aggregator_snark_verifier::halo2_base::halo2_proofs::circuit::Value; +use halo2curves::bn256::Fr; use crate::aggregation::decoder::{tables::fixed::FixedLookupTag, witgen::ZstdTag}; diff --git a/aggregator/src/aggregation/decoder/tables/fixed/variable_bit_packing.rs b/aggregator/src/aggregation/decoder/tables/fixed/variable_bit_packing.rs index f882310338..a635932b47 100644 --- a/aggregator/src/aggregation/decoder/tables/fixed/variable_bit_packing.rs +++ b/aggregator/src/aggregation/decoder/tables/fixed/variable_bit_packing.rs @@ -1,4 +1,5 @@ -use halo2_proofs::{circuit::Value, halo2curves::bn256::Fr}; +use aggregator_snark_verifier::halo2_base::halo2_proofs::circuit::Value; +use halo2curves::bn256::Fr; use crate::aggregation::decoder::witgen::util::bit_length; diff --git a/aggregator/src/aggregation/decoder/tables/fse.rs b/aggregator/src/aggregation/decoder/tables/fse.rs index f6dba39e73..7cbfc2ff41 100644 --- a/aggregator/src/aggregation/decoder/tables/fse.rs +++ b/aggregator/src/aggregation/decoder/tables/fse.rs @@ -1,13 +1,13 @@ +use aggregator_snark_verifier::halo2_base::halo2_proofs::{ + circuit::{Layouter, Value}, + plonk::{Advice, Any, Column, ConstraintSystem, Error, Expression, Fixed, VirtualCells}, + poly::Rotation, +}; use gadgets::{ is_equal::{IsEqualChip, IsEqualConfig, IsEqualInstruction}, util::{and, not, select, Expr}, }; -use halo2_proofs::{ - circuit::{Layouter, Value}, - halo2curves::bn256::Fr, - plonk::{Advice, Column, ConstraintSystem, Error, Expression, Fixed, VirtualCells}, - poly::Rotation, -}; +use halo2curves::bn256::Fr; use itertools::Itertools; use zkevm_circuits::{ evm_circuit::{BaseConstraintBuilder, ConstrainBuilderCommon}, @@ -1820,32 +1820,32 @@ impl FseSortedStatesTable { } } -impl LookupTable for FseSortedStatesTable { - fn columns(&self) -> Vec> { - vec![ - self.block_idx.into(), - self.table_kind.into(), - self.table_size.into(), - self.symbol.into(), - self.symbol_count.into(), - self.state.into(), - self.baseline.into(), - self.nb.into(), - self.is_padding.column.into(), - ] - } - - fn annotations(&self) -> Vec { - vec![ - String::from("block_idx"), - String::from("table_kind"), - String::from("table_size"), - String::from("symbol"), - String::from("symbol_count"), - String::from("state"), - String::from("baseline"), - String::from("nb"), - String::from("is_padding"), - ] - } -} +// impl LookupTable for FseSortedStatesTable { +// fn columns(&self) -> Vec> { +// vec![ +// self.block_idx.into(), +// self.table_kind.into(), +// self.table_size.into(), +// self.symbol.into(), +// self.symbol_count.into(), +// self.state.into(), +// self.baseline.into(), +// self.nb.into(), +// self.is_padding.column.into(), +// ] +// } + +// fn annotations(&self) -> Vec { +// vec![ +// String::from("block_idx"), +// String::from("table_kind"), +// String::from("table_size"), +// String::from("symbol"), +// String::from("symbol_count"), +// String::from("state"), +// String::from("baseline"), +// String::from("nb"), +// String::from("is_padding"), +// ] +// } +// } diff --git a/aggregator/src/aggregation/decoder/tables/literals_header.rs b/aggregator/src/aggregation/decoder/tables/literals_header.rs index 142d89c2e2..a382e67f7b 100644 --- a/aggregator/src/aggregation/decoder/tables/literals_header.rs +++ b/aggregator/src/aggregation/decoder/tables/literals_header.rs @@ -1,11 +1,11 @@ -use eth_types::Field; -use gadgets::util::{and, not, select, Expr}; -use halo2_proofs::{ +use aggregator_snark_verifier::halo2_base::halo2_proofs::{ circuit::{Layouter, Value}, - halo2curves::bn256::Fr, plonk::{Advice, Any, Column, ConstraintSystem, Error, Fixed}, poly::Rotation, }; +use eth_types::Field; +use gadgets::util::{and, not, select, Expr}; +use halo2curves::bn256::Fr; use zkevm_circuits::{ evm_circuit::{BaseConstraintBuilder, ConstrainBuilderCommon}, table::{LookupTable, RangeTable}, @@ -277,31 +277,31 @@ impl LiteralsHeaderTable { } } -impl LookupTable for LiteralsHeaderTable { - fn columns(&self) -> Vec> { - vec![ - self.block_idx.into(), - self.byte0.into(), - self.byte1.into(), - self.byte2.into(), - self.size_format_bit0.into(), - self.size_format_bit1.into(), - self.regen_size.into(), - self.is_padding.column.into(), - ] - } - - fn annotations(&self) -> Vec { - vec![ - String::from("block_idx"), - String::from("byte_offset"), - String::from("byte0"), - String::from("byte1"), - String::from("byte2"), - String::from("size_format_bit0"), - String::from("size_format_bit1"), - String::from("regen_size"), - String::from("is_padding"), - ] - } -} +// impl LookupTable for LiteralsHeaderTable { +// fn columns(&self) -> Vec> { +// vec![ +// self.block_idx.into(), +// self.byte0.into(), +// self.byte1.into(), +// self.byte2.into(), +// self.size_format_bit0.into(), +// self.size_format_bit1.into(), +// self.regen_size.into(), +// self.is_padding.column.into(), +// ] +// } + +// fn annotations(&self) -> Vec { +// vec![ +// String::from("block_idx"), +// String::from("byte_offset"), +// String::from("byte0"), +// String::from("byte1"), +// String::from("byte2"), +// String::from("size_format_bit0"), +// String::from("size_format_bit1"), +// String::from("regen_size"), +// String::from("is_padding"), +// ] +// } +// } diff --git a/aggregator/src/aggregation/decoder/tables/seqinst_table.rs b/aggregator/src/aggregation/decoder/tables/seqinst_table.rs index bf567e9195..599028db45 100644 --- a/aggregator/src/aggregation/decoder/tables/seqinst_table.rs +++ b/aggregator/src/aggregation/decoder/tables/seqinst_table.rs @@ -1,13 +1,13 @@ +use aggregator_snark_verifier::halo2_base::halo2_proofs::{ + circuit::{Layouter, Region, Value}, + plonk::{Advice, Any, Column, ConstraintSystem, Error, Expression, Fixed, VirtualCells}, + poly::Rotation, +}; use gadgets::{ is_equal::*, is_zero::*, util::{and, not, select, Expr}, }; -use halo2_proofs::{ - circuit::{Layouter, Region, Value}, - plonk::{Advice, Any, Column, ConstraintSystem, Error, Expression, Fixed, VirtualCells}, - poly::Rotation, -}; use zkevm_circuits::{ evm_circuit::{BaseConstraintBuilder, ConstrainBuilderCommon}, table::LookupTable, @@ -126,33 +126,33 @@ pub struct SeqInstTable { ref_offset_1_is_zero: IsZeroConfig, } -impl LookupTable for SeqInstTable { - fn columns(&self) -> Vec> { - vec![ - self.q_enabled.into(), - self.block_index.into(), - self.n_seq.into(), - self.s_beginning.column.into(), - self.seq_index.into(), - self.literal_len.into(), - self.match_offset.into(), - self.match_len.into(), - ] - } - - fn annotations(&self) -> Vec { - vec![ - String::from("q_enabled"), - String::from("n_seq"), - String::from("block_index"), - String::from("s_beginning"), - String::from("seq_index"), - String::from("literal_len"), - String::from("match_offset"), - String::from("match_len"), - ] - } -} +// impl LookupTable for SeqInstTable { +// fn columns(&self) -> Vec> { +// vec![ +// self.q_enabled.into(), +// self.block_index.into(), +// self.n_seq.into(), +// self.s_beginning.column.into(), +// self.seq_index.into(), +// self.literal_len.into(), +// self.match_offset.into(), +// self.match_len.into(), +// ] +// } + +// fn annotations(&self) -> Vec { +// vec![ +// String::from("q_enabled"), +// String::from("n_seq"), +// String::from("block_index"), +// String::from("s_beginning"), +// String::from("seq_index"), +// String::from("literal_len"), +// String::from("match_offset"), +// String::from("match_len"), +// ] +// } +// } #[derive(Clone, Debug)] struct ChipContext { @@ -993,14 +993,16 @@ impl SeqInstTable { #[cfg(test)] mod tests { use super::*; - use halo2_proofs::{ - circuit::SimpleFloorPlanner, dev::MockProver, halo2curves::bn256::Fr, plonk::Circuit, + use aggregator_snark_verifier::halo2_base::halo2_proofs::{ + circuit::SimpleFloorPlanner, dev::MockProver, plonk::Circuit, }; + use halo2curves::bn256::Fr; #[derive(Clone, Debug)] struct SeqTable(Vec); impl Circuit for SeqTable { + type Params = (); type Config = SeqInstTable; type FloorPlanner = SimpleFloorPlanner; fn without_witnesses(&self) -> Self { diff --git a/aggregator/src/aggregation/decoder/witgen.rs b/aggregator/src/aggregation/decoder/witgen.rs index bda688e465..ecd5f7430a 100644 --- a/aggregator/src/aggregation/decoder/witgen.rs +++ b/aggregator/src/aggregation/decoder/witgen.rs @@ -1,5 +1,5 @@ +use aggregator_snark_verifier::halo2_base::halo2_proofs::circuit::Value; use eth_types::Field; -use halo2_proofs::circuit::Value; use revm_precompile::HashMap; mod params; @@ -1860,7 +1860,7 @@ mod tests { #[test] fn test_zstd_witness_processing_batch_data() -> Result<(), std::io::Error> { use super::*; - use halo2_proofs::halo2curves::bn256::Fr; + use aggregator_snark_verifier::halo2_base::halo2_proofs::halo2curves::bn256::Fr; let mut batch_files = fs::read_dir("./data/test_batches")? .map(|entry| entry.map(|e| e.path())) diff --git a/aggregator/src/aggregation/decoder/witgen/types.rs b/aggregator/src/aggregation/decoder/witgen/types.rs index 0bd3af5535..1781e993f1 100644 --- a/aggregator/src/aggregation/decoder/witgen/types.rs +++ b/aggregator/src/aggregation/decoder/witgen/types.rs @@ -1,9 +1,10 @@ use std::{collections::BTreeMap, io::Cursor}; +use crate::aggregation::decoder::Expression; +use aggregator_snark_verifier::halo2_base::halo2_proofs::circuit::Value; use bitstream_io::{BitRead, BitReader, LittleEndian}; use eth_types::Field; -use gadgets::impl_expr; -use halo2_proofs::{circuit::Value, plonk::Expression}; +// use gadgets::impl_expr; use itertools::Itertools; use std::collections::HashMap; use strum_macros::EnumIter; @@ -91,7 +92,7 @@ impl From for LstreamNum { } } -impl_expr!(LstreamNum); +// impl_expr!(LstreamNum); /// Various tags that we can decode from a zstd encoded data. #[derive(Clone, Copy, Debug, EnumIter, PartialEq, Eq, Hash)] @@ -165,7 +166,7 @@ impl ZstdTag { } } -impl_expr!(ZstdTag); +// impl_expr!(ZstdTag); impl From for usize { fn from(value: ZstdTag) -> Self { @@ -185,7 +186,7 @@ pub enum FseTableKind { MLT, } -impl_expr!(FseTableKind); +// impl_expr!(FseTableKind); impl ToString for ZstdTag { fn to_string(&self) -> String { diff --git a/aggregator/src/aggregation/rlc/config.rs b/aggregator/src/aggregation/rlc/config.rs index 2922eec2f2..0c18c76ef0 100644 --- a/aggregator/src/aggregation/rlc/config.rs +++ b/aggregator/src/aggregation/rlc/config.rs @@ -1,11 +1,11 @@ -use halo2_proofs::{ +use aggregator_snark_verifier::halo2_base::halo2_proofs::{ halo2curves::bn256::Fr, plonk::{Advice, Column, ConstraintSystem, Fixed, SecondPhase, Selector}, poly::Rotation, }; #[cfg(test)] -use halo2_proofs::plonk::FirstPhase; +use aggregator_snark_verifier::halo2_base::halo2_proofs::plonk::FirstPhase; use itertools::Itertools; use zkevm_circuits::{ table::{KeccakTable, LookupTable}, diff --git a/aggregator/src/aggregation/rlc/gates.rs b/aggregator/src/aggregation/rlc/gates.rs index 1527fd1418..bf05e6e245 100644 --- a/aggregator/src/aggregation/rlc/gates.rs +++ b/aggregator/src/aggregation/rlc/gates.rs @@ -1,10 +1,10 @@ -use ethers_core::utils::keccak256; -use halo2_proofs::{ +use aggregator_snark_verifier::halo2_base::halo2_proofs::{ arithmetic::Field, circuit::{AssignedCell, Cell, Region, RegionIndex, Value}, halo2curves::bn256::Fr, plonk::Error, }; +use ethers_core::utils::keccak256; use zkevm_circuits::util::Challenges; // TODO: remove MAX_AGG_SNARKS and make this generic over N_SNARKS diff --git a/aggregator/src/aggregation/util.rs b/aggregator/src/aggregation/util.rs index 95ff9061f0..3333a64853 100644 --- a/aggregator/src/aggregation/util.rs +++ b/aggregator/src/aggregation/util.rs @@ -1,8 +1,8 @@ -use gadgets::util::Expr; -use halo2_proofs::{ +use aggregator_snark_verifier::halo2_base::halo2_proofs::{ plonk::{Advice, Column, ConstraintSystem, Expression, VirtualCells}, poly::Rotation, }; +use gadgets::util::Expr; use zkevm_circuits::util::Field; #[derive(Clone, Copy, Debug)] diff --git a/aggregator/src/blob.rs b/aggregator/src/blob.rs index b1c33570f5..35510de247 100644 --- a/aggregator/src/blob.rs +++ b/aggregator/src/blob.rs @@ -3,15 +3,13 @@ use crate::{ BatchHash, ChunkHash, }; +use aggregator_snark_verifier::halo2_base::halo2_proofs::circuit::Value; use eth_types::{ToBigEndian, H256, U256}; use ethers_core::{ k256::sha2::{Digest, Sha256}, utils::keccak256, }; -use halo2_proofs::{ - circuit::Value, - halo2curves::{bls12_381::Scalar, bn256::Fr}, -}; +use halo2curves::{bls12_381::Scalar, bn256::Fr}; use itertools::Itertools; use once_cell::sync::Lazy; use revm_primitives::VERSIONED_HASH_VERSION_KZG; diff --git a/aggregator/src/compression/circuit.rs b/aggregator/src/compression/circuit.rs index f7dbc2a47a..242d247a34 100644 --- a/aggregator/src/compression/circuit.rs +++ b/aggregator/src/compression/circuit.rs @@ -3,6 +3,11 @@ use std::fs::File; use aggregator_snark_verifier::{ + halo2_base::halo2_proofs::{ + circuit::{Cell, Layouter, SimpleFloorPlanner, Value}, + halo2curves::bn256::G1Affine, + plonk::{Circuit, ConstraintSystem, Error}, + }, loader::halo2::{ halo2_ecc::{ halo2_base, @@ -16,20 +21,19 @@ use aggregator_snark_verifier::{ }, Halo2Loader, }, - pcs::kzg::{Bdfg21, Kzg, KzgSuccinctVerifyingKey}, + pcs::kzg::{Bdfg21, KzgAs, KzgSuccinctVerifyingKey}, }; use aggregator_snark_verifier_sdk::{ - aggregate, flatten_accumulator, types::Svk, Snark, SnarkWitness, + halo2::aggregation::{aggregate, Svk}, + Snark, SnarkWitness, }; use ark_std::{end_timer, start_timer}; -use halo2_proofs::{ - circuit::{Cell, Layouter, SimpleFloorPlanner, Value}, - halo2curves::bn256::G1Affine, - plonk::{Circuit, ConstraintSystem, Error}, -}; use rand::Rng; -use crate::{core::extract_proof_and_instances_with_pairing_check, param::ConfigParams, ACC_LEN}; +use crate::{ + core::extract_proof_and_instances_with_pairing_check, param::ConfigParams, + util::flatten_accumulator, ACC_LEN, +}; use super::config::CompressionConfig; @@ -53,6 +57,7 @@ pub struct CompressionCircuit { } impl Circuit for CompressionCircuit { + type Params = (); type Config = CompressionConfig; type FloorPlanner = SimpleFloorPlanner; @@ -126,7 +131,7 @@ impl Circuit for CompressionCircuit { let ecc_chip = config.ecc_chip(); let loader = Halo2Loader::new(ecc_chip, ctx); - let (assigned_instances, acc) = aggregate::>( + let (assigned_instances, acc) = aggregate::>( &self.svk, &loader, &[self.snark.clone()], diff --git a/aggregator/src/compression/circuit_ext.rs b/aggregator/src/compression/circuit_ext.rs index cb1a571a31..dc7bd827fb 100644 --- a/aggregator/src/compression/circuit_ext.rs +++ b/aggregator/src/compression/circuit_ext.rs @@ -1,7 +1,9 @@ //! CircuitExt implementation for compression circuit. +use aggregator_snark_verifier::halo2_base::halo2_proofs::{ + halo2curves::bn256::Fr, plonk::Selector, +}; use aggregator_snark_verifier_sdk::CircuitExt; -use halo2_proofs::{halo2curves::bn256::Fr, plonk::Selector}; use crate::ACC_LEN; diff --git a/aggregator/src/compression/config.rs b/aggregator/src/compression/config.rs index f75eb6de05..111483d63f 100644 --- a/aggregator/src/compression/config.rs +++ b/aggregator/src/compression/config.rs @@ -1,14 +1,16 @@ -use aggregator_snark_verifier::loader::halo2::halo2_ecc::{ - ecc::{BaseFieldEccChip, EccChip}, - fields::fp::FpConfig, - halo2_base::{ - gates::{flex_gate::FlexGateConfig, range::RangeConfig}, - utils::modulus, +use aggregator_snark_verifier::{ + halo2_base::halo2_proofs::{ + halo2curves::bn256::{Fq, Fr, G1Affine}, + plonk::{Column, ConstraintSystem, Instance}, + }, + loader::halo2::halo2_ecc::{ + ecc::{BaseFieldEccChip, EccChip}, + fields::fp::FpConfig, + halo2_base::{ + gates::{flex_gate::FlexGateConfig, range::RangeConfig}, + utils::modulus, + }, }, -}; -use halo2_proofs::{ - halo2curves::bn256::{Fq, Fr, G1Affine}, - plonk::{Column, ConstraintSystem, Instance}, }; use crate::{ @@ -21,7 +23,7 @@ use crate::{ /// This config is hard coded for BN256 curve pub struct CompressionConfig { /// Non-native field chip configurations - pub base_field_config: FpConfig, + pub base_field_config: FpConfig, /// Instance for public input pub instance: Column, } diff --git a/aggregator/src/core.rs b/aggregator/src/core.rs index a4e9472f8e..6fe48a6b97 100644 --- a/aggregator/src/core.rs +++ b/aggregator/src/core.rs @@ -1,29 +1,28 @@ use std::iter::repeat; use aggregator_snark_verifier::{ + halo2_base::halo2_proofs::{ + circuit::{AssignedCell, Layouter, Region, Value}, + halo2curves::{ + bn256::{Bn256, Fq, Fr, G1Affine, G2Affine}, + pairing::Engine, + }, + poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, + }, loader::native::NativeLoader, pcs::{ - kzg::{Bdfg21, Kzg, KzgAccumulator, KzgAs}, + kzg::{Bdfg21, KzgAccumulator, KzgAs}, AccumulationSchemeProver, }, util::arithmetic::fe_to_limbs, - verifier::PlonkVerifier, Error, }; use aggregator_snark_verifier_sdk::{ - types::{PoseidonTranscript, Shplonk, POSEIDON_SPEC}, - Snark, + halo2::{PoseidonTranscript, Shplonk, POSEIDON_SPEC}, + PlonkVerifier, Snark, }; use ark_std::{end_timer, start_timer}; use ethers_core::utils::keccak256; -use halo2_proofs::{ - circuit::{AssignedCell, Layouter, Region, Value}, - halo2curves::{ - bn256::{Bn256, Fq, Fr, G1Affine, G2Affine}, - pairing::Engine, - }, - poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, -}; use itertools::Itertools; use rand::Rng; use zkevm_circuits::{ @@ -95,7 +94,7 @@ pub(crate) fn extract_accumulators_and_proof( // accumulated ec_pt = ec_pt_1 * 1 + ec_pt_2 * r + ... + ec_pt_n * r^{n-1} // ec_pt can be lhs and rhs // r is the challenge squeezed from proof - KzgAs::>::create_proof::>, _>( + KzgAs::::create_proof::>, _>( &Default::default(), &accumulators, &mut transcript_write, @@ -172,7 +171,7 @@ impl ExtractedHashCells { chunk_is_valid_cell32s: &[AssignedCell], num_valid_snarks: AssignedCell, chunks_are_padding: Vec>, - ) -> Result { + ) -> Result { let mut inputs = vec![]; let mut input_rlcs = vec![]; let mut outputs = vec![]; @@ -285,7 +284,7 @@ impl ExtractedHashCells { plonk_config: &RlcConfig, region: &mut Region, offset: &mut usize, - ) -> Result<(), halo2_proofs::plonk::Error> { + ) -> Result<(), Error> { for (input_rlcs, (output_rlcs, data_len)) in self .input_rlcs .iter() @@ -465,7 +464,7 @@ fn copy_constraints( layouter .assign_region( || "copy constraints", - |mut region| -> Result<(), halo2_proofs::plonk::Error> { + |mut region| -> Result<(), Error> { if is_first_time { // this region only use copy constraints and do not affect the shape of the // layouter @@ -617,7 +616,7 @@ pub(crate) fn conditional_constraints( layouter .assign_region( || "rlc conditional constraints", - |mut region| -> Result, halo2_proofs::plonk::Error> { + |mut region| -> Result, Error> { let mut offset = 0; rlc_config.init(&mut region)?; // ==================================================== @@ -631,14 +630,14 @@ pub(crate) fn conditional_constraints( let chunk_is_valid_cells = chunks_are_valid .iter() - .map(|chunk_is_valid| -> Result<_, halo2_proofs::plonk::Error> { + .map(|chunk_is_valid| -> Result<_, Error> { rlc_config.load_private( &mut region, &Fr::from(*chunk_is_valid as u64), &mut offset, ) }) - .collect::, halo2_proofs::plonk::Error>>()?; + .collect::, Error>>()?; let chunk_is_valid_cell32s = chunk_is_valid_cells .iter() @@ -649,7 +648,7 @@ pub(crate) fn conditional_constraints( let chunks_are_padding = chunk_is_valid_cells .iter() .map(|chunk_is_valid| rlc_config.not(&mut region, chunk_is_valid, &mut offset)) - .collect::, halo2_proofs::plonk::Error>>()?; + .collect::, Error>>()?; let num_valid_snarks = constrain_flags(rlc_config, &mut region, &chunk_is_valid_cells, &mut offset)?; @@ -874,7 +873,7 @@ fn constrain_flags( region: &mut Region, chunk_are_valid: &[AssignedCell], offset: &mut usize, -) -> Result, halo2_proofs::plonk::Error> { +) -> Result, Error> { assert!(!chunk_are_valid.is_empty()); let one = { diff --git a/aggregator/src/param.rs b/aggregator/src/param.rs index 666926f2c6..4f85bf5f4a 100644 --- a/aggregator/src/param.rs +++ b/aggregator/src/param.rs @@ -1,4 +1,4 @@ -use aggregator_snark_verifier::loader::halo2::halo2_ecc::fields::fp::FpStrategy; +use aggregator_snark_verifier::loader::halo2::halo2_ecc::fields::FpStrategy; use crate::{BITS, LIMBS}; diff --git a/aggregator/src/tests.rs b/aggregator/src/tests.rs index 88fdb10710..143cc3d0c3 100644 --- a/aggregator/src/tests.rs +++ b/aggregator/src/tests.rs @@ -27,11 +27,11 @@ macro_rules! layer_0 { gen_snark_shplonk(¶m, &pk, $circuit.clone(), &mut rng, None::).unwrap(); log::trace!("finished layer 0 snark generation for circuit"); - assert!(verify_snark_shplonk::<$circuit_type>( - ¶m, - snark.clone(), - pk.get_vk() - )); + // assert!(verify_snark_shplonk::<$circuit_type>( + // ¶m, + // snark.clone(), + // pk.get_vk() + // )); log::trace!("finished layer 0 snark verification"); log::trace!("proof size: {}", snark.proof.len()); @@ -82,11 +82,11 @@ macro_rules! compression_layer_snark { $layer_index ); - assert!(verify_snark_shplonk::( - ¶m, - snark.clone(), - pk.get_vk() - )); + // assert!(verify_snark_shplonk::( + // ¶m, + // snark.clone(), + // pk.get_vk() + // )); end_timer!(timer); snark @@ -126,7 +126,7 @@ macro_rules! compression_layer_evm { log::trace!("proof size: {}", proof.len()); // verify proof via EVM - let deployment_code = gen_evm_verifier::>( + let deployment_code = gen_evm_verifier::>( ¶m, pk.get_vk(), compression_circuit.num_instance(), @@ -180,11 +180,11 @@ macro_rules! aggregation_layer_snark { $layer_index ); - assert!(verify_snark_shplonk::( - ¶m, - snark.clone(), - pk.get_vk() - )); + // assert!(verify_snark_shplonk::( + // ¶m, + // snark.clone(), + // pk.get_vk() + // )); end_timer!(timer); snark diff --git a/aggregator/src/tests/aggregation.rs b/aggregator/src/tests/aggregation.rs index 59962e9588..ca60f882cc 100644 --- a/aggregator/src/tests/aggregation.rs +++ b/aggregator/src/tests/aggregation.rs @@ -1,9 +1,11 @@ use std::{fs, path::Path, process}; -use aggregator_snark_verifier::loader::halo2::halo2_ecc::halo2_base::utils::fs::gen_srs; -use aggregator_snark_verifier_sdk::{gen_pk, gen_snark_shplonk, verify_snark_shplonk, CircuitExt}; +use aggregator_snark_verifier::{ + halo2_base::halo2_proofs::{dev::MockProver, halo2curves::bn256::Fr, poly::commitment::Params}, + loader::halo2::halo2_ecc::halo2_base::utils::fs::gen_srs, +}; +use aggregator_snark_verifier_sdk::{gen_pk, halo2::gen_snark_shplonk, CircuitExt}; use ark_std::{end_timer, start_timer, test_rng}; -use halo2_proofs::{dev::MockProver, halo2curves::bn256::Fr, poly::commitment::Params}; use itertools::Itertools; use crate::{ @@ -89,11 +91,11 @@ fn test_aggregation_circuit_full() { let snark = gen_snark_shplonk(¶m, &pk, circuit.clone(), &mut rng, None::).unwrap(); log::trace!("finished snark generation for circuit"); - assert!(verify_snark_shplonk::>( - ¶m, - snark, - pk.get_vk() - )); + // assert!(verify_snark_shplonk::>( + // ¶m, + // snark, + // pk.get_vk() + // )); log::trace!("finished verification for circuit"); // This set up requires two rounds of keccak for chunk's data hash @@ -101,11 +103,11 @@ fn test_aggregation_circuit_full() { let snark = gen_snark_shplonk(¶m, &pk, circuit, &mut rng, None::).unwrap(); log::trace!("finished snark generation for circuit"); - assert!(verify_snark_shplonk::>( - ¶m, - snark, - pk.get_vk() - )); + // assert!(verify_snark_shplonk::>( + // ¶m, + // snark, + // pk.get_vk() + // )); log::trace!("finished verification for circuit"); } diff --git a/aggregator/src/tests/blob.rs b/aggregator/src/tests/blob.rs index abeeddee51..9615fa6f5f 100644 --- a/aggregator/src/tests/blob.rs +++ b/aggregator/src/tests/blob.rs @@ -6,15 +6,16 @@ use crate::{ param::ConfigParams, BatchDataConfig, MAX_AGG_SNARKS, }; -use halo2_base::{ - gates::range::{RangeConfig, RangeStrategy}, - Context, ContextParams, -}; -use halo2_proofs::{ - circuit::{AssignedCell, Layouter, Region, SimpleFloorPlanner, Value}, - dev::{MockProver, VerifyFailure}, - halo2curves::bn256::Fr, - plonk::{Circuit, ConstraintSystem, Error}, +use aggregator_snark_verifier::halo2_base::{ + gates::range::{RangeConfig}, + gates::flex_gate::FlexGateConfigParams, + halo2_proofs::{ + circuit::{AssignedCell, Layouter, Region, SimpleFloorPlanner, Value}, + dev::{MockProver, VerifyFailure}, + halo2curves::bn256::Fr, + plonk::{Circuit, ConstraintSystem, Error}, + }, + Context, SKIP_FIRST_PASS, }; use zkevm_circuits::{ table::{KeccakTable, RangeTable, U8Table}, @@ -49,6 +50,7 @@ struct BlobConfig { } impl Circuit for BlobCircuit { + type Params = (); type Config = BlobConfig; type FloorPlanner = SimpleFloorPlanner; fn without_witnesses(&self) -> Self { @@ -66,14 +68,15 @@ impl Circuit for BlobCircuit { let parameters = ConfigParams::aggregation_param(); let range = RangeConfig::::configure( meta, - RangeStrategy::Vertical, - ¶meters.num_advice, + FlexGateConfigParams { + k: 21, + num_advice_per_phase: parameters.num_advice.clone(), + num_fixed: parameters.num_fixed, + }, ¶meters.num_lookup_advice, - parameters.num_fixed, parameters.lookup_bits, - 0, - parameters.degree.try_into().unwrap(), ); + let barycentric = BarycentricEvaluationConfig::construct(range); let challenge_expressions = challenges.exprs(meta); @@ -109,7 +112,7 @@ impl Circuit for BlobCircuit { .keccak_table .dev_load(&mut layouter, &self.data.preimages(), &challenge_values)?; - let mut first_pass = halo2_base::SKIP_FIRST_PASS; + let mut first_pass = SKIP_FIRST_PASS; let barycentric_assignments = layouter.assign_region( || "barycentric config", |region| -> Result { @@ -119,7 +122,15 @@ impl Circuit for BlobCircuit { } let gate = &config.barycentric.scalar.range.gate; + + let core_manager = MultiPhaseCoreManager::new(false); + let mut ctx = core_manager. let mut ctx = Context::new( + false, // witness_gen_only: bool, + 1, // phase: usize, + "asdfasdfasdf", // type_id: &'static str, + 1, // context_id: usize, + // copy_manager: SharedCopyConstraintManager, region, ContextParams { max_rows: gate.max_rows, diff --git a/aggregator/src/tests/compression.rs b/aggregator/src/tests/compression.rs index 1161fae727..18361f7f7d 100644 --- a/aggregator/src/tests/compression.rs +++ b/aggregator/src/tests/compression.rs @@ -2,11 +2,13 @@ use std::{fs, path::Path, process}; use aggregator_snark_verifier::{ loader::halo2::halo2_ecc::halo2_base::{halo2_proofs, utils::fs::gen_srs}, - pcs::kzg::{Bdfg21, Kzg}, + pcs::kzg::{Bdfg21, KzgAs}, }; use aggregator_snark_verifier_sdk::{ - evm_verify, gen_evm_proof_shplonk, gen_evm_verifier, gen_pk, gen_snark_shplonk, - verify_snark_shplonk, CircuitExt, + evm::{evm_verify, gen_evm_proof_shplonk, gen_evm_verifier}, + gen_pk, + halo2::gen_snark_shplonk, + CircuitExt, }; use ark_std::{end_timer, start_timer, test_rng}; use halo2_proofs::{ diff --git a/aggregator/src/tests/mock_chunk.rs b/aggregator/src/tests/mock_chunk.rs index 71db1850ce..3d44a91957 100644 --- a/aggregator/src/tests/mock_chunk.rs +++ b/aggregator/src/tests/mock_chunk.rs @@ -1,14 +1,16 @@ use std::iter; -use aggregator_snark_verifier::loader::halo2::halo2_ecc::halo2_base::SKIP_FIRST_PASS; +use aggregator_snark_verifier::{ + halo2_base::halo2_proofs::{ + circuit::{AssignedCell, Layouter, SimpleFloorPlanner}, + dev::MockProver, + halo2curves::bn256::Fr, + plonk::{Circuit, Column, ConstraintSystem, Error, Instance}, + }, + loader::halo2::halo2_ecc::halo2_base::SKIP_FIRST_PASS, +}; use aggregator_snark_verifier_sdk::CircuitExt; use ark_std::test_rng; -use halo2_proofs::{ - circuit::{AssignedCell, Layouter, SimpleFloorPlanner}, - dev::MockProver, - halo2curves::bn256::Fr, - plonk::{Circuit, Column, ConstraintSystem, Error, Instance}, -}; use zkevm_circuits::{table::KeccakTable, util::Challenges}; use crate::{ @@ -67,6 +69,7 @@ impl MockChunkCircuit { } impl Circuit for MockChunkCircuit { + type Params = (); type Config = MockConfig; type FloorPlanner = SimpleFloorPlanner; diff --git a/aggregator/src/tests/rlc/dynamic_hashes.rs b/aggregator/src/tests/rlc/dynamic_hashes.rs index 190faaa953..e566f74027 100644 --- a/aggregator/src/tests/rlc/dynamic_hashes.rs +++ b/aggregator/src/tests/rlc/dynamic_hashes.rs @@ -1,12 +1,15 @@ -use aggregator_snark_verifier::loader::halo2::halo2_ecc::halo2_base::utils::fs::gen_srs; -use aggregator_snark_verifier_sdk::{gen_pk, gen_snark_shplonk, verify_snark_shplonk, CircuitExt}; -use ark_std::test_rng; -use halo2_proofs::{ - circuit::{Layouter, SimpleFloorPlanner}, - dev::MockProver, - halo2curves::bn256::Fr, - plonk::{Circuit, ConstraintSystem, Error}, +use aggregator_snark_verifier::{ + halo2_base::halo2_proofs::{ + circuit::{Layouter, SimpleFloorPlanner}, + dev::MockProver, + halo2curves::bn256::Fr, + plonk::{Circuit, ConstraintSystem, Error}, + }, + loader::halo2::halo2_ecc::halo2_base::utils::fs::gen_srs, }; +use aggregator_snark_verifier_sdk::{gen_pk, halo2::gen_snark_shplonk, CircuitExt}; +// halo2::verify_snark_shplonk +use ark_std::test_rng; use zkevm_circuits::{ keccak_circuit::{ keccak_packed_multi::{self, multi_keccak}, @@ -34,6 +37,7 @@ struct DynamicHashCircuitConfig { impl Circuit for DynamicHashCircuit { type Config = (DynamicHashCircuitConfig, Challenges); type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { unimplemented!() @@ -191,7 +195,14 @@ impl Circuit for DynamicHashCircuit { } } -impl CircuitExt for DynamicHashCircuit {} +impl CircuitExt for DynamicHashCircuit { + fn num_instance(&self) -> Vec { + todo!() + } + fn instances(&self) -> Vec> { + todo!() + } +} #[test] fn test_hash_circuit() { @@ -221,24 +232,24 @@ fn test_dynamic_hash_circuit() { // pk verifies the original circuit { let snark = gen_snark_shplonk(¶ms, &pk, circuit, &mut rng, None::).unwrap(); - assert!(verify_snark_shplonk::( - ¶ms, - snark, - pk.get_vk() - )); + // assert!(verify_snark_shplonk::( + // ¶ms, + // snark, + // pk.get_vk() + // )); println!("1 round keccak verified with same pk"); } - // pk verifies the circuit with 3 round of keccak + // pk verifies the circuit with 3 rounds of keccak { let a: Vec = (0..LEN * 3).map(|x| x as u8).collect::>(); let circuit = DynamicHashCircuit { inputs: a }; let snark = gen_snark_shplonk(¶ms, &pk, circuit, &mut rng, None::).unwrap(); - assert!(verify_snark_shplonk::( - ¶ms, - snark, - pk.get_vk() - )); + // assert!(verify_snark_shplonk::( + // ¶ms, + // snark, + // pk.get_vk() + // )); println!("3 round keccak verified with same pk"); } } diff --git a/aggregator/src/tests/rlc/gates.rs b/aggregator/src/tests/rlc/gates.rs index 7f177a5d94..06df55ce73 100644 --- a/aggregator/src/tests/rlc/gates.rs +++ b/aggregator/src/tests/rlc/gates.rs @@ -1,6 +1,6 @@ //! Tests the RLC gates -use halo2_proofs::{ +use aggregator_snark_verifier::halo2_base::halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner}, dev::MockProver, halo2curves::bn256::Fr, @@ -23,6 +23,7 @@ struct ArithTestCircuit { } impl Circuit for ArithTestCircuit { + type Params = (); type Config = RlcConfig; type FloorPlanner = SimpleFloorPlanner; fn without_witnesses(&self) -> Self { diff --git a/aggregator/src/util.rs b/aggregator/src/util.rs index ff6cdc2403..9edf2609d5 100644 --- a/aggregator/src/util.rs +++ b/aggregator/src/util.rs @@ -1,5 +1,13 @@ +use aggregator_snark_verifier::{ + halo2_base::{ + halo2_proofs::{circuit::AssignedCell, halo2curves::bn256::Fr, plonk::Error}, + AssignedValue, + }, + loader::native::NativeLoader, + pcs::kzg::KzgAccumulator, +}; use eth_types::Field; -use halo2_proofs::{circuit::AssignedCell, halo2curves::bn256::Fr, plonk::Error}; +use halo2curves::bn256::G1Affine; #[cfg(test)] #[ctor::ctor] @@ -101,3 +109,21 @@ pub(crate) fn rlc(inputs: &[Fr], randomness: &Fr) -> Fr { acc } + +// TODO: does this already exist in snark-verifier? +pub fn flatten_accumulator<'a>( + accumulator: KzgAccumulator, +) -> Vec> { + let KzgAccumulator { lhs, rhs } = accumulator; + let lhs = lhs.into_assigned(); + let rhs = rhs.into_assigned(); + + lhs.x + .truncation + .limbs + .into_iter() + .chain(lhs.y.truncation.limbs.into_iter()) + .chain(rhs.x.truncation.limbs.into_iter()) + .chain(rhs.y.truncation.limbs.into_iter()) + .collect() +} From 30578c4b791f145b1a8f6af7ff2b498ba6bad996 Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Mon, 3 Jun 2024 17:28:28 +0800 Subject: [PATCH 03/18] fix Shplonk import --- aggregator/src/core.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aggregator/src/core.rs b/aggregator/src/core.rs index 6fe48a6b97..7d2bf1a7e4 100644 --- a/aggregator/src/core.rs +++ b/aggregator/src/core.rs @@ -18,7 +18,7 @@ use aggregator_snark_verifier::{ Error, }; use aggregator_snark_verifier_sdk::{ - halo2::{PoseidonTranscript, Shplonk, POSEIDON_SPEC}, + halo2::{PoseidonTranscript, POSEIDON_SPEC}, PlonkVerifier, Snark, }; use ark_std::{end_timer, start_timer}; @@ -57,7 +57,7 @@ pub(crate) fn extract_accumulators_and_proof( .iter() .flat_map(|snark| { transcript_read.new_stream(snark.proof.as_slice()); - let proof = Shplonk::read_proof( + let proof = KzgAs::read_proof( &svk, &snark.protocol, &snark.instances, @@ -65,7 +65,7 @@ pub(crate) fn extract_accumulators_and_proof( ); // each accumulator has (lhs, rhs) based on Shplonk // lhs and rhs are EC points - Shplonk::succinct_verify(&svk, &snark.protocol, &snark.instances, &proof) + KzgAs::verify(&svk, &snark.protocol, &snark.instances, &proof) }) .collect::>(); // sanity check on the accumulator From 070c3a3e3e87bdc3643d1cc9f65a9c2ed9156724 Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Mon, 3 Jun 2024 17:37:16 +0800 Subject: [PATCH 04/18] fix blob Context --- aggregator/src/tests/blob.rs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/aggregator/src/tests/blob.rs b/aggregator/src/tests/blob.rs index 9615fa6f5f..a225908348 100644 --- a/aggregator/src/tests/blob.rs +++ b/aggregator/src/tests/blob.rs @@ -8,7 +8,7 @@ use crate::{ }; use aggregator_snark_verifier::halo2_base::{ gates::range::{RangeConfig}, - gates::flex_gate::FlexGateConfigParams, + gates::flex_gate::{FlexGateConfigParams, threads::MultiPhaseCoreManager}, halo2_proofs::{ circuit::{AssignedCell, Layouter, Region, SimpleFloorPlanner, Value}, dev::{MockProver, VerifyFailure}, @@ -123,21 +123,9 @@ impl Circuit for BlobCircuit { let gate = &config.barycentric.scalar.range.gate; + // TODO: check correctness of this! let core_manager = MultiPhaseCoreManager::new(false); - let mut ctx = core_manager. - let mut ctx = Context::new( - false, // witness_gen_only: bool, - 1, // phase: usize, - "asdfasdfasdf", // type_id: &'static str, - 1, // context_id: usize, - // copy_manager: SharedCopyConstraintManager, - region, - ContextParams { - max_rows: gate.max_rows, - num_context_ids: 1, - fixed_columns: gate.constants.clone(), - }, - ); + let mut ctx = core_manager.main(0); let point_eval = PointEvaluationAssignments::from(&self.data); Ok(config.barycentric.assign( From 5c3fc490ff98f6aea7c9cacdbe3bd7d4b21ecfb6 Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Mon, 3 Jun 2024 17:56:50 +0800 Subject: [PATCH 05/18] fix ContextParams imports --- aggregator/src/aggregation/circuit.rs | 21 +++++---------------- aggregator/src/compression/circuit.rs | 23 ++++++++++------------- aggregator/src/tests/blob.rs | 4 ++-- 3 files changed, 17 insertions(+), 31 deletions(-) diff --git a/aggregator/src/aggregation/circuit.rs b/aggregator/src/aggregation/circuit.rs index e25c429ab0..4fe2e3a759 100644 --- a/aggregator/src/aggregation/circuit.rs +++ b/aggregator/src/aggregation/circuit.rs @@ -1,5 +1,6 @@ use crate::{blob::BatchData, witgen::MultiBlockProcessResult}; use aggregator_snark_verifier::halo2_base::{ + gates::flex_gate::threads::MultiPhaseCoreManager, halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner, Value}, halo2curves::bn256::{Bn256, Fr, G1Affine}, @@ -183,14 +184,8 @@ impl Circuit for AggregationCircuit { return Ok(AssignedBarycentricEvaluationConfig::default()); } - let mut ctx = Context::new( - region, - ContextParams { - max_rows: config.flex_gate().max_rows, - num_context_ids: 1, - fixed_columns: config.flex_gate().constants.clone(), - }, - ); + // TODO: check correctness of this! + let mut ctx = MultiPhaseCoreManager::new(false).main(0); let barycentric = config.barycentric.assign( &mut ctx, @@ -229,14 +224,8 @@ impl Circuit for AggregationCircuit { let mut accumulator_instances: Vec> = vec![]; // stores public inputs for all snarks, including the padded ones let mut snark_inputs: Vec> = vec![]; - let ctx = Context::new( - region, - ContextParams { - max_rows: config.flex_gate().max_rows, - num_context_ids: 1, - fixed_columns: config.flex_gate().constants.clone(), - }, - ); + // TODO: check correctness of this! + let mut ctx = MultiPhaseCoreManager::new(false).main(0); let ecc_chip = config.ecc_chip(); let loader = Halo2Loader::new(ecc_chip, ctx); diff --git a/aggregator/src/compression/circuit.rs b/aggregator/src/compression/circuit.rs index 242d247a34..1972da0566 100644 --- a/aggregator/src/compression/circuit.rs +++ b/aggregator/src/compression/circuit.rs @@ -3,10 +3,13 @@ use std::fs::File; use aggregator_snark_verifier::{ - halo2_base::halo2_proofs::{ - circuit::{Cell, Layouter, SimpleFloorPlanner, Value}, - halo2curves::bn256::G1Affine, - plonk::{Circuit, ConstraintSystem, Error}, + halo2_base::{ + gates::flex_gate::threads::MultiPhaseCoreManager, + halo2_proofs::{ + circuit::{Cell, Layouter, SimpleFloorPlanner, Value}, + halo2curves::bn256::G1Affine, + plonk::{Circuit, ConstraintSystem, Error}, + }, }, loader::halo2::{ halo2_ecc::{ @@ -16,7 +19,7 @@ use aggregator_snark_verifier::{ halo2curves::bn256::{Bn256, Fr}, poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, }, - Context, ContextParams, + Context, }, }, Halo2Loader, @@ -120,14 +123,8 @@ impl Circuit for CompressionCircuit { return Ok(vec![]); } let mut instances = vec![]; - let ctx = Context::new( - region, - ContextParams { - max_rows: config.gate().max_rows, - num_context_ids: 1, - fixed_columns: config.gate().constants.clone(), - }, - ); + // TODO: check correctness of this! + let mut ctx = MultiPhaseCoreManager::new(false).main(0); let ecc_chip = config.ecc_chip(); let loader = Halo2Loader::new(ecc_chip, ctx); diff --git a/aggregator/src/tests/blob.rs b/aggregator/src/tests/blob.rs index a225908348..466c93c461 100644 --- a/aggregator/src/tests/blob.rs +++ b/aggregator/src/tests/blob.rs @@ -7,8 +7,8 @@ use crate::{ BatchDataConfig, MAX_AGG_SNARKS, }; use aggregator_snark_verifier::halo2_base::{ - gates::range::{RangeConfig}, - gates::flex_gate::{FlexGateConfigParams, threads::MultiPhaseCoreManager}, + gates::flex_gate::{threads::MultiPhaseCoreManager, FlexGateConfigParams}, + gates::range::RangeConfig, halo2_proofs::{ circuit::{AssignedCell, Layouter, Region, SimpleFloorPlanner, Value}, dev::{MockProver, VerifyFailure}, From 071f05e69ad1ab6672d7102015d67c926cd969e2 Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Fri, 7 Jun 2024 12:29:01 +0800 Subject: [PATCH 06/18] fix SnarkWitness import error --- aggregator/src/aggregation/circuit.rs | 4 ++-- aggregator/src/compression/circuit.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aggregator/src/aggregation/circuit.rs b/aggregator/src/aggregation/circuit.rs index 4fe2e3a759..f6f4cfacd9 100644 --- a/aggregator/src/aggregation/circuit.rs +++ b/aggregator/src/aggregation/circuit.rs @@ -26,7 +26,7 @@ use aggregator_snark_verifier::{ }; #[cfg(not(feature = "disable_proof_aggregation"))] use aggregator_snark_verifier_sdk::halo2::aggregation::aggregate; -use aggregator_snark_verifier_sdk::{CircuitExt, Snark, SnarkWitness}; +use aggregator_snark_verifier_sdk::{CircuitExt, Snark}; use zkevm_circuits::util::Challenges; #[cfg(not(feature = "disable_proof_aggregation"))] @@ -48,7 +48,7 @@ pub struct AggregationCircuit { pub svk: KzgSuccinctVerifyingKey, // the input snarks for the aggregation circuit // it is padded already so it will have a fixed length of N_SNARKS - pub snarks_with_padding: Vec, + pub snarks_with_padding: Vec, // the public instance for this circuit consists of // - an accumulator (12 elements) // - the batch's public_input_hash (32 elements) diff --git a/aggregator/src/compression/circuit.rs b/aggregator/src/compression/circuit.rs index 1972da0566..9e693c895e 100644 --- a/aggregator/src/compression/circuit.rs +++ b/aggregator/src/compression/circuit.rs @@ -28,7 +28,7 @@ use aggregator_snark_verifier::{ }; use aggregator_snark_verifier_sdk::{ halo2::aggregation::{aggregate, Svk}, - Snark, SnarkWitness, + Snark, }; use ark_std::{end_timer, start_timer}; use rand::Rng; @@ -47,7 +47,7 @@ use super::config::CompressionConfig; #[derive(Clone, Debug)] pub struct CompressionCircuit { pub(crate) svk: KzgSuccinctVerifyingKey, - pub(crate) snark: SnarkWitness, + pub(crate) snark: Snark, /// whether this circuit compresses a fresh snark pub(crate) has_accumulator: bool, /// instances, flattened. @@ -74,7 +74,7 @@ impl Circuit for CompressionCircuit { Self { svk: self.svk, - snark: SnarkWitness::without_witnesses(&self.snark), + snark: Snark::without_witnesses(&self.snark), has_accumulator: false, flattened_instances, as_proof: Value::unknown(), @@ -217,7 +217,7 @@ impl CompressionCircuit { &self.svk } - pub fn snark(&self) -> &SnarkWitness { + pub fn snark(&self) -> &Snark { &self.snark } From c7eb13860643d69fb6eb1eb599b01423af4ff7d0 Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Mon, 17 Jun 2024 22:33:30 +0800 Subject: [PATCH 07/18] wip --- Cargo.lock | 436 +++++++++++++++++------ Cargo.toml | 25 +- aggregator/src/aggregation/rlc/config.rs | 2 +- aggregator/src/aggregation/rlc/gates.rs | 2 +- aggregator/src/tests/rlc/gates.rs | 2 +- aggregator/src/util.rs | 3 +- 6 files changed, 345 insertions(+), 125 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 511ac4af4b..3e4b33c024 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -205,9 +205,9 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] @@ -437,9 +437,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.72" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" dependencies = [ "addr2line", "cc", @@ -780,9 +780,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.98" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" dependencies = [ "jobserver", "libc", @@ -870,9 +870,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" dependencies = [ "clap_builder", "clap_derive", @@ -880,9 +880,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" dependencies = [ "anstream", "anstyle", @@ -892,9 +892,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -904,9 +904,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "cli-table" @@ -1303,15 +1303,15 @@ dependencies = [ [[package]] name = "derive_more" -version = "0.99.17" +version = "0.99.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "convert_case", "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 1.0.109", + "syn 2.0.66", ] [[package]] @@ -1362,6 +1362,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "displaydoc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "dotenvy" version = "0.15.7" @@ -2206,26 +2217,11 @@ dependencies = [ "tracing", ] -[[package]] -name = "halo2-base" -version = "0.2.2" -source = "git+https://github.com/scroll-tech/halo2-lib?branch=develop#817cace374a9f4b2eca682b1cc36f143255ea25f" -dependencies = [ - "ff", - "halo2_proofs 1.1.0", - "itertools 0.10.5", - "num-bigint", - "num-integer", - "num-traits", - "rand_chacha", - "rustc-hash", -] - [[package]] name = "halo2-base" version = "0.4.1" -source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition#18d7d6e713d7161e1f5aa15e8721e6160eb36776" dependencies = [ + "ark-std 0.3.0", "getset", "halo2_proofs 0.3.0", "itertools 0.11.0", @@ -2234,6 +2230,7 @@ dependencies = [ "num-integer", "num-traits", "poseidon-primitives", + "rand", "rand_chacha", "rayon", "rustc-hash", @@ -2241,31 +2238,11 @@ dependencies = [ "serde_json", ] -[[package]] -name = "halo2-ecc" -version = "0.2.2" -source = "git+https://github.com/scroll-tech/halo2-lib?branch=develop#817cace374a9f4b2eca682b1cc36f143255ea25f" -dependencies = [ - "ff", - "group", - "halo2-base 0.2.2", - "itertools 0.10.5", - "num-bigint", - "num-integer", - "num-traits", - "rand", - "rand_chacha", - "rand_core", - "serde", - "serde_json", -] - [[package]] name = "halo2-ecc" version = "0.4.1" -source = "git+https://github.com/axiom-crypto/halo2-lib.git?branch=community-edition#18d7d6e713d7161e1f5aa15e8721e6160eb36776" dependencies = [ - "halo2-base 0.4.1", + "halo2-base", "itertools 0.11.0", "num-bigint", "num-integer", @@ -2547,9 +2524,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "d0e7a4dd27b9476dc40cb050d3632d3bba3a70ddbff012285f7f8559a1e7e545" [[package]] name = "httpdate" @@ -2565,9 +2542,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" dependencies = [ "bytes", "futures-channel", @@ -2624,6 +2601,124 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f8ac670d7422d7f76b32e17a5db556510825b29ec9154f235977c9caba61036" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -2632,12 +2727,14 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "icu_normalizer", + "icu_properties", + "smallvec", + "utf8_iter", ] [[package]] @@ -2911,7 +3008,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if 1.0.0", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] @@ -2942,6 +3039,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lock_api" version = "0.4.12" @@ -3007,9 +3110,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "mime" @@ -3251,9 +3354,9 @@ dependencies = [ [[package]] name = "object" -version = "0.35.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" dependencies = [ "memchr", ] @@ -3750,9 +3853,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.84" +version = "1.0.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" dependencies = [ "unicode-ident", ] @@ -3771,7 +3874,7 @@ dependencies = [ "rand", "rand_chacha", "rand_xorshift", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", "rusty-fork", "tempfile", "unarray", @@ -3901,9 +4004,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ "bitflags 2.5.0", ] @@ -3921,25 +4024,25 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", ] [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.3", + "regex-syntax 0.8.4", ] [[package]] @@ -3950,9 +4053,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" @@ -4052,7 +4155,7 @@ dependencies = [ [[package]] name = "revm-precompile" version = "7.0.0" -source = "git+https://github.com/scroll-tech/revm?branch=scroll-evm-executor/v36#8543dd627348907773d8057807b6a310b276bb30" +source = "git+https://github.com/scroll-tech/revm?branch=scroll-evm-executor/v36#074cba27d614f9506a0e10bec5ac7e5644b129a0" dependencies = [ "aurora-engine-modexp", "c-kzg 1.0.2", @@ -4086,7 +4189,7 @@ dependencies = [ [[package]] name = "revm-primitives" version = "4.0.0" -source = "git+https://github.com/scroll-tech/revm?branch=scroll-evm-executor/v36#8543dd627348907773d8057807b6a310b276bb30" +source = "git+https://github.com/scroll-tech/revm?branch=scroll-evm-executor/v36#074cba27d614f9506a0e10bec5ac7e5644b129a0" dependencies = [ "alloy-primitives 0.7.4", "auto_impl", @@ -4220,9 +4323,9 @@ dependencies = [ [[package]] name = "ruint-macro" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" +checksum = "48fd7bd8a6377e15ad9d42a8ec25371b94ddc67abe7c8b9127bec79bebaaae18" [[package]] name = "rustc-demangle" @@ -4731,12 +4834,11 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "snark-verifier" version = "0.1.0" -source = "git+https://github.com/scroll-tech/snark-verifier?branch=develop#fe1f8906041ad323034881fbd808908250d44829" dependencies = [ "bytes", "ethereum-types", - "halo2-base 0.2.2", - "halo2-ecc 0.2.2", + "halo2-base", + "halo2-ecc", "hex", "itertools 0.12.1", "num-bigint", @@ -4754,10 +4856,9 @@ dependencies = [ [[package]] name = "snark-verifier" version = "0.1.8" -source = "git+https://github.com/axiom-crypto/snark-verifier?branch=community-edition#59845ab4a7a175063d02b721343e687199d8ec24" dependencies = [ - "halo2-base 0.4.1", - "halo2-ecc 0.4.1", + "halo2-base", + "halo2-ecc", "hex", "itertools 0.11.0", "lazy_static", @@ -4775,12 +4876,11 @@ dependencies = [ [[package]] name = "snark-verifier-sdk" version = "0.0.1" -source = "git+https://github.com/scroll-tech/snark-verifier?branch=develop#fe1f8906041ad323034881fbd808908250d44829" dependencies = [ "bincode", "ethereum-types", "ff", - "halo2-base 0.2.2", + "halo2-base", "hex", "itertools 0.12.1", "log", @@ -4797,12 +4897,11 @@ dependencies = [ [[package]] name = "snark-verifier-sdk" version = "0.1.8" -source = "git+https://github.com/axiom-crypto/snark-verifier?branch=community-edition#59845ab4a7a175063d02b721343e687199d8ec24" dependencies = [ "bincode", "ethereum-types", "getset", - "halo2-base 0.4.1", + "halo2-base", "hex", "itertools 0.11.0", "lazy_static", @@ -4863,6 +4962,12 @@ dependencies = [ "der", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "stacker" version = "0.1.15" @@ -5015,6 +5120,17 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -5224,6 +5340,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -5463,32 +5589,17 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-normalization" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "unicode-xid" @@ -5510,9 +5621,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "f7c25da092f0a868cdf09e8674cd3b7ef3a7d92a24253e663a2fb85e2496de56" dependencies = [ "form_urlencoded", "idna", @@ -5531,11 +5642,23 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" @@ -5904,6 +6027,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "ws_stream_wasm" version = "0.7.4" @@ -5947,6 +6082,30 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.34" @@ -5967,6 +6126,27 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "synstructure", +] + [[package]] name = "zeroize" version = "1.8.1" @@ -5987,6 +6167,28 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "zerovec" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb2cc8827d6c0994478a15c53f374f46fbd41bea663d809b14744bc42e6b109c" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + [[package]] name = "zip" version = "0.6.6" @@ -6022,8 +6224,8 @@ dependencies = [ "ethers-signers", "ff", "gadgets", - "halo2-base 0.2.2", - "halo2-ecc 0.2.2", + "halo2-base", + "halo2-ecc", "halo2-mpt-circuits", "halo2_gadgets", "halo2_proofs 1.1.0", diff --git a/Cargo.toml b/Cargo.toml index 757f8f288f..acdd93ce71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,10 +56,14 @@ serde = {version = "1.0", features = ["derive"] } serde_json = "1.0" serde_stacker = "0.1" sha3 = "0.10" -snark-verifier = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop" } -snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "develop", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"] } -aggregator-snark-verifier = { git = "https://github.com/axiom-crypto/snark-verifier", branch = "community-edition", package = "snark-verifier", default-features = false, features = ["loader_halo2", "halo2-pse", "loader_evm", "revm"] } -aggregator-snark-verifier-sdk = { git = "https://github.com/axiom-crypto/snark-verifier", branch = "community-edition", default-features = false, features = ["loader_halo2", "halo2-pse", "loader_evm", "revm"], package = "snark-verifier-sdk" } +snark-verifier = { path = "../scroll-snark-verifier/snark-verifier" } +snark-verifier-sdk = { path = "../scroll-snark-verifier/snark-verifier-sdk", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"] } +# aggregator-snark-verifier = { git = "https://github.com/axiom-crypto/snark-verifier", branch = "community-edition", package = "snark-verifier", default-features = false, features = ["loader_halo2", "halo2-pse", "loader_evm", "revm"] } +# aggregator-snark-verifier-sdk = { git = "https://github.com/axiom-crypto/snark-verifier", branch = "community-edition", default-features = false, features = ["loader_halo2", "halo2-pse", "loader_evm", "revm"], package = "snark-verifier-sdk" } + +aggregator-snark-verifier = { path = "../snark-verifier/snark-verifier", package = "snark-verifier", default-features = false, features = ["loader_halo2", "halo2-pse", "loader_evm", "revm"] } +aggregator-snark-verifier-sdk = { path = "../snark-verifier/snark-verifier-sdk", default-features = false, features = ["loader_halo2", "halo2-pse", "loader_evm", "revm"], package = "snark-verifier-sdk" } + strum = "0.25" strum_macros = "0.25" subtle = "2.4" @@ -77,6 +81,8 @@ ethers-etherscan = { git = "https://github.com/scroll-tech/ethers-rs.git", branc ethers-signers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" } gobuild = { git = "https://github.com/scroll-tech/gobuild.git" } halo2curves = { git = "https://github.com/scroll-tech/halo2curves", branch = "v0.1.0" } +# halo2-base = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop" } +# halo2-ecc = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop" } [patch."https://github.com/privacy-scaling-explorations/halo2.git"] halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" } @@ -86,6 +92,17 @@ poseidon = { git = "https://github.com/scroll-tech/poseidon.git", branch = "main [patch."https://github.com/privacy-scaling-explorations/bls12_381"] bls12_381 = { git = "https://github.com/scroll-tech/bls12_381", branch = "feat/impl_scalar_field" } +[patch."https://github.com/axiom-crypto/halo2-lib.git"] +halo2-base = { path = "../halo2-lib/halo2-base" } +halo2-ecc = { path = "../halo2-lib/halo2-ecc" } +# halo2-base = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop" } +# halo2-ecc = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop" } + +[patch."https://github.com/scroll-tech/halo2-lib.git"] +halo2-base = { path = "../halo2-lib/halo2-base" } +halo2-ecc = { path = "../halo2-lib/halo2-ecc" } +# halo2-base = { git = "https://github.com/axiom-crypto/halo2-lib", branch = "community-edition" } +# halo2-ecc = { git = "https://github.com/scroll-tech/halo2-lib", branch = "community-edition" } # Definition of benchmarks profile to use. [profile.bench] diff --git a/aggregator/src/aggregation/rlc/config.rs b/aggregator/src/aggregation/rlc/config.rs index 0c18c76ef0..d9896d427b 100644 --- a/aggregator/src/aggregation/rlc/config.rs +++ b/aggregator/src/aggregation/rlc/config.rs @@ -1,8 +1,8 @@ use aggregator_snark_verifier::halo2_base::halo2_proofs::{ - halo2curves::bn256::Fr, plonk::{Advice, Column, ConstraintSystem, Fixed, SecondPhase, Selector}, poly::Rotation, }; +use halo2curves::bn256::Fr; #[cfg(test)] use aggregator_snark_verifier::halo2_base::halo2_proofs::plonk::FirstPhase; diff --git a/aggregator/src/aggregation/rlc/gates.rs b/aggregator/src/aggregation/rlc/gates.rs index bf05e6e245..fc3b15b358 100644 --- a/aggregator/src/aggregation/rlc/gates.rs +++ b/aggregator/src/aggregation/rlc/gates.rs @@ -1,9 +1,9 @@ use aggregator_snark_verifier::halo2_base::halo2_proofs::{ arithmetic::Field, circuit::{AssignedCell, Cell, Region, RegionIndex, Value}, - halo2curves::bn256::Fr, plonk::Error, }; +use halo2curves::bn256::Fr; use ethers_core::utils::keccak256; use zkevm_circuits::util::Challenges; diff --git a/aggregator/src/tests/rlc/gates.rs b/aggregator/src/tests/rlc/gates.rs index 06df55ce73..666a0d0a49 100644 --- a/aggregator/src/tests/rlc/gates.rs +++ b/aggregator/src/tests/rlc/gates.rs @@ -3,9 +3,9 @@ use aggregator_snark_verifier::halo2_base::halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner}, dev::MockProver, - halo2curves::bn256::Fr, plonk::{Circuit, ConstraintSystem, Error}, }; +use halo2curves::bn256::Fr; use zkevm_circuits::{table::KeccakTable, util::Challenges}; use crate::{aggregation::RlcConfig, util::rlc}; diff --git a/aggregator/src/util.rs b/aggregator/src/util.rs index 9edf2609d5..e7fb5944ca 100644 --- a/aggregator/src/util.rs +++ b/aggregator/src/util.rs @@ -1,11 +1,12 @@ use aggregator_snark_verifier::{ halo2_base::{ - halo2_proofs::{circuit::AssignedCell, halo2curves::bn256::Fr, plonk::Error}, + halo2_proofs::{circuit::AssignedCell, plonk::Error}, AssignedValue, }, loader::native::NativeLoader, pcs::kzg::KzgAccumulator, }; +use halo2curves::bn256::Fr; use eth_types::Field; use halo2curves::bn256::G1Affine; From 6087eb96d0ff0bd16b8ac772bbdf616198b93ba4 Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Fri, 21 Jun 2024 13:54:17 +0800 Subject: [PATCH 08/18] wip --- Cargo.lock | 157 ++++++++---------- Cargo.toml | 21 ++- aggregator/Cargo.toml | 1 + aggregator/src/aggregation/barycentric.rs | 90 +++++----- aggregator/src/aggregation/circuit.rs | 6 +- aggregator/src/aggregation/config.rs | 4 +- .../aggregation/decoder/tables/bitstring.rs | 74 ++++----- .../src/aggregation/decoder/tables/fixed.rs | 54 +++--- .../src/aggregation/decoder/tables/fse.rs | 58 +++---- .../decoder/tables/literals_header.rs | 56 +++---- .../decoder/tables/seqinst_table.rs | 54 +++--- .../src/aggregation/decoder/witgen/types.rs | 8 +- aggregator/src/aggregation/rlc/gates.rs | 4 +- aggregator/src/core.rs | 46 ++--- aggregator/src/tests.rs | 17 +- aggregator/src/tests/aggregation.rs | 4 +- aggregator/src/tests/blob.rs | 2 +- aggregator/src/tests/rlc/dynamic_hashes.rs | 4 +- aggregator/src/tests/rlc/gates.rs | 2 +- aggregator/src/util.rs | 6 +- gadgets/Cargo.toml | 3 + gadgets/src/batched_is_zero.rs | 1 + gadgets/src/evm_word.rs | 1 + gadgets/src/is_equal.rs | 1 + gadgets/src/is_zero.rs | 4 +- gadgets/src/less_than.rs | 2 + gadgets/src/monotone.rs | 1 + gadgets/src/mul_add.rs | 1 + zkevm-circuits/Cargo.toml | 3 +- zkevm-circuits/src/ecc_circuit/dev.rs | 2 + zkevm-circuits/src/sha256_circuit/circuit.rs | 2 + zkevm-circuits/src/sha256_circuit/test.rs | 2 + zkevm-circuits/src/sig_circuit/dev.rs | 2 + 33 files changed, 350 insertions(+), 343 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3e4b33c024..4c002889b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,7 +52,8 @@ dependencies = [ "eth-types", "ethers-core", "gadgets", - "halo2curves 0.1.0", + "halo2_proofs", + "halo2curves", "hex", "itertools 0.11.0", "log", @@ -655,7 +656,7 @@ dependencies = [ "ethers-signers", "external-tracer", "gadgets", - "halo2_proofs 1.1.0", + "halo2_proofs", "hex", "itertools 0.11.0", "log", @@ -845,7 +846,7 @@ dependencies = [ "eth-types", "ethers", "ethers-signers", - "halo2_proofs 1.1.0", + "halo2_proofs", "itertools 0.11.0", "log", "mock", @@ -1549,7 +1550,7 @@ dependencies = [ "base64 0.13.1", "ethers-core", "ethers-signers", - "halo2curves 0.1.0", + "halo2curves", "hex", "itertools 0.11.0", "log", @@ -2085,7 +2086,7 @@ name = "gadgets" version = "0.11.0" dependencies = [ "eth-types", - "halo2_proofs 1.1.0", + "halo2_proofs", "rand", "rand_xorshift", "sha3 0.10.8", @@ -2217,20 +2218,33 @@ dependencies = [ "tracing", ] +[[package]] +name = "halo2-base" +version = "0.2.2" +source = "git+https://github.com/scroll-tech/halo2-lib?branch=develop#817cace374a9f4b2eca682b1cc36f143255ea25f" +dependencies = [ + "ff", + "halo2_proofs", + "itertools 0.10.5", + "num-bigint", + "num-integer", + "num-traits", + "rand_chacha", + "rustc-hash", +] + [[package]] name = "halo2-base" version = "0.4.1" dependencies = [ - "ark-std 0.3.0", "getset", - "halo2_proofs 0.3.0", + "halo2_proofs", "itertools 0.11.0", "log", "num-bigint", "num-integer", "num-traits", "poseidon-primitives", - "rand", "rand_chacha", "rayon", "rustc-hash", @@ -2238,11 +2252,30 @@ dependencies = [ "serde_json", ] +[[package]] +name = "halo2-ecc" +version = "0.2.2" +source = "git+https://github.com/scroll-tech/halo2-lib?branch=develop#817cace374a9f4b2eca682b1cc36f143255ea25f" +dependencies = [ + "ff", + "group", + "halo2-base 0.2.2", + "itertools 0.10.5", + "num-bigint", + "num-integer", + "num-traits", + "rand", + "rand_chacha", + "rand_core", + "serde", + "serde_json", +] + [[package]] name = "halo2-ecc" version = "0.4.1" dependencies = [ - "halo2-base", + "halo2-base 0.4.1", "itertools 0.11.0", "num-bigint", "num-integer", @@ -2261,7 +2294,7 @@ name = "halo2-gate-generator" version = "0.1.0" source = "git+https://github.com/scroll-tech/halo2gategen?branch=scroll#2fa5c39aa67d0f97d660f37954daa9e897d0a4c1" dependencies = [ - "halo2_proofs 1.1.0", + "halo2_proofs", "lazy_static", "num-bigint", "rand", @@ -2278,7 +2311,7 @@ version = "0.1.0" source = "git+https://github.com/scroll-tech/mpt-circuit.git?branch=v0.7#daa3a06e2e96d00337188280ac43fa879e722804" dependencies = [ "ethers-core", - "halo2_proofs 1.1.0", + "halo2_proofs", "hex", "itertools 0.10.5", "lazy_static", @@ -2304,30 +2337,14 @@ dependencies = [ "bitvec", "ff", "group", - "halo2_proofs 1.1.0", - "halo2curves 0.1.0", + "halo2_proofs", + "halo2curves", "lazy_static", "rand", "subtle", "uint", ] -[[package]] -name = "halo2_proofs" -version = "0.3.0" -source = "git+https://github.com/privacy-scaling-explorations/halo2.git?tag=v0.3.0#73408a140737d8336490452193b21f5a7a94e7de" -dependencies = [ - "blake2b_simd", - "ff", - "group", - "halo2curves 0.6.1", - "rand_chacha", - "rand_core", - "rayon", - "sha3 0.9.1", - "tracing", -] - [[package]] name = "halo2_proofs" version = "1.1.0" @@ -2339,7 +2356,7 @@ dependencies = [ "crossbeam", "ff", "group", - "halo2curves 0.1.0", + "halo2curves", "log", "maybe-rayon", "num-bigint", @@ -2356,7 +2373,6 @@ dependencies = [ [[package]] name = "halo2curves" version = "0.1.0" -source = "git+https://github.com/scroll-tech/halo2curves?branch=v0.1.0#112f5b9bf27f6b1708ba7d1c2fc14cb3c6e55604" dependencies = [ "blake2b_simd", "bls12_381", @@ -2366,35 +2382,11 @@ dependencies = [ "maybe-rayon", "num-bigint", "num-traits", - "pasta_curves", - "paste", - "rand", - "rand_core", - "serde", - "serde_arrays", - "static_assertions", - "subtle", -] - -[[package]] -name = "halo2curves" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db81d01d0bbfec9f624d7590fc6929ee2537a64ec1e080d8f8c9e2d2da291405" -dependencies = [ - "blake2b_simd", - "ff", - "group", - "hex", - "lazy_static", - "num-bigint", - "num-traits", "pairing", "pasta_curves", "paste", "rand", "rand_core", - "rayon", "serde", "serde_arrays", "static_assertions", @@ -2472,9 +2464,6 @@ name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -dependencies = [ - "serde", -] [[package]] name = "hex-literal" @@ -2524,9 +2513,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.3" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0e7a4dd27b9476dc40cb050d3632d3bba3a70ddbff012285f7f8559a1e7e545" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -2828,7 +2817,7 @@ dependencies = [ "env_logger", "eth-types", "ethers", - "halo2_proofs 1.1.0", + "halo2_proofs", "hex", "log", "mock", @@ -3128,9 +3117,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] @@ -3152,7 +3141,7 @@ version = "0.1.0" source = "git+https://github.com/scroll-tech/misc-precompiled-circuit.git?branch=main#dcb5018d84e8a9adec59cd33f5348a3971cec194" dependencies = [ "halo2-gate-generator", - "halo2_proofs 1.1.0", + "halo2_proofs", "num-bigint", "rand", "serde", @@ -3182,7 +3171,7 @@ version = "0.11.0" dependencies = [ "env_logger", "eth-types", - "halo2curves 0.1.0", + "halo2curves", "hex", "log", "num-bigint", @@ -3476,10 +3465,8 @@ dependencies = [ "blake2b_simd", "ff", "group", - "hex", "lazy_static", "rand", - "serde", "static_assertions", "subtle", ] @@ -3699,7 +3686,7 @@ name = "poseidon" version = "0.2.0" source = "git+https://github.com/scroll-tech/poseidon.git?branch=main#5787dd3d2ce7a9e9601a035c396ac0c03449b54d" dependencies = [ - "halo2curves 0.1.0", + "halo2curves", "subtle", ] @@ -3709,7 +3696,7 @@ version = "0.1.0" source = "git+https://github.com/scroll-tech/poseidon-circuit.git?branch=main#7b96835c6201afdbfaf3d13d641efbaaf5db2d20" dependencies = [ "bitvec", - "halo2curves 0.1.0", + "halo2curves", "lazy_static", ] @@ -3719,7 +3706,7 @@ version = "0.1.0" source = "git+https://github.com/scroll-tech/poseidon-circuit.git?branch=main#7b96835c6201afdbfaf3d13d641efbaaf5db2d20" dependencies = [ "ff", - "halo2_proofs 1.1.0", + "halo2_proofs", "log", "poseidon-base", "rand", @@ -3894,7 +3881,7 @@ dependencies = [ "eth-types", "ethers-core", "git-version", - "halo2_proofs 1.1.0", + "halo2_proofs", "hex", "itertools 0.11.0", "log", @@ -4200,7 +4187,7 @@ dependencies = [ "derive_more", "dyn-clone", "enumn", - "halo2curves 0.1.0", + "halo2curves", "hashbrown 0.14.5", "hex", "once_cell", @@ -4837,8 +4824,8 @@ version = "0.1.0" dependencies = [ "bytes", "ethereum-types", - "halo2-base", - "halo2-ecc", + "halo2-base 0.2.2", + "halo2-ecc 0.2.2", "hex", "itertools 0.12.1", "num-bigint", @@ -4857,8 +4844,8 @@ dependencies = [ name = "snark-verifier" version = "0.1.8" dependencies = [ - "halo2-base", - "halo2-ecc", + "halo2-base 0.4.1", + "halo2-ecc 0.4.1", "hex", "itertools 0.11.0", "lazy_static", @@ -4880,7 +4867,7 @@ dependencies = [ "bincode", "ethereum-types", "ff", - "halo2-base", + "halo2-base 0.2.2", "hex", "itertools 0.12.1", "log", @@ -4901,7 +4888,7 @@ dependencies = [ "bincode", "ethereum-types", "getset", - "halo2-base", + "halo2-base 0.4.1", "hex", "itertools 0.11.0", "lazy_static", @@ -5237,7 +5224,7 @@ dependencies = [ "ethers-signers", "external-tracer", "glob", - "halo2_proofs 1.1.0", + "halo2_proofs", "handlebars", "hex", "itertools 0.11.0", @@ -6224,11 +6211,11 @@ dependencies = [ "ethers-signers", "ff", "gadgets", - "halo2-base", - "halo2-ecc", + "halo2-base 0.2.2", + "halo2-ecc 0.2.2", "halo2-mpt-circuits", "halo2_gadgets", - "halo2_proofs 1.1.0", + "halo2_proofs", "hex", "itertools 0.11.0", "log", @@ -6301,7 +6288,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" dependencies = [ "libc", - "zstd-sys 2.0.10+zstd.1.5.6", + "zstd-sys 2.0.11+zstd.1.5.6", ] [[package]] @@ -6323,9 +6310,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.10+zstd.1.5.6" +version = "2.0.11+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c253a4914af5bafc8fa8c86ee400827e83cf6ec01195ec1f1ed8441bf00d65aa" +checksum = "75652c55c0b6f3e6f12eb786fe1bc960396bf05a1eb3bf1f3691c3610ac2e6d4" dependencies = [ "cc", "pkg-config", diff --git a/Cargo.toml b/Cargo.toml index acdd93ce71..51552de6ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,30 +80,37 @@ ethers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0. ethers-etherscan = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" } ethers-signers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" } gobuild = { git = "https://github.com/scroll-tech/gobuild.git" } -halo2curves = { git = "https://github.com/scroll-tech/halo2curves", branch = "v0.1.0" } +halo2curves = { path = "../halo2curves" } # halo2-base = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop" } # halo2-ecc = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop" } [patch."https://github.com/privacy-scaling-explorations/halo2.git"] halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" } + [patch."https://github.com/privacy-scaling-explorations/poseidon.git"] poseidon = { git = "https://github.com/scroll-tech/poseidon.git", branch = "main" } [patch."https://github.com/privacy-scaling-explorations/bls12_381"] bls12_381 = { git = "https://github.com/scroll-tech/bls12_381", branch = "feat/impl_scalar_field" } -[patch."https://github.com/axiom-crypto/halo2-lib.git"] -halo2-base = { path = "../halo2-lib/halo2-base" } -halo2-ecc = { path = "../halo2-lib/halo2-ecc" } +# [patch."https://github.com/axiom-crypto/halo2-lib.git"] +# halo2-base = { path = "../halo2-lib/halo2-base" } +# halo2-ecc = { path = "../halo2-lib/halo2-ecc" } # halo2-base = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop" } # halo2-ecc = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop" } -[patch."https://github.com/scroll-tech/halo2-lib.git"] -halo2-base = { path = "../halo2-lib/halo2-base" } -halo2-ecc = { path = "../halo2-lib/halo2-ecc" } +# [patch."https://github.com/scroll-tech/halo2-lib.git"] +# halo2-base = { path = "../halo2-lib/halo2-base" } +# halo2-ecc = { path = "../halo2-lib/halo2-ecc" } # halo2-base = { git = "https://github.com/axiom-crypto/halo2-lib", branch = "community-edition" } # halo2-ecc = { git = "https://github.com/scroll-tech/halo2-lib", branch = "community-edition" } +# [patch."https://github.com/privacy-scaling-explorations/halo2.git"] +# halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" } + +# [replace] +# "halo2_proofs:0.3.0" = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" } + # Definition of benchmarks profile to use. [profile.bench] opt-level = 3 diff --git a/aggregator/Cargo.toml b/aggregator/Cargo.toml index 68b62cb33a..0231774922 100644 --- a/aggregator/Cargo.toml +++ b/aggregator/Cargo.toml @@ -14,6 +14,7 @@ ark-std.workspace = true ctor.workspace = true env_logger.workspace = true ethers-core.workspace = true +halo2_proofs.workspace = true hex.workspace = true log.workspace = true itertools.workspace = true diff --git a/aggregator/src/aggregation/barycentric.rs b/aggregator/src/aggregation/barycentric.rs index 7742e96a7f..b4fbb8551c 100644 --- a/aggregator/src/aggregation/barycentric.rs +++ b/aggregator/src/aggregation/barycentric.rs @@ -7,7 +7,10 @@ use aggregator_snark_verifier::{ }, halo2_ecc::{ bigint::{CRTInteger, OverflowInteger}, - fields::{fp::FpConfig, FieldChip}, + fields::{ + fp::{FpChip, FpConfig}, + FieldChip, + }, halo2_base::{utils::decompose_bigint_option, Context}, }, }; @@ -67,7 +70,8 @@ pub struct AssignedBarycentricEvaluationConfig { impl BarycentricEvaluationConfig { pub fn construct(range: RangeConfig) -> Self { Self { - scalar: FpConfig::construct(range, BITS, LIMBS, modulus::()), + // scalar: FpConfig::construct(range, BITS, LIMBS, modulus::()), + scalar: range, } } @@ -76,16 +80,11 @@ impl BarycentricEvaluationConfig { // similar to FpChip.load_private without range check. let a_val = Value::known(BigInt::from_bytes_le(Sign::Plus, &a.to_le_bytes())); - let a_vec = decompose_bigint_option::( - a_val.as_ref(), - self.scalar.num_limbs, - self.scalar.limb_bits, - ); - let limbs = self.scalar.range().gate.assign_witnesses(ctx, a_vec); + let a_vec = decompose_bigint_option::(a_val.as_ref(), LIMBS, BITS); + let limbs = ctx.assign_witnesses(a_vec); let a_native = OverflowInteger::::evaluate( - &self.scalar.range().gate, - //&self.bigint_chip, + &fp_chip, ctx, &limbs, self.scalar.limb_bases.iter().cloned(), @@ -106,10 +105,10 @@ impl BarycentricEvaluationConfig { evaluation: U256, ) -> AssignedBarycentricEvaluationConfig { // some constants for later use. - let one = self.scalar.load_constant(ctx, fe_to_biguint(&Fr::one())); - let blob_width = self - .scalar - .load_constant(ctx, fe_to_biguint(&Fr::from(BLOB_WIDTH as u64))); + let fp_chip = FpChip::::new(&self.scalar, BITS, LIMBS); + + let one = fp_chip.load_constant(ctx, fe_to_biguint(&Fr::one())); + let blob_width = fp_chip.load_constant(ctx, fe_to_biguint(&Fr::from(BLOB_WIDTH as u64))); let powers_of_256 = std::iter::successors(Some(Fr::one()), |coeff| Some(Fr::from(256) * coeff)) @@ -119,7 +118,7 @@ impl BarycentricEvaluationConfig { let roots_of_unity = ROOTS_OF_UNITY .iter() - .map(|x| self.scalar.load_constant(ctx, fe_to_biguint(x))) + .map(|x| fp_chip.load_constant(ctx, fe_to_biguint(x))) .collect::>(); //////////////////////////////////////////////////////////////////////////////////////// @@ -130,51 +129,49 @@ impl BarycentricEvaluationConfig { let challenge_scalar = Scalar::from_raw(challenge.0); let challenge_digest_crt = self.load_u256(ctx, challenge_digest); - let challenge_le = self.scalar.range().gate.assign_witnesses( + let challenge_le = fp_chip.gate().assign_witnesses( ctx, challenge .to_le_bytes() .iter() .map(|&x| Value::known(Fr::from(x as u64))), ); - let challenge_digest_mod = self.scalar.carry_mod(ctx, &challenge_digest_crt); - let challenge_crt = self - .scalar - .load_private(ctx, Value::known(fe_to_biguint(&challenge_scalar).into())); - self.scalar - .assert_equal(ctx, &challenge_digest_mod, &challenge_crt); - let challenge_limb1 = self.scalar.range().gate.inner_product( + let challenge_digest_mod = fp_chip.carry_mod(ctx, &challenge_digest_crt); + let challenge_crt = + fp_chip.load_private(ctx, Value::known(fe_to_biguint(&challenge_scalar).into())); + fp_chip.assert_equal(ctx, &challenge_digest_mod, &challenge_crt); + let challenge_limb1 = fp_chip.gate().inner_product( ctx, challenge_le[0..11] .iter() .map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - let challenge_limb2 = self.scalar.range().gate.inner_product( + let challenge_limb2 = fp_chip.gate.inner_product( ctx, challenge_le[11..22] .iter() .map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - let challenge_limb3 = self.scalar.range().gate.inner_product( + let challenge_limb3 = fp_chip.gate().inner_product( ctx, challenge_le[22..32] .iter() .map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - self.scalar.range().gate.assert_equal( + fp_chip.assert_equal( ctx, QuantumCell::Existing(challenge_limb1), QuantumCell::Existing(challenge_crt.truncation.limbs[0]), ); - self.scalar.range().gate.assert_equal( + fp_chip.assert_equal( ctx, QuantumCell::Existing(challenge_limb2), QuantumCell::Existing(challenge_crt.truncation.limbs[1]), ); - self.scalar.range().gate.assert_equal( + fp_chip.assert_equal( ctx, QuantumCell::Existing(challenge_limb3), QuantumCell::Existing(challenge_crt.truncation.limbs[2]), @@ -183,49 +180,47 @@ impl BarycentricEvaluationConfig { //////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// PRECHECKS y ///////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////// - let evaluation_le = self.scalar.range().gate.assign_witnesses( - ctx, + let evaluation_le = ctx.assign_witnesses( evaluation .to_le_bytes() .iter() .map(|&x| Value::known(Fr::from(x as u64))), ); let evaluation_scalar = Scalar::from_raw(evaluation.0); - let evaluation_crt = self - .scalar - .load_private(ctx, Value::known(fe_to_biguint(&evaluation_scalar).into())); - let evaluation_limb1 = self.scalar.range().gate.inner_product( + let evaluation_crt = + fp_chip.load_private(ctx, Value::known(fe_to_biguint(&evaluation_scalar).into())); + let evaluation_limb1 = fp_chip.inner_product( ctx, evaluation_le[0..11] .iter() .map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - let evaluation_limb2 = self.scalar.range().gate.inner_product( + let evaluation_limb2 = fp_chip.inner_product( ctx, evaluation_le[11..22] .iter() .map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - let evaluation_limb3 = self.scalar.range().gate.inner_product( + let evaluation_limb3 = fp_chip.inner_product( ctx, evaluation_le[22..32] .iter() .map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - self.scalar.range().gate.assert_equal( + fp_chip.assert_equal( ctx, QuantumCell::Existing(evaluation_limb1), QuantumCell::Existing(evaluation_crt.truncation.limbs[0]), ); - self.scalar.range().gate.assert_equal( + fp_chip.assert_equal( ctx, QuantumCell::Existing(evaluation_limb2), QuantumCell::Existing(evaluation_crt.truncation.limbs[1]), ); - self.scalar.range().gate.assert_equal( + fp_chip.assert_equal( ctx, QuantumCell::Existing(evaluation_limb3), QuantumCell::Existing(evaluation_crt.truncation.limbs[2]), @@ -240,8 +235,7 @@ impl BarycentricEvaluationConfig { .zip_eq(roots_of_unity.iter()) .for_each(|(blob_i, root_i_crt)| { // assign LE-bytes of blob scalar field element. - let blob_i_le = self.scalar.range().gate.assign_witnesses( - ctx, + let blob_i_le = ctx.assign_witnesses( blob_i .to_le_bytes() .iter() @@ -253,32 +247,32 @@ impl BarycentricEvaluationConfig { .load_private(ctx, Value::known(fe_to_biguint(&blob_i_scalar).into())); // compute the limbs for blob scalar field element. - let limb1 = self.scalar.range().gate.inner_product( + let limb1 = fp_chip.inner_product( ctx, blob_i_le[0..11].iter().map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - let limb2 = self.scalar.range().gate.inner_product( + let limb2 = fp_chip.inner_product( ctx, blob_i_le[11..22].iter().map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - let limb3 = self.scalar.range().gate.inner_product( + let limb3 = fp_chip.inner_product( ctx, blob_i_le[22..32].iter().map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - self.scalar.range().gate.assert_equal( + fp_chip.assert_equal( ctx, QuantumCell::Existing(limb1), QuantumCell::Existing(blob_i_crt.truncation.limbs[0]), ); - self.scalar.range().gate.assert_equal( + fp_chip.assert_equal( ctx, QuantumCell::Existing(limb2), QuantumCell::Existing(blob_i_crt.truncation.limbs[1]), ); - self.scalar.range().gate.assert_equal( + fp_chip.assert_equal( ctx, QuantumCell::Existing(limb3), QuantumCell::Existing(blob_i_crt.truncation.limbs[2]), @@ -286,7 +280,7 @@ impl BarycentricEvaluationConfig { // the most-significant byte of blob scalar field element is 0 as we expect this // representation to be in its canonical form. - self.scalar.range().gate.assert_equal( + fp_chip.assert_equal( ctx, QuantumCell::Existing(blob_i_le[31]), QuantumCell::Constant(Fr::zero()), diff --git a/aggregator/src/aggregation/circuit.rs b/aggregator/src/aggregation/circuit.rs index f6f4cfacd9..e91c11dd22 100644 --- a/aggregator/src/aggregation/circuit.rs +++ b/aggregator/src/aggregation/circuit.rs @@ -237,12 +237,14 @@ impl Circuit for AggregationCircuit { // - new accumulator to be verified on chain // log::debug!("aggregation: assigning aggregation"); - let (assigned_aggregation_instances, acc) = aggregate::>( + let assigned_aggregation_instances = aggregate::>( &self.svk, &loader, &self.snarks_with_padding, self.as_proof(), ); + let assigned_aggregation_instances = aggregation_witness.previous_instances; + let acc = aggregation_witness.accumulator; for (i, e) in assigned_aggregation_instances[0].iter().enumerate() { log::trace!("{}-th instance: {:?}", i, e.value) } @@ -383,7 +385,7 @@ impl Circuit for AggregationCircuit { region.constrain_equal( chunk_pi_hash_digests[i][j].cell(), - snark_inputs[i * DIGEST_LEN + j].cell(), + snark_inputs[i * DIGEST_LEN + j].cell, )?; } } diff --git a/aggregator/src/aggregation/config.rs b/aggregator/src/aggregation/config.rs index a7918df50f..cd26f19ceb 100644 --- a/aggregator/src/aggregation/config.rs +++ b/aggregator/src/aggregation/config.rs @@ -177,12 +177,12 @@ impl AggregationConfig { /// Range gate configuration pub fn range(&self) -> &RangeConfig { - &self.base_field_config.range + &self.base_field_config } /// Flex gate configuration pub fn flex_gate(&self) -> &FlexGateConfig { - &self.base_field_config.range.gate + &self.base_field_config.gate } /// Ecc gate configuration diff --git a/aggregator/src/aggregation/decoder/tables/bitstring.rs b/aggregator/src/aggregation/decoder/tables/bitstring.rs index 75329a9e66..ff7c9fc982 100644 --- a/aggregator/src/aggregation/decoder/tables/bitstring.rs +++ b/aggregator/src/aggregation/decoder/tables/bitstring.rs @@ -702,40 +702,40 @@ impl BitstringTable { } } -// impl LookupTable for BitstringTable { -// fn columns(&self) -> Vec> { -// vec![ -// self.byte_idx_1.into(), -// self.byte_idx_2.into(), -// self.byte_idx_3.into(), -// self.byte_1.into(), -// self.byte_2.into(), -// self.byte_3.into(), -// self.bitstring_value.into(), -// self.bitstring_len.into(), -// self.bit_index.into(), -// self.from_start.column.into(), -// self.until_end.column.into(), -// self.is_reverse.column.into(), -// self.is_padding.column.into(), -// ] -// } - -// fn annotations(&self) -> Vec { -// vec![ -// String::from("byte_idx_1"), -// String::from("byte_idx_2"), -// String::from("byte_idx_3"), -// String::from("byte_1"), -// String::from("byte_2"), -// String::from("byte_3"), -// String::from("bitstring_value"), -// String::from("bitstring_len"), -// String::from("bit_index"), -// String::from("from_start"), -// String::from("until_end"), -// String::from("is_reverse"), -// String::from("is_padding"), -// ] -// } -// } +impl LookupTable for BitstringTable { + fn columns(&self) -> Vec> { + vec![ + self.byte_idx_1.into(), + self.byte_idx_2.into(), + self.byte_idx_3.into(), + self.byte_1.into(), + self.byte_2.into(), + self.byte_3.into(), + self.bitstring_value.into(), + self.bitstring_len.into(), + self.bit_index.into(), + self.from_start.column.into(), + self.until_end.column.into(), + self.is_reverse.column.into(), + self.is_padding.column.into(), + ] + } + + fn annotations(&self) -> Vec { + vec![ + String::from("byte_idx_1"), + String::from("byte_idx_2"), + String::from("byte_idx_3"), + String::from("byte_1"), + String::from("byte_2"), + String::from("byte_3"), + String::from("bitstring_value"), + String::from("bitstring_len"), + String::from("bit_index"), + String::from("from_start"), + String::from("until_end"), + String::from("is_reverse"), + String::from("is_padding"), + ] + } +} diff --git a/aggregator/src/aggregation/decoder/tables/fixed.rs b/aggregator/src/aggregation/decoder/tables/fixed.rs index 3d8c969bad..a02d80b6be 100644 --- a/aggregator/src/aggregation/decoder/tables/fixed.rs +++ b/aggregator/src/aggregation/decoder/tables/fixed.rs @@ -3,7 +3,7 @@ use aggregator_snark_verifier::halo2_base::halo2_proofs::{ plonk::{Any, Column, ConstraintSystem, Error, Expression, Fixed}, }; use eth_types::Field; -// use gadgets::impl_expr; +use gadgets::impl_expr; use halo2curves::bn256::Fr; use itertools::Itertools; use strum::IntoEnumIterator; @@ -61,7 +61,7 @@ pub enum FixedLookupTag { VariableBitPacking, } -// impl_expr!(FixedLookupTag); +impl_expr!(FixedLookupTag); impl FixedLookupTag { fn values(&self) -> Vec<[Value; 7]> { @@ -130,28 +130,28 @@ impl FixedTable { } } -// impl LookupTable for FixedTable { -// fn columns(&self) -> Vec> { -// vec![ -// self.lookup_tag.into(), -// self.fixed1.into(), -// self.fixed2.into(), -// self.fixed3.into(), -// self.fixed4.into(), -// self.fixed5.into(), -// self.fixed6.into(), -// ] -// } - -// fn annotations(&self) -> Vec { -// vec![ -// String::from("lookup_tag"), -// String::from("fixed1"), -// String::from("fixed2"), -// String::from("fixed3"), -// String::from("fixed4"), -// String::from("fixed5"), -// String::from("fixed6"), -// ] -// } -// } +impl LookupTable for FixedTable { + fn columns(&self) -> Vec> { + vec![ + self.lookup_tag.into(), + self.fixed1.into(), + self.fixed2.into(), + self.fixed3.into(), + self.fixed4.into(), + self.fixed5.into(), + self.fixed6.into(), + ] + } + + fn annotations(&self) -> Vec { + vec![ + String::from("lookup_tag"), + String::from("fixed1"), + String::from("fixed2"), + String::from("fixed3"), + String::from("fixed4"), + String::from("fixed5"), + String::from("fixed6"), + ] + } +} diff --git a/aggregator/src/aggregation/decoder/tables/fse.rs b/aggregator/src/aggregation/decoder/tables/fse.rs index 7cbfc2ff41..4a054bf0bb 100644 --- a/aggregator/src/aggregation/decoder/tables/fse.rs +++ b/aggregator/src/aggregation/decoder/tables/fse.rs @@ -1820,32 +1820,32 @@ impl FseSortedStatesTable { } } -// impl LookupTable for FseSortedStatesTable { -// fn columns(&self) -> Vec> { -// vec![ -// self.block_idx.into(), -// self.table_kind.into(), -// self.table_size.into(), -// self.symbol.into(), -// self.symbol_count.into(), -// self.state.into(), -// self.baseline.into(), -// self.nb.into(), -// self.is_padding.column.into(), -// ] -// } - -// fn annotations(&self) -> Vec { -// vec![ -// String::from("block_idx"), -// String::from("table_kind"), -// String::from("table_size"), -// String::from("symbol"), -// String::from("symbol_count"), -// String::from("state"), -// String::from("baseline"), -// String::from("nb"), -// String::from("is_padding"), -// ] -// } -// } +impl LookupTable for FseSortedStatesTable { + fn columns(&self) -> Vec> { + vec![ + self.block_idx.into(), + self.table_kind.into(), + self.table_size.into(), + self.symbol.into(), + self.symbol_count.into(), + self.state.into(), + self.baseline.into(), + self.nb.into(), + self.is_padding.column.into(), + ] + } + + fn annotations(&self) -> Vec { + vec![ + String::from("block_idx"), + String::from("table_kind"), + String::from("table_size"), + String::from("symbol"), + String::from("symbol_count"), + String::from("state"), + String::from("baseline"), + String::from("nb"), + String::from("is_padding"), + ] + } +} diff --git a/aggregator/src/aggregation/decoder/tables/literals_header.rs b/aggregator/src/aggregation/decoder/tables/literals_header.rs index a382e67f7b..c6c3d2d9c2 100644 --- a/aggregator/src/aggregation/decoder/tables/literals_header.rs +++ b/aggregator/src/aggregation/decoder/tables/literals_header.rs @@ -277,31 +277,31 @@ impl LiteralsHeaderTable { } } -// impl LookupTable for LiteralsHeaderTable { -// fn columns(&self) -> Vec> { -// vec![ -// self.block_idx.into(), -// self.byte0.into(), -// self.byte1.into(), -// self.byte2.into(), -// self.size_format_bit0.into(), -// self.size_format_bit1.into(), -// self.regen_size.into(), -// self.is_padding.column.into(), -// ] -// } - -// fn annotations(&self) -> Vec { -// vec![ -// String::from("block_idx"), -// String::from("byte_offset"), -// String::from("byte0"), -// String::from("byte1"), -// String::from("byte2"), -// String::from("size_format_bit0"), -// String::from("size_format_bit1"), -// String::from("regen_size"), -// String::from("is_padding"), -// ] -// } -// } +impl LookupTable for LiteralsHeaderTable { + fn columns(&self) -> Vec> { + vec![ + self.block_idx.into(), + self.byte0.into(), + self.byte1.into(), + self.byte2.into(), + self.size_format_bit0.into(), + self.size_format_bit1.into(), + self.regen_size.into(), + self.is_padding.column.into(), + ] + } + + fn annotations(&self) -> Vec { + vec![ + String::from("block_idx"), + String::from("byte_offset"), + String::from("byte0"), + String::from("byte1"), + String::from("byte2"), + String::from("size_format_bit0"), + String::from("size_format_bit1"), + String::from("regen_size"), + String::from("is_padding"), + ] + } +} diff --git a/aggregator/src/aggregation/decoder/tables/seqinst_table.rs b/aggregator/src/aggregation/decoder/tables/seqinst_table.rs index 599028db45..46af4cd608 100644 --- a/aggregator/src/aggregation/decoder/tables/seqinst_table.rs +++ b/aggregator/src/aggregation/decoder/tables/seqinst_table.rs @@ -126,33 +126,33 @@ pub struct SeqInstTable { ref_offset_1_is_zero: IsZeroConfig, } -// impl LookupTable for SeqInstTable { -// fn columns(&self) -> Vec> { -// vec![ -// self.q_enabled.into(), -// self.block_index.into(), -// self.n_seq.into(), -// self.s_beginning.column.into(), -// self.seq_index.into(), -// self.literal_len.into(), -// self.match_offset.into(), -// self.match_len.into(), -// ] -// } - -// fn annotations(&self) -> Vec { -// vec![ -// String::from("q_enabled"), -// String::from("n_seq"), -// String::from("block_index"), -// String::from("s_beginning"), -// String::from("seq_index"), -// String::from("literal_len"), -// String::from("match_offset"), -// String::from("match_len"), -// ] -// } -// } +impl LookupTable for SeqInstTable { + fn columns(&self) -> Vec> { + vec![ + self.q_enabled.into(), + self.block_index.into(), + self.n_seq.into(), + self.s_beginning.column.into(), + self.seq_index.into(), + self.literal_len.into(), + self.match_offset.into(), + self.match_len.into(), + ] + } + + fn annotations(&self) -> Vec { + vec![ + String::from("q_enabled"), + String::from("n_seq"), + String::from("block_index"), + String::from("s_beginning"), + String::from("seq_index"), + String::from("literal_len"), + String::from("match_offset"), + String::from("match_len"), + ] + } +} #[derive(Clone, Debug)] struct ChipContext { diff --git a/aggregator/src/aggregation/decoder/witgen/types.rs b/aggregator/src/aggregation/decoder/witgen/types.rs index 1781e993f1..b814e492f5 100644 --- a/aggregator/src/aggregation/decoder/witgen/types.rs +++ b/aggregator/src/aggregation/decoder/witgen/types.rs @@ -4,7 +4,7 @@ use crate::aggregation::decoder::Expression; use aggregator_snark_verifier::halo2_base::halo2_proofs::circuit::Value; use bitstream_io::{BitRead, BitReader, LittleEndian}; use eth_types::Field; -// use gadgets::impl_expr; +use gadgets::impl_expr; use itertools::Itertools; use std::collections::HashMap; use strum_macros::EnumIter; @@ -92,7 +92,7 @@ impl From for LstreamNum { } } -// impl_expr!(LstreamNum); +impl_expr!(LstreamNum); /// Various tags that we can decode from a zstd encoded data. #[derive(Clone, Copy, Debug, EnumIter, PartialEq, Eq, Hash)] @@ -166,7 +166,7 @@ impl ZstdTag { } } -// impl_expr!(ZstdTag); +impl_expr!(ZstdTag); impl From for usize { fn from(value: ZstdTag) -> Self { @@ -186,7 +186,7 @@ pub enum FseTableKind { MLT, } -// impl_expr!(FseTableKind); +impl_expr!(FseTableKind); impl ToString for ZstdTag { fn to_string(&self) -> String { diff --git a/aggregator/src/aggregation/rlc/gates.rs b/aggregator/src/aggregation/rlc/gates.rs index fc3b15b358..39ae2eca57 100644 --- a/aggregator/src/aggregation/rlc/gates.rs +++ b/aggregator/src/aggregation/rlc/gates.rs @@ -1,10 +1,10 @@ -use aggregator_snark_verifier::halo2_base::halo2_proofs::{ +use ethers_core::utils::keccak256; +use halo2_proofs::{ arithmetic::Field, circuit::{AssignedCell, Cell, Region, RegionIndex, Value}, plonk::Error, }; use halo2curves::bn256::Fr; -use ethers_core::utils::keccak256; use zkevm_circuits::util::Challenges; // TODO: remove MAX_AGG_SNARKS and make this generic over N_SNARKS diff --git a/aggregator/src/core.rs b/aggregator/src/core.rs index 7d2bf1a7e4..3b7becd300 100644 --- a/aggregator/src/core.rs +++ b/aggregator/src/core.rs @@ -1,21 +1,13 @@ use std::iter::repeat; use aggregator_snark_verifier::{ - halo2_base::halo2_proofs::{ - circuit::{AssignedCell, Layouter, Region, Value}, - halo2curves::{ - bn256::{Bn256, Fq, Fr, G1Affine, G2Affine}, - pairing::Engine, - }, - poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, - }, loader::native::NativeLoader, pcs::{ kzg::{Bdfg21, KzgAccumulator, KzgAs}, AccumulationSchemeProver, }, util::arithmetic::fe_to_limbs, - Error, + Error as SnarkVerifierError, }; use aggregator_snark_verifier_sdk::{ halo2::{PoseidonTranscript, POSEIDON_SPEC}, @@ -23,6 +15,15 @@ use aggregator_snark_verifier_sdk::{ }; use ark_std::{end_timer, start_timer}; use ethers_core::utils::keccak256; +use halo2_proofs::{ + circuit::{AssignedCell, Layouter, Region, Value}, + halo2curves::{ + bn256::{Bn256, Fq, Fr, G1Affine, G2Affine}, + pairing::Engine, + }, + plonk::Error, + poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, +}; use itertools::Itertools; use rand::Rng; use zkevm_circuits::{ @@ -48,7 +49,7 @@ pub(crate) fn extract_accumulators_and_proof( rng: impl Rng + Send, g2: &G2Affine, s_g2: &G2Affine, -) -> Result<(KzgAccumulator, Vec), Error> { +) -> Result<(KzgAccumulator, Vec), SnarkVerifierError> { let svk = params.get_g()[0].into(); let mut transcript_read = @@ -77,7 +78,7 @@ pub(crate) fn extract_accumulators_and_proof( log::trace!("acc extraction {}-th acc check: left {:?}", i, left); log::trace!("acc extraction {}-th acc check: right {:?}", i, right); if left != right { - return Err(Error::AssertionFailure(format!( + return Err(SnarkVerifierError::AssertionFailure(format!( "accumulator check failed {left:?} {right:?}, index {i}", ))); } @@ -109,7 +110,7 @@ pub fn extract_proof_and_instances_with_pairing_check( params: &ParamsKZG, snarks: &[Snark], rng: impl Rng + Send, -) -> Result<(Vec, Vec), Error> { +) -> Result<(Vec, Vec), SnarkVerifierError> { // (old_accumulator, public inputs) -> (new_accumulator, public inputs) let (accumulator, as_proof) = extract_accumulators_and_proof(params, snarks, rng, ¶ms.g2(), ¶ms.s_g2())?; @@ -130,7 +131,7 @@ pub fn extract_proof_and_instances_with_pairing_check( log::trace!("circuit acc check: right {:?}", right); if left != right { - return Err(Error::AssertionFailure(format!( + return Err(SnarkVerifierError::AssertionFailure(format!( "accumulator check failed {left:?} {right:?}", ))); } @@ -355,7 +356,7 @@ pub(crate) fn assign_batch_hashes( chunks_are_valid: &[bool], num_valid_chunks: usize, preimages: &[Vec], -) -> Result { +) -> Result { // assign the hash table assign_keccak_table(keccak_config, layouter, challenges, preimages)?; @@ -410,7 +411,7 @@ pub(crate) fn assign_keccak_table( layouter: &mut impl Layouter, challenges: Challenges>, preimages: &[Vec], -) -> Result<(), Error> { +) -> Result<(), SnarkVerifierError> { let keccak_capacity = KeccakCircuit::::capacity_for_row(1 << LOG_DEGREE); let timer = start_timer!(|| ("multi keccak").to_string()); @@ -428,8 +429,9 @@ pub(crate) fn assign_keccak_table( // (3) batchDataHash preimage = // (chunk[0].dataHash || ... || chunk[k-1].dataHash) // each part of the preimage is mapped to image by Keccak256 - let witness = multi_keccak(preimages, challenges, keccak_capacity) - .map_err(|e| Error::AssertionFailure(format!("multi keccak assignment failed: {e:?}")))?; + let witness = multi_keccak(preimages, challenges, keccak_capacity).map_err(|e| { + SnarkVerifierError::AssertionFailure(format!("multi keccak assignment failed: {e:?}")) + })?; end_timer!(timer); layouter @@ -445,7 +447,7 @@ pub(crate) fn assign_keccak_table( Ok(()) }, ) - .map_err(|e| Error::AssertionFailure(format!("assign keccak rows: {e}")))?; + .map_err(|e| SnarkVerifierError::AssertionFailure(format!("assign keccak rows: {e}")))?; Ok(()) } @@ -458,7 +460,7 @@ pub(crate) fn assign_keccak_table( fn copy_constraints( layouter: &mut impl Layouter, hash_input_cells: &[Vec>], -) -> Result<(), Error> { +) -> Result<(), SnarkVerifierError> { let mut is_first_time = true; layouter @@ -587,7 +589,7 @@ fn copy_constraints( Ok(()) }, ) - .map_err(|e| Error::AssertionFailure(format!("assign keccak rows: {e}")))?; + .map_err(|e| SnarkVerifierError::AssertionFailure(format!("assign keccak rows: {e}")))?; Ok(()) } @@ -612,7 +614,7 @@ pub(crate) fn conditional_constraints( chunks_are_valid: &[bool], num_valid_chunks: usize, preimages: &[Vec], -) -> Result, Error> { +) -> Result, SnarkVerifierError> { layouter .assign_region( || "rlc conditional constraints", @@ -857,7 +859,7 @@ pub(crate) fn conditional_constraints( Ok(assigned_hash_cells) }, ) - .map_err(|e| Error::AssertionFailure(format!("aggregation: {e}"))) + .map_err(|e| SnarkVerifierError::AssertionFailure(format!("aggregation: {e}"))) } /// Input a list of flags whether the snark is valid diff --git a/aggregator/src/tests.rs b/aggregator/src/tests.rs index 143cc3d0c3..70755d634c 100644 --- a/aggregator/src/tests.rs +++ b/aggregator/src/tests.rs @@ -23,8 +23,7 @@ macro_rules! layer_0 { ); log::trace!("finished layer 0 pk generation for circuit"); - let snark = - gen_snark_shplonk(¶m, &pk, $circuit.clone(), &mut rng, None::).unwrap(); + let snark = gen_snark_shplonk(¶m, &pk, $circuit.clone(), None::); log::trace!("finished layer 0 snark generation for circuit"); // assert!(verify_snark_shplonk::<$circuit_type>( @@ -73,10 +72,8 @@ macro_rules! compression_layer_snark { ¶m, &pk, compression_circuit.clone(), - &mut rng, None::, // Some(&$path.join(Path::new("layer_1.snark"))), - ) - .unwrap(); + ); log::trace!( "finished layer {} snark generation for circuit", $layer_index @@ -114,13 +111,8 @@ macro_rules! compression_layer_evm { let pk = gen_pk(&$param, &compression_circuit, None); // build the snark for next layer - let proof = gen_evm_proof_shplonk( - ¶m, - &pk, - compression_circuit.clone(), - instances.clone(), - &mut rng, - ); + let proof = + gen_evm_proof_shplonk(¶m, &pk, compression_circuit.clone(), instances.clone()); log::trace!("finished layer 4 aggregation generation"); log::trace!("proof size: {}", proof.len()); @@ -172,7 +164,6 @@ macro_rules! aggregation_layer_snark { ¶m, &pk, aggregation_circuit.clone(), - &mut rng, None::, // Some(&$path.join(Path::new("layer_3.snark"))), ); log::trace!( diff --git a/aggregator/src/tests/aggregation.rs b/aggregator/src/tests/aggregation.rs index b419232434..e328ddc0ac 100644 --- a/aggregator/src/tests/aggregation.rs +++ b/aggregator/src/tests/aggregation.rs @@ -92,7 +92,7 @@ fn test_aggregation_circuit_full() { let pk = gen_pk(¶m, &circuit, None); log::trace!("finished pk generation for circuit"); - let snark = gen_snark_shplonk(¶m, &pk, circuit.clone(), &mut rng, None::).unwrap(); + let snark = gen_snark_shplonk(¶m, &pk, circuit.clone(), None::); log::trace!("finished snark generation for circuit"); // assert!(verify_snark_shplonk::>( @@ -104,7 +104,7 @@ fn test_aggregation_circuit_full() { // This set up requires two rounds of keccak for chunk's data hash let circuit: AggregationCircuit = build_new_aggregation_circuit(5, k); - let snark = gen_snark_shplonk(¶m, &pk, circuit, &mut rng, None::).unwrap(); + let snark = gen_snark_shplonk(¶m, &pk, circuit, None::); log::trace!("finished snark generation for circuit"); // assert!(verify_snark_shplonk::>( diff --git a/aggregator/src/tests/blob.rs b/aggregator/src/tests/blob.rs index 466c93c461..82152cdb39 100644 --- a/aggregator/src/tests/blob.rs +++ b/aggregator/src/tests/blob.rs @@ -121,7 +121,7 @@ impl Circuit for BlobCircuit { return Ok(AssignedBarycentricEvaluationConfig::default()); } - let gate = &config.barycentric.scalar.range.gate; + let gate = &config.barycentric.scalar.gate; // TODO: check correctness of this! let core_manager = MultiPhaseCoreManager::new(false); diff --git a/aggregator/src/tests/rlc/dynamic_hashes.rs b/aggregator/src/tests/rlc/dynamic_hashes.rs index 2dd112c576..e4a5882ff1 100644 --- a/aggregator/src/tests/rlc/dynamic_hashes.rs +++ b/aggregator/src/tests/rlc/dynamic_hashes.rs @@ -232,7 +232,7 @@ fn test_dynamic_hash_circuit() { // pk verifies the original circuit { - let snark = gen_snark_shplonk(¶ms, &pk, circuit, &mut rng, None::).unwrap(); + let snark = gen_snark_shplonk(¶ms, &pk, circuit, None::); // assert!(verify_snark_shplonk::( // ¶ms, // snark, @@ -245,7 +245,7 @@ fn test_dynamic_hash_circuit() { let a: Vec = (0..LEN * 3).map(|x| x as u8).collect::>(); let circuit = DynamicHashCircuit { inputs: a }; - let snark = gen_snark_shplonk(¶ms, &pk, circuit, &mut rng, None::).unwrap(); + let snark = gen_snark_shplonk(¶ms, &pk, circuit, None::); // assert!(verify_snark_shplonk::( // ¶ms, // snark, diff --git a/aggregator/src/tests/rlc/gates.rs b/aggregator/src/tests/rlc/gates.rs index 666a0d0a49..b9c263d81a 100644 --- a/aggregator/src/tests/rlc/gates.rs +++ b/aggregator/src/tests/rlc/gates.rs @@ -3,8 +3,8 @@ use aggregator_snark_verifier::halo2_base::halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner}, dev::MockProver, - plonk::{Circuit, ConstraintSystem, Error}, }; +use halo2_proofs::plonk::{Circuit, ConstraintSystem, Error}; use halo2curves::bn256::Fr; use zkevm_circuits::{table::KeccakTable, util::Challenges}; diff --git a/aggregator/src/util.rs b/aggregator/src/util.rs index e7fb5944ca..a087e840e1 100644 --- a/aggregator/src/util.rs +++ b/aggregator/src/util.rs @@ -6,9 +6,8 @@ use aggregator_snark_verifier::{ loader::native::NativeLoader, pcs::kzg::KzgAccumulator, }; -use halo2curves::bn256::Fr; use eth_types::Field; -use halo2curves::bn256::G1Affine; +use halo2curves::bn256::{Fr, G1Affine}; #[cfg(test)] #[ctor::ctor] @@ -116,6 +115,9 @@ pub fn flatten_accumulator<'a>( accumulator: KzgAccumulator, ) -> Vec> { let KzgAccumulator { lhs, rhs } = accumulator; + + // TODO: this prevents compilation??? + // figure out what to copy paste here..... let lhs = lhs.into_assigned(); let rhs = rhs.into_assigned(); diff --git a/gadgets/Cargo.toml b/gadgets/Cargo.toml index f773d511f2..9bf8af4dc3 100644 --- a/gadgets/Cargo.toml +++ b/gadgets/Cargo.toml @@ -13,3 +13,6 @@ strum.workspace = true [dev-dependencies] rand_xorshift.workspace = true rand.workspace = true + +[features] +circuit-params = [] diff --git a/gadgets/src/batched_is_zero.rs b/gadgets/src/batched_is_zero.rs index f3a0dd58c7..b28b99024e 100644 --- a/gadgets/src/batched_is_zero.rs +++ b/gadgets/src/batched_is_zero.rs @@ -156,6 +156,7 @@ mod test { } impl Circuit for TestCircuit { + type Params = (); type Config = TestCircuitConfig; type FloorPlanner = SimpleFloorPlanner; #[cfg(feature = "circuit-params")] diff --git a/gadgets/src/evm_word.rs b/gadgets/src/evm_word.rs index 1019304f1e..5b6ca349bf 100644 --- a/gadgets/src/evm_word.rs +++ b/gadgets/src/evm_word.rs @@ -172,6 +172,7 @@ mod tests { } impl Circuit for MyCircuit { + type Params = (); // Introduce an additional instance column here to test lookups // with public inputs. This is analogous to the bus mapping // commitment which will be provided as public inputs. diff --git a/gadgets/src/is_equal.rs b/gadgets/src/is_equal.rs index bd066d101e..f714377907 100644 --- a/gadgets/src/is_equal.rs +++ b/gadgets/src/is_equal.rs @@ -156,6 +156,7 @@ mod tests { } impl Circuit for TestCircuit { + type Params = (); type Config = TestCircuitConfig; type FloorPlanner = SimpleFloorPlanner; #[cfg(feature = "circuit-params")] diff --git a/gadgets/src/is_zero.rs b/gadgets/src/is_zero.rs index b69bb23f13..54a3ad4724 100644 --- a/gadgets/src/is_zero.rs +++ b/gadgets/src/is_zero.rs @@ -220,6 +220,7 @@ mod test { } impl Circuit for TestCircuit { + type Params = (); type Config = TestCircuitConfig; type FloorPlanner = SimpleFloorPlanner; #[cfg(feature = "circuit-params")] @@ -349,9 +350,10 @@ mod test { } impl Circuit for TestCircuit { + type Params = (); type Config = TestCircuitConfig; type FloorPlanner = SimpleFloorPlanner; - #[cfg(feature = "circuit-params")] + #[cfg(feature = "mason-circuit-params")] type Params = (); fn without_witnesses(&self) -> Self { diff --git a/gadgets/src/less_than.rs b/gadgets/src/less_than.rs index 171cd61e64..8f617c0c73 100644 --- a/gadgets/src/less_than.rs +++ b/gadgets/src/less_than.rs @@ -251,6 +251,7 @@ mod test { } impl Circuit for TestCircuit { + type Params = (); type Config = TestCircuitConfig; type FloorPlanner = SimpleFloorPlanner; #[cfg(feature = "circuit-params")] @@ -375,6 +376,7 @@ mod test { } impl Circuit for TestCircuit { + type Params = (); type Config = TestCircuitConfig; type FloorPlanner = SimpleFloorPlanner; #[cfg(feature = "circuit-params")] diff --git a/gadgets/src/monotone.rs b/gadgets/src/monotone.rs index 072e8ba90d..3ce006d815 100644 --- a/gadgets/src/monotone.rs +++ b/gadgets/src/monotone.rs @@ -136,6 +136,7 @@ mod test { impl Circuit for TestCircuit { + type Params = (); type Config = TestCircuitConfig; type FloorPlanner = SimpleFloorPlanner; #[cfg(feature = "circuit-params")] diff --git a/gadgets/src/mul_add.rs b/gadgets/src/mul_add.rs index e10fb58183..9800616187 100644 --- a/gadgets/src/mul_add.rs +++ b/gadgets/src/mul_add.rs @@ -499,6 +499,7 @@ mod test { } impl Circuit for TestCircuit { + type Params = (); type Config = TestCircuitConfig; type FloorPlanner = SimpleFloorPlanner; #[cfg(feature = "circuit-params")] diff --git a/zkevm-circuits/Cargo.toml b/zkevm-circuits/Cargo.toml index 6eca8f2d59..ba660f2c63 100644 --- a/zkevm-circuits/Cargo.toml +++ b/zkevm-circuits/Cargo.toml @@ -54,8 +54,9 @@ cli-table = "0.4" paste = "1.0" [features] -default = ["test", "test-circuits", "debug-annotations", "parallel_syn"] +default = ["test", "test-circuits", "debug-annotations", "parallel_syn", "circuit-params"] test = ["ethers-signers", "mock", "bus-mapping/test"] +circuit-params = [] scroll = ["bus-mapping/scroll", "eth-types/scroll", "mock?/scroll", "zktrie", "poseidon-codehash"] diff --git a/zkevm-circuits/src/ecc_circuit/dev.rs b/zkevm-circuits/src/ecc_circuit/dev.rs index 6e74489861..d8a1822065 100644 --- a/zkevm-circuits/src/ecc_circuit/dev.rs +++ b/zkevm-circuits/src/ecc_circuit/dev.rs @@ -14,6 +14,8 @@ use super::{EccCircuit, EccCircuitConfig, EccCircuitConfigArgs}; impl Circuit for EccCircuit { type Config = (EccCircuitConfig, Challenges); type FloorPlanner = SimpleFloorPlanner; + #[cfg(feature = "circuit-params")] + type Params = (); fn without_witnesses(&self) -> Self { Self::default() diff --git a/zkevm-circuits/src/sha256_circuit/circuit.rs b/zkevm-circuits/src/sha256_circuit/circuit.rs index b533325ae4..f41c045e65 100644 --- a/zkevm-circuits/src/sha256_circuit/circuit.rs +++ b/zkevm-circuits/src/sha256_circuit/circuit.rs @@ -1134,6 +1134,8 @@ mod tests { impl Circuit for MyCircuit { type Config = CircuitConfig; type FloorPlanner = SimpleFloorPlanner; + #[cfg(feature = "circuit-params")] + type Params = (); fn without_witnesses(&self) -> Self { unimplemented!() diff --git a/zkevm-circuits/src/sha256_circuit/test.rs b/zkevm-circuits/src/sha256_circuit/test.rs index 9a85cc0e51..b4505208f2 100644 --- a/zkevm-circuits/src/sha256_circuit/test.rs +++ b/zkevm-circuits/src/sha256_circuit/test.rs @@ -32,6 +32,8 @@ struct MyCircuit { impl Circuit for MyCircuit { type Config = (CircuitConfig, Challenges); type FloorPlanner = SimpleFloorPlanner; + #[cfg(feature = "circuit-params")] + type Params = (); fn without_witnesses(&self) -> Self { unimplemented!() diff --git a/zkevm-circuits/src/sig_circuit/dev.rs b/zkevm-circuits/src/sig_circuit/dev.rs index 1555db56c7..edd5e19444 100644 --- a/zkevm-circuits/src/sig_circuit/dev.rs +++ b/zkevm-circuits/src/sig_circuit/dev.rs @@ -39,6 +39,8 @@ impl SigCircuitTesterConfig { impl Circuit for SigCircuit { type Config = SigCircuitTesterConfig; type FloorPlanner = SimpleFloorPlanner; + #[cfg(feature = "circuit-params")] + type Params = (); fn without_witnesses(&self) -> Self { Self::default() From c2819e389835bba334425c94994ba9029e822b55 Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Mon, 24 Jun 2024 23:37:15 +0800 Subject: [PATCH 09/18] Use git branches instead of local files. Does not compile --- Cargo.lock | 381 +++++----------------- Cargo.toml | 35 +- aggregator/src/aggregation/barycentric.rs | 189 ++++++----- aggregator/src/aggregation/config.rs | 4 +- 4 files changed, 174 insertions(+), 435 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c002889b4..91b7b9648f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -156,7 +156,7 @@ checksum = "8037e03c7f462a063f28daec9fda285a9a89da003c552f8637a80b9c8fd96241" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -395,7 +395,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -427,7 +427,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -509,7 +509,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.66", + "syn 2.0.68", "which", ] @@ -781,9 +781,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.99" +version = "1.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" +checksum = "c891175c3fb232128f48de6590095e59198bbeb8620c310be349bfc3afd12c7b" dependencies = [ "jobserver", "libc", @@ -900,7 +900,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -1240,7 +1240,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -1262,7 +1262,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -1312,7 +1312,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version 0.4.0", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -1363,17 +1363,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "displaydoc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "dotenvy" version = "0.15.7" @@ -1489,7 +1478,7 @@ checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -1680,7 +1669,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.66", + "syn 2.0.68", "toml 0.7.8", "walkdir", ] @@ -1697,7 +1686,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -1722,7 +1711,7 @@ dependencies = [ "serde", "serde_json", "strum 0.24.1", - "syn 2.0.66", + "syn 2.0.68", "tempfile", "thiserror", "tiny-keccak", @@ -2029,7 +2018,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -2159,7 +2148,7 @@ checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -2236,6 +2225,7 @@ dependencies = [ [[package]] name = "halo2-base" version = "0.4.1" +source = "git+https://github.com/z2trillion/halo2-lib.git?branch=axiom/community-edition#508815c24d9963b6fdef6f1cfe6c4597c4c779ef" dependencies = [ "getset", "halo2_proofs", @@ -2274,6 +2264,7 @@ dependencies = [ [[package]] name = "halo2-ecc" version = "0.4.1" +source = "git+https://github.com/z2trillion/halo2-lib.git?branch=axiom/community-edition#508815c24d9963b6fdef6f1cfe6c4597c4c779ef" dependencies = [ "halo2-base 0.4.1", "itertools 0.11.0", @@ -2373,6 +2364,7 @@ dependencies = [ [[package]] name = "halo2curves" version = "0.1.0" +source = "git+https://github.com/scroll-tech/halo2curves?branch=use_pairing#1a1fdf259915449f937f35d80965ef69f9ad8e20" dependencies = [ "blake2b_simd", "bls12_381", @@ -2590,124 +2582,6 @@ dependencies = [ "cc", ] -[[package]] -name = "icu_collections" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" -dependencies = [ - "displaydoc", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_locid" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" -dependencies = [ - "displaydoc", - "litemap", - "tinystr", - "writeable", - "zerovec", -] - -[[package]] -name = "icu_locid_transform" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_locid_transform_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_locid_transform_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" - -[[package]] -name = "icu_normalizer" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_normalizer_data", - "icu_properties", - "icu_provider", - "smallvec", - "utf16_iter", - "utf8_iter", - "write16", - "zerovec", -] - -[[package]] -name = "icu_normalizer_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" - -[[package]] -name = "icu_properties" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f8ac670d7422d7f76b32e17a5db556510825b29ec9154f235977c9caba61036" -dependencies = [ - "displaydoc", - "icu_collections", - "icu_locid_transform", - "icu_properties_data", - "icu_provider", - "tinystr", - "zerovec", -] - -[[package]] -name = "icu_properties_data" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" - -[[package]] -name = "icu_provider" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" -dependencies = [ - "displaydoc", - "icu_locid", - "icu_provider_macros", - "stable_deref_trait", - "tinystr", - "writeable", - "yoke", - "zerofrom", - "zerovec", -] - -[[package]] -name = "icu_provider_macros" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "ident_case" version = "1.0.1" @@ -2716,14 +2590,12 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "1.0.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ - "icu_normalizer", - "icu_properties", - "smallvec", - "utf8_iter", + "unicode-bidi", + "unicode-normalization", ] [[package]] @@ -2971,11 +2843,11 @@ checksum = "d3c48237b9604c5a4702de6b824e02006c3214327564636aef27c1028a8fa0ed" [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" dependencies = [ - "spin 0.5.2", + "spin 0.9.8", ] [[package]] @@ -2992,9 +2864,9 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" dependencies = [ "cfg-if 1.0.0", "windows-targets 0.52.5", @@ -3028,12 +2900,6 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" -[[package]] -name = "litemap" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" - [[package]] name = "lock_api" version = "0.4.12" @@ -3338,7 +3204,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -3548,7 +3414,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -3612,7 +3478,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -3650,7 +3516,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -3764,7 +3630,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -3840,18 +3706,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "proptest" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31b476131c3c86cb68032fdc5cb6d5a1045e3e42d96b69fa599fd77701e1f5bf" +checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ "bit-set", "bit-vec", @@ -4632,7 +4498,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -4724,7 +4590,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -4821,6 +4687,7 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "snark-verifier" version = "0.1.0" +source = "git+https://github.com/scroll-tech/snark-verifier?branch=feat/circuit_params#1ea1b992c1fc9f36f858d0c0b3a4aa10371cb28d" dependencies = [ "bytes", "ethereum-types", @@ -4843,6 +4710,7 @@ dependencies = [ [[package]] name = "snark-verifier" version = "0.1.8" +source = "git+https://github.com/scroll-tech/snark-verifier?branch=axiom-community-edition#55c75da0b80e48a922e54e7612e5fc5370ad1556" dependencies = [ "halo2-base 0.4.1", "halo2-ecc 0.4.1", @@ -4863,6 +4731,7 @@ dependencies = [ [[package]] name = "snark-verifier-sdk" version = "0.0.1" +source = "git+https://github.com/scroll-tech/snark-verifier?branch=feat/circuit_params#1ea1b992c1fc9f36f858d0c0b3a4aa10371cb28d" dependencies = [ "bincode", "ethereum-types", @@ -4884,6 +4753,7 @@ dependencies = [ [[package]] name = "snark-verifier-sdk" version = "0.1.8" +source = "git+https://github.com/scroll-tech/snark-verifier?branch=axiom-community-edition#55c75da0b80e48a922e54e7612e5fc5370ad1556" dependencies = [ "bincode", "ethereum-types", @@ -4949,12 +4819,6 @@ dependencies = [ "der", ] -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "stacker" version = "0.1.15" @@ -5037,7 +4901,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -5055,9 +4919,9 @@ dependencies = [ [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "0d0208408ba0c3df17ed26eb06992cb1a1268d41b2c0e12e65203fbe3972cee5" [[package]] name = "svm-rs" @@ -5092,9 +4956,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.66" +version = "2.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" dependencies = [ "proc-macro2", "quote", @@ -5107,17 +4971,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" -[[package]] -name = "synstructure" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", -] - [[package]] name = "system-configuration" version = "0.5.1" @@ -5195,7 +5048,7 @@ dependencies = [ "cfg-if 1.0.0", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -5206,7 +5059,7 @@ checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", "test-case-core", ] @@ -5265,7 +5118,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -5327,16 +5180,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tinystr" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" -dependencies = [ - "displaydoc", - "zerovec", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -5377,7 +5220,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -5497,7 +5340,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] @@ -5576,12 +5419,27 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-width" version = "0.1.13" @@ -5608,9 +5466,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c25da092f0a868cdf09e8674cd3b7ef3a7d92a24253e663a2fb85e2496de56" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -5629,18 +5487,6 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" -[[package]] -name = "utf16_iter" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" - -[[package]] -name = "utf8_iter" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" - [[package]] name = "utf8parse" version = "0.2.2" @@ -5724,7 +5570,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", "wasm-bindgen-shared", ] @@ -5758,7 +5604,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", + "syn 2.0.68", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6014,18 +5860,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "write16" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" - -[[package]] -name = "writeable" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" - [[package]] name = "ws_stream_wasm" version = "0.7.4" @@ -6069,30 +5903,6 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" -[[package]] -name = "yoke" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" -dependencies = [ - "serde", - "stable_deref_trait", - "yoke-derive", - "zerofrom", -] - -[[package]] -name = "yoke-derive" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", - "synstructure", -] - [[package]] name = "zerocopy" version = "0.7.34" @@ -6110,28 +5920,7 @@ checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", -] - -[[package]] -name = "zerofrom" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" -dependencies = [ - "zerofrom-derive", -] - -[[package]] -name = "zerofrom-derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", - "synstructure", + "syn 2.0.68", ] [[package]] @@ -6151,29 +5940,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.66", -] - -[[package]] -name = "zerovec" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2cc8827d6c0994478a15c53f374f46fbd41bea663d809b14744bc42e6b109c" -dependencies = [ - "yoke", - "zerofrom", - "zerovec-derive", -] - -[[package]] -name = "zerovec-derive" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.66", + "syn 2.0.68", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 51552de6ed..74d2988b96 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ ethers-core = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = " ethers-providers = "=2.0.7" ethers-signers = "=2.0.7" ff = "0.13" -halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" } +halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1", features = ["circuit-params"] } halo2curves = { version = "0.1.0", features = [ "derive_serde" ] } poseidon-base = { package = "poseidon-base", git = "https://github.com/scroll-tech/poseidon-circuit.git", branch = "main" } hash-circuit = { package = "poseidon-circuit", git = "https://github.com/scroll-tech/poseidon-circuit.git", branch = "main" } @@ -56,13 +56,10 @@ serde = {version = "1.0", features = ["derive"] } serde_json = "1.0" serde_stacker = "0.1" sha3 = "0.10" -snark-verifier = { path = "../scroll-snark-verifier/snark-verifier" } -snark-verifier-sdk = { path = "../scroll-snark-verifier/snark-verifier-sdk", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"] } -# aggregator-snark-verifier = { git = "https://github.com/axiom-crypto/snark-verifier", branch = "community-edition", package = "snark-verifier", default-features = false, features = ["loader_halo2", "halo2-pse", "loader_evm", "revm"] } -# aggregator-snark-verifier-sdk = { git = "https://github.com/axiom-crypto/snark-verifier", branch = "community-edition", default-features = false, features = ["loader_halo2", "halo2-pse", "loader_evm", "revm"], package = "snark-verifier-sdk" } - -aggregator-snark-verifier = { path = "../snark-verifier/snark-verifier", package = "snark-verifier", default-features = false, features = ["loader_halo2", "halo2-pse", "loader_evm", "revm"] } -aggregator-snark-verifier-sdk = { path = "../snark-verifier/snark-verifier-sdk", default-features = false, features = ["loader_halo2", "halo2-pse", "loader_evm", "revm"], package = "snark-verifier-sdk" } +snark-verifier = { git = "https://github.com/scroll-tech/snark-verifier", branch = "feat/circuit_params" } +snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "feat/circuit_params", default-features = false, features = ["loader_halo2", "loader_evm", "halo2-pse"] } +aggregator-snark-verifier = { git = "https://github.com/scroll-tech/snark-verifier", branch = "axiom-community-edition", package = "snark-verifier", default-features = false, features = ["loader_halo2", "halo2-pse", "loader_evm", "revm"] } +aggregator-snark-verifier-sdk = { git = "https://github.com/scroll-tech/snark-verifier", branch = "axiom-community-edition", default-features = false, features = ["loader_halo2", "halo2-pse", "loader_evm", "revm"], package = "snark-verifier-sdk" } strum = "0.25" strum_macros = "0.25" @@ -80,9 +77,7 @@ ethers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0. ethers-etherscan = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" } ethers-signers = { git = "https://github.com/scroll-tech/ethers-rs.git", branch = "v2.0.7" } gobuild = { git = "https://github.com/scroll-tech/gobuild.git" } -halo2curves = { path = "../halo2curves" } -# halo2-base = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop" } -# halo2-ecc = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop" } +halo2curves = { git = "https://github.com/scroll-tech/halo2curves", branch = "use_pairing" } [patch."https://github.com/privacy-scaling-explorations/halo2.git"] halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" } @@ -93,24 +88,6 @@ poseidon = { git = "https://github.com/scroll-tech/poseidon.git", branch = "main [patch."https://github.com/privacy-scaling-explorations/bls12_381"] bls12_381 = { git = "https://github.com/scroll-tech/bls12_381", branch = "feat/impl_scalar_field" } -# [patch."https://github.com/axiom-crypto/halo2-lib.git"] -# halo2-base = { path = "../halo2-lib/halo2-base" } -# halo2-ecc = { path = "../halo2-lib/halo2-ecc" } -# halo2-base = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop" } -# halo2-ecc = { git = "https://github.com/scroll-tech/halo2-lib", branch = "develop" } - -# [patch."https://github.com/scroll-tech/halo2-lib.git"] -# halo2-base = { path = "../halo2-lib/halo2-base" } -# halo2-ecc = { path = "../halo2-lib/halo2-ecc" } -# halo2-base = { git = "https://github.com/axiom-crypto/halo2-lib", branch = "community-edition" } -# halo2-ecc = { git = "https://github.com/scroll-tech/halo2-lib", branch = "community-edition" } - -# [patch."https://github.com/privacy-scaling-explorations/halo2.git"] -# halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" } - -# [replace] -# "halo2_proofs:0.3.0" = { git = "https://github.com/scroll-tech/halo2.git", branch = "v1.1" } - # Definition of benchmarks profile to use. [profile.bench] opt-level = 3 diff --git a/aggregator/src/aggregation/barycentric.rs b/aggregator/src/aggregation/barycentric.rs index b4fbb8551c..583574a392 100644 --- a/aggregator/src/aggregation/barycentric.rs +++ b/aggregator/src/aggregation/barycentric.rs @@ -1,8 +1,12 @@ use aggregator_snark_verifier::{ halo2_base::{ - gates::{range::RangeConfig, GateInstructions}, + gates::{ + circuit::BaseCircuitBuilder, + range::{RangeChip, RangeConfig}, + GateInstructions, + }, halo2_proofs::circuit::Value, - utils::{fe_to_biguint, modulus}, + utils::{decompose_biguint, fe_to_biguint, modulus}, AssignedValue, QuantumCell, }, halo2_ecc::{ @@ -17,7 +21,8 @@ use aggregator_snark_verifier::{ use eth_types::{ToLittleEndian, U256}; use halo2curves::{bls12_381::Scalar, bn256::Fr, ff::PrimeField}; use itertools::Itertools; -use num_bigint::{BigInt, Sign}; +use num_bigint::{BigInt, BigUint, Sign}; +use snark_verifier::loader::halo2::IntegerInstructions; use std::{iter::successors, sync::LazyLock}; use crate::{ @@ -78,23 +83,17 @@ impl BarycentricEvaluationConfig { fn load_u256(&self, ctx: &mut Context, a: U256) -> CRTInteger { // borrowed from halo2-ecc/src/fields/fp.rs // similar to FpChip.load_private without range check. - - let a_val = Value::known(BigInt::from_bytes_le(Sign::Plus, &a.to_le_bytes())); - let a_vec = decompose_bigint_option::(a_val.as_ref(), LIMBS, BITS); + let a = BigUint::from_bytes_le(&a.to_le_bytes()); + let a_vec = decompose_biguint::(&a, LIMBS, BITS); let limbs = ctx.assign_witnesses(a_vec); - let a_native = OverflowInteger::::evaluate( - &fp_chip, - ctx, - &limbs, - self.scalar.limb_bases.iter().cloned(), - ); + // TODO: probably this will panic because it's not fully built. + let builder = BaseCircuitBuilder::default(); + let fp_chip = FpChip::::new(&builder.range_chip(), BITS, LIMBS); + let a_native = + OverflowInteger::::evaluate_native(ctx, fp_chip.gate(), limbs, &fp_chip.limb_bases); - CRTInteger::construct( - OverflowInteger::construct(limbs, self.scalar.limb_bits), - a_native, - a_val, - ) + CRTInteger::new(OverflowInteger::new(limbs, BITS), a_native, a.into()) } pub fn assign( @@ -105,10 +104,12 @@ impl BarycentricEvaluationConfig { evaluation: U256, ) -> AssignedBarycentricEvaluationConfig { // some constants for later use. - let fp_chip = FpChip::::new(&self.scalar, BITS, LIMBS); + let builder = BaseCircuitBuilder::default(); + let fp_chip = FpChip::::new(&builder.range_chip(), BITS, LIMBS); - let one = fp_chip.load_constant(ctx, fe_to_biguint(&Fr::one())); - let blob_width = fp_chip.load_constant(ctx, fe_to_biguint(&Fr::from(BLOB_WIDTH as u64))); + let one = fp_chip.load_constant(ctx, Scalar::one()); + let blob_width = + fp_chip.load_constant(ctx, Scalar::from(u64::try_from(BLOB_WIDTH).unwrap())); let powers_of_256 = std::iter::successors(Some(Fr::one()), |coeff| Some(Fr::from(256) * coeff)) @@ -118,7 +119,7 @@ impl BarycentricEvaluationConfig { let roots_of_unity = ROOTS_OF_UNITY .iter() - .map(|x| fp_chip.load_constant(ctx, fe_to_biguint(x))) + .map(|&x| fp_chip.load_constant(ctx, x)) .collect::>(); //////////////////////////////////////////////////////////////////////////////////////// @@ -129,16 +130,10 @@ impl BarycentricEvaluationConfig { let challenge_scalar = Scalar::from_raw(challenge.0); let challenge_digest_crt = self.load_u256(ctx, challenge_digest); - let challenge_le = fp_chip.gate().assign_witnesses( - ctx, - challenge - .to_le_bytes() - .iter() - .map(|&x| Value::known(Fr::from(x as u64))), - ); + let challenge_le = + ctx.assign_witnesses(challenge.to_le_bytes().iter().map(|&x| Fr::from(x as u64))); let challenge_digest_mod = fp_chip.carry_mod(ctx, &challenge_digest_crt); - let challenge_crt = - fp_chip.load_private(ctx, Value::known(fe_to_biguint(&challenge_scalar).into())); + let challenge_crt = fp_chip.load_private(ctx, challenge_scalar); fp_chip.assert_equal(ctx, &challenge_digest_mod, &challenge_crt); let challenge_limb1 = fp_chip.gate().inner_product( ctx, @@ -161,21 +156,9 @@ impl BarycentricEvaluationConfig { .map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - fp_chip.assert_equal( - ctx, - QuantumCell::Existing(challenge_limb1), - QuantumCell::Existing(challenge_crt.truncation.limbs[0]), - ); - fp_chip.assert_equal( - ctx, - QuantumCell::Existing(challenge_limb2), - QuantumCell::Existing(challenge_crt.truncation.limbs[1]), - ); - fp_chip.assert_equal( - ctx, - QuantumCell::Existing(challenge_limb3), - QuantumCell::Existing(challenge_crt.truncation.limbs[2]), - ); + fp_chip.assert_equal(ctx, challenge_limb1, challenge_crt.truncation.limbs[0]); + fp_chip.assert_equal(ctx, challenge_limb2, challenge_crt.truncation.limbs[1]); + fp_chip.assert_equal(ctx, challenge_limb3, challenge_crt.truncation.limbs[2]); //////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// PRECHECKS y ///////////////////////////////////////// @@ -184,26 +167,26 @@ impl BarycentricEvaluationConfig { evaluation .to_le_bytes() .iter() - .map(|&x| Value::known(Fr::from(x as u64))), + .map(|&x| Fr::from(u64::from(x))), ); let evaluation_scalar = Scalar::from_raw(evaluation.0); let evaluation_crt = fp_chip.load_private(ctx, Value::known(fe_to_biguint(&evaluation_scalar).into())); - let evaluation_limb1 = fp_chip.inner_product( + let evaluation_limb1 = fp_chip.gate().inner_product( ctx, evaluation_le[0..11] .iter() .map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - let evaluation_limb2 = fp_chip.inner_product( + let evaluation_limb2 = fp_chip.gate().inner_product( ctx, evaluation_le[11..22] .iter() .map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - let evaluation_limb3 = fp_chip.inner_product( + let evaluation_limb3 = fp_chip.gate().inner_product( ctx, evaluation_le[22..32] .iter() @@ -220,63 +203,56 @@ impl BarycentricEvaluationConfig { QuantumCell::Existing(evaluation_limb2), QuantumCell::Existing(evaluation_crt.truncation.limbs[1]), ); - fp_chip.assert_equal( + fp_chip.gate().assert_equal( ctx, QuantumCell::Existing(evaluation_limb3), QuantumCell::Existing(evaluation_crt.truncation.limbs[2]), ); + for (a, b) in evaluation_crt.limbs().into_iter().zip_eq([ + evaluation_limb1, + evaluation_limb2, + evaluation_limb3, + ]) { + fp_chip.gate().assert_equal(ctx, blob_limb, expected_limb); + } //////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////// BARYCENTRIC EVALUATION ////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////// let mut blob_crts = Vec::with_capacity(BLOB_WIDTH); - let mut evaluation_computed = self.scalar.load_constant(ctx, fe_to_biguint(&Fr::zero())); + let mut evaluation_computed = fp_chip.load_constant(ctx, Scalar::zero()); blob.iter() .zip_eq(roots_of_unity.iter()) .for_each(|(blob_i, root_i_crt)| { // assign LE-bytes of blob scalar field element. - let blob_i_le = ctx.assign_witnesses( - blob_i - .to_le_bytes() - .iter() - .map(|&x| Value::known(Fr::from(x as u64))), - ); + let blob_i_le = ctx + .assign_witnesses(blob_i.to_le_bytes().iter().map(|&x| Fr::from(u64::from(x)))); let blob_i_scalar = Scalar::from_raw(blob_i.0); - let blob_i_crt = self - .scalar - .load_private(ctx, Value::known(fe_to_biguint(&blob_i_scalar).into())); + let blob_i_crt = + fp_chip.load_private(ctx, Value::known(fe_to_biguint(&blob_i_scalar).into())); // compute the limbs for blob scalar field element. - let limb1 = fp_chip.inner_product( + let limb1 = fp_chip.gate().inner_product( ctx, blob_i_le[0..11].iter().map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - let limb2 = fp_chip.inner_product( + let limb2 = fp_chip.gate().inner_product( ctx, blob_i_le[11..22].iter().map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - let limb3 = fp_chip.inner_product( + let limb3 = fp_chip.gate().inner_product( ctx, blob_i_le[22..32].iter().map(|&x| QuantumCell::Existing(x)), powers_of_256[0..11].to_vec(), ); - fp_chip.assert_equal( - ctx, - QuantumCell::Existing(limb1), - QuantumCell::Existing(blob_i_crt.truncation.limbs[0]), - ); - fp_chip.assert_equal( - ctx, - QuantumCell::Existing(limb2), - QuantumCell::Existing(blob_i_crt.truncation.limbs[1]), - ); - fp_chip.assert_equal( - ctx, - QuantumCell::Existing(limb3), - QuantumCell::Existing(blob_i_crt.truncation.limbs[2]), - ); + + for (blob_limb, expected_limb) in + blob_i_crt.limbs().into_iter().zip_eq([limb1, limb2, limb3]) + { + fp_chip.gate().assert_equal(ctx, blob_limb, expected_limb); + } // the most-significant byte of blob scalar field element is 0 as we expect this // representation to be in its canonical form. @@ -287,33 +263,29 @@ impl BarycentricEvaluationConfig { ); // a = int(polynomial[i]) * int(roots_of_unity_brp[i]) % BLS_MODULUS - let a = self.scalar.mul(ctx, &blob_i_crt, root_i_crt); + let a = fp_chip.mul(ctx, &blob_i_crt, root_i_crt); // b = (int(BLS_MODULUS) + int(z) - int(roots_of_unity_brp[i])) % BLS_MODULUS - let b = self.scalar.sub_no_carry(ctx, &challenge_crt, root_i_crt); - let b = self.scalar.carry_mod(ctx, &b); + let b = fp_chip.sub_no_carry(ctx, &challenge_crt, root_i_crt); + let b = fp_chip.carry_mod(ctx, b); // y += int(div(a, b) % BLS_MODULUS) - let a_by_b = self.scalar.divide(ctx, &a, &b); - evaluation_computed = self.scalar.add_no_carry(ctx, &evaluation_computed, &a_by_b); - evaluation_computed = self.scalar.carry_mod(ctx, &evaluation_computed); + let a_by_b = fp_chip.divide(ctx, &a, &b); + let add_no_carry = fp_chip.add_no_carry(ctx, &evaluation_computed, &a_by_b); + evaluation_computed = fp_chip.carry_mod(ctx, add_no_carry); blob_crts.push(blob_i_crt); }); - let z_to_blob_width = (0..LOG_BLOB_WIDTH).fold(challenge_crt.clone(), |acc, _| { - self.scalar.mul(ctx, &acc, &acc) - }); - let z_to_blob_width_minus_one = self.scalar.sub_no_carry(ctx, &z_to_blob_width, &one); - let z_to_blob_width_minus_one = self.scalar.carry_mod(ctx, &z_to_blob_width_minus_one); - let factor = self - .scalar - .divide(ctx, &z_to_blob_width_minus_one, &blob_width); - evaluation_computed = self.scalar.mul(ctx, &evaluation_computed, &factor); - evaluation_computed = self.scalar.carry_mod(ctx, &evaluation_computed); + let z_to_blob_width = + (0..LOG_BLOB_WIDTH).fold(challenge_crt.clone(), |acc, _| fp_chip.mul(ctx, &acc, &acc)); + let z_to_blob_width_minus_one = fp_chip.sub_no_carry(ctx, &z_to_blob_width, &one); + let z_to_blob_width_minus_one = fp_chip.carry_mod(ctx, z_to_blob_width_minus_one); + let factor = fp_chip.divide(ctx, &z_to_blob_width_minus_one, &blob_width); + evaluation_computed = fp_chip.mul(ctx, &evaluation_computed, &factor); + evaluation_computed = fp_chip.carry_mod(ctx, evaluation_computed.into()); // computed evaluation matches the expected evaluation. - self.scalar - .assert_equal(ctx, &evaluation_computed, &evaluation_crt); + fp_chip.assert_equal(ctx, &evaluation_computed, &evaluation_crt); //////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////// EXPORT ////////////////////////////////////////// @@ -321,7 +293,7 @@ impl BarycentricEvaluationConfig { AssignedBarycentricEvaluationConfig { barycentric_assignments: blob_crts .into_iter() - .chain(std::iter::once(challenge_digest_crt)) + .chain(std::iter::once(ProperCrtUint::from(challenge_digest_crt))) .collect(), z_le: challenge_le, y_le: evaluation_le, @@ -340,6 +312,29 @@ pub fn interpolate(z: Scalar, coefficients: &[Scalar; BLOB_WIDTH]) -> Scalar { * Scalar::from(blob_width).invert().unwrap() } +fn assert_le_bytes_equal_crt( + gate: &GateChip, + le_bytes: [AssignedValue; 32], + crt: &CRTInteger, + powers_of_256: [QuantumCell; 11], +) { + for (limb_le_bytes, limb) in [ + le_bytes[0..11].iter(), + le_bytes[11..22].iter(), + le_bytes[22..32].iter(), + ] + .iter() + .zip_eq(crt.limbs()) + { + let limb_from_le_bytes = gate.inner_product( + ctx, + limb_le_bytes.map(|&x| QuantumCell::Existing(x)), + &powers_of_256[..limb_le_bytes.len()], + ); + gate.assert_equal(ctx, limb, limb_from_le_bytes); + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/aggregator/src/aggregation/config.rs b/aggregator/src/aggregation/config.rs index cd26f19ceb..e7c36e0c13 100644 --- a/aggregator/src/aggregation/config.rs +++ b/aggregator/src/aggregation/config.rs @@ -182,12 +182,12 @@ impl AggregationConfig { /// Flex gate configuration pub fn flex_gate(&self) -> &FlexGateConfig { - &self.base_field_config.gate + self.ecc_chip().gate() } /// Ecc gate configuration pub fn ecc_chip(&self) -> BaseFieldEccChip { - EccChip::construct(self.base_field_config.clone()) + EccChip::new(&self.base_field_config) } } From 3e57a8f4e3486a54d9b989bda34db38184004c06 Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Thu, 27 Jun 2024 16:44:08 +0800 Subject: [PATCH 10/18] wip --- aggregator/src/aggregation/barycentric.rs | 130 ++++++---------------- aggregator/src/aggregation/circuit.rs | 6 +- aggregator/src/compression/circuit.rs | 3 + aggregator/src/compression/config.rs | 7 +- aggregator/src/core.rs | 17 ++- aggregator/src/util.rs | 7 +- 6 files changed, 61 insertions(+), 109 deletions(-) diff --git a/aggregator/src/aggregation/barycentric.rs b/aggregator/src/aggregation/barycentric.rs index 583574a392..2ff9da82bd 100644 --- a/aggregator/src/aggregation/barycentric.rs +++ b/aggregator/src/aggregation/barycentric.rs @@ -1,7 +1,9 @@ +use aggregator_snark_verifier::loader::halo2::IntegerInstructions; use aggregator_snark_verifier::{ halo2_base::{ gates::{ circuit::BaseCircuitBuilder, + flex_gate::GateChip, range::{RangeChip, RangeConfig}, GateInstructions, }, @@ -22,7 +24,6 @@ use eth_types::{ToLittleEndian, U256}; use halo2curves::{bls12_381::Scalar, bn256::Fr, ff::PrimeField}; use itertools::Itertools; use num_bigint::{BigInt, BigUint, Sign}; -use snark_verifier::loader::halo2::IntegerInstructions; use std::{iter::successors, sync::LazyLock}; use crate::{ @@ -104,6 +105,7 @@ impl BarycentricEvaluationConfig { evaluation: U256, ) -> AssignedBarycentricEvaluationConfig { // some constants for later use. + // todo: move builder up... let builder = BaseCircuitBuilder::default(); let fp_chip = FpChip::::new(&builder.range_chip(), BITS, LIMBS); @@ -132,33 +134,17 @@ impl BarycentricEvaluationConfig { let challenge_digest_crt = self.load_u256(ctx, challenge_digest); let challenge_le = ctx.assign_witnesses(challenge.to_le_bytes().iter().map(|&x| Fr::from(x as u64))); + assert_le_bytes_equal_crt( + ctx, + fp_chip.gate(), + &challenge_le, + &challenge_digest_crt, + &powers_of_256, + ); + let challenge_digest_mod = fp_chip.carry_mod(ctx, &challenge_digest_crt); let challenge_crt = fp_chip.load_private(ctx, challenge_scalar); fp_chip.assert_equal(ctx, &challenge_digest_mod, &challenge_crt); - let challenge_limb1 = fp_chip.gate().inner_product( - ctx, - challenge_le[0..11] - .iter() - .map(|&x| QuantumCell::Existing(x)), - powers_of_256[0..11].to_vec(), - ); - let challenge_limb2 = fp_chip.gate.inner_product( - ctx, - challenge_le[11..22] - .iter() - .map(|&x| QuantumCell::Existing(x)), - powers_of_256[0..11].to_vec(), - ); - let challenge_limb3 = fp_chip.gate().inner_product( - ctx, - challenge_le[22..32] - .iter() - .map(|&x| QuantumCell::Existing(x)), - powers_of_256[0..11].to_vec(), - ); - fp_chip.assert_equal(ctx, challenge_limb1, challenge_crt.truncation.limbs[0]); - fp_chip.assert_equal(ctx, challenge_limb2, challenge_crt.truncation.limbs[1]); - fp_chip.assert_equal(ctx, challenge_limb3, challenge_crt.truncation.limbs[2]); //////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// PRECHECKS y ///////////////////////////////////////// @@ -169,52 +155,18 @@ impl BarycentricEvaluationConfig { .iter() .map(|&x| Fr::from(u64::from(x))), ); - let evaluation_scalar = Scalar::from_raw(evaluation.0); - let evaluation_crt = - fp_chip.load_private(ctx, Value::known(fe_to_biguint(&evaluation_scalar).into())); - let evaluation_limb1 = fp_chip.gate().inner_product( - ctx, - evaluation_le[0..11] - .iter() - .map(|&x| QuantumCell::Existing(x)), - powers_of_256[0..11].to_vec(), - ); - let evaluation_limb2 = fp_chip.gate().inner_product( + let evaluation_crt = fp_chip.load_private( ctx, - evaluation_le[11..22] - .iter() - .map(|&x| QuantumCell::Existing(x)), - powers_of_256[0..11].to_vec(), + Value::known(fe_to_biguint(&Scalar::from_raw(evaluation.0)).into()), ); - let evaluation_limb3 = fp_chip.gate().inner_product( - ctx, - evaluation_le[22..32] - .iter() - .map(|&x| QuantumCell::Existing(x)), - powers_of_256[0..11].to_vec(), - ); - fp_chip.assert_equal( - ctx, - QuantumCell::Existing(evaluation_limb1), - QuantumCell::Existing(evaluation_crt.truncation.limbs[0]), - ); - fp_chip.assert_equal( - ctx, - QuantumCell::Existing(evaluation_limb2), - QuantumCell::Existing(evaluation_crt.truncation.limbs[1]), - ); - fp_chip.gate().assert_equal( + + assert_le_bytes_equal_crt( ctx, - QuantumCell::Existing(evaluation_limb3), - QuantumCell::Existing(evaluation_crt.truncation.limbs[2]), + fp_chip.gate(), + &evaluation_le, + &evaluation_crt, + &powers_of_256, ); - for (a, b) in evaluation_crt.limbs().into_iter().zip_eq([ - evaluation_limb1, - evaluation_limb2, - evaluation_limb3, - ]) { - fp_chip.gate().assert_equal(ctx, blob_limb, expected_limb); - } //////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////// BARYCENTRIC EVALUATION ////////////////////////////////// @@ -228,39 +180,19 @@ impl BarycentricEvaluationConfig { let blob_i_le = ctx .assign_witnesses(blob_i.to_le_bytes().iter().map(|&x| Fr::from(u64::from(x)))); let blob_i_scalar = Scalar::from_raw(blob_i.0); - let blob_i_crt = - fp_chip.load_private(ctx, Value::known(fe_to_biguint(&blob_i_scalar).into())); + let blob_i_crt = fp_chip.load_private(ctx, fe_to_biguint(&blob_i_scalar)); - // compute the limbs for blob scalar field element. - let limb1 = fp_chip.gate().inner_product( + assert_le_bytes_equal_crt( ctx, - blob_i_le[0..11].iter().map(|&x| QuantumCell::Existing(x)), - powers_of_256[0..11].to_vec(), - ); - let limb2 = fp_chip.gate().inner_product( - ctx, - blob_i_le[11..22].iter().map(|&x| QuantumCell::Existing(x)), - powers_of_256[0..11].to_vec(), - ); - let limb3 = fp_chip.gate().inner_product( - ctx, - blob_i_le[22..32].iter().map(|&x| QuantumCell::Existing(x)), - powers_of_256[0..11].to_vec(), + fp_chip.gate(), + &blob_i_le, + &blob_i_crt, + &powers_of_256, ); - for (blob_limb, expected_limb) in - blob_i_crt.limbs().into_iter().zip_eq([limb1, limb2, limb3]) - { - fp_chip.gate().assert_equal(ctx, blob_limb, expected_limb); - } - // the most-significant byte of blob scalar field element is 0 as we expect this // representation to be in its canonical form. - fp_chip.assert_equal( - ctx, - QuantumCell::Existing(blob_i_le[31]), - QuantumCell::Constant(Fr::zero()), - ); + fp_chip.gate().assert_equal(ctx, &blob_i_le[31], Fr::zero()); // a = int(polynomial[i]) * int(roots_of_unity_brp[i]) % BLS_MODULUS let a = fp_chip.mul(ctx, &blob_i_crt, root_i_crt); @@ -313,11 +245,15 @@ pub fn interpolate(z: Scalar, coefficients: &[Scalar; BLOB_WIDTH]) -> Scalar { } fn assert_le_bytes_equal_crt( + ctx: &mut Context, gate: &GateChip, - le_bytes: [AssignedValue; 32], + le_bytes: &[AssignedValue], crt: &CRTInteger, - powers_of_256: [QuantumCell; 11], + powers_of_256: &[QuantumCell], ) { + assert_eq!(le_bytes.len(), 32); + assert_eq!(powers_of_256.len(), 11); + for (limb_le_bytes, limb) in [ le_bytes[0..11].iter(), le_bytes[11..22].iter(), @@ -331,7 +267,7 @@ fn assert_le_bytes_equal_crt( limb_le_bytes.map(|&x| QuantumCell::Existing(x)), &powers_of_256[..limb_le_bytes.len()], ); - gate.assert_equal(ctx, limb, limb_from_le_bytes); + gate.assert_equal(ctx, limb, &limb_from_le_bytes); } } diff --git a/aggregator/src/aggregation/circuit.rs b/aggregator/src/aggregation/circuit.rs index e91c11dd22..7729b51326 100644 --- a/aggregator/src/aggregation/circuit.rs +++ b/aggregator/src/aggregation/circuit.rs @@ -197,7 +197,7 @@ impl Circuit for AggregationCircuit { ); config.barycentric.scalar.range.finalize(&mut ctx); - ctx.print_stats(&["barycentric evaluation"]); + // ctx.print_stats(&["barycentric evaluation"]); Ok(barycentric) }, @@ -262,7 +262,7 @@ impl Circuit for AggregationCircuit { .flat_map(|instance_column| instance_column.iter().skip(ACC_LEN)), ); - loader.ctx_mut().print_stats(&["snark aggregation"]); + // loader.ctx_mut().print_stats(&["snark aggregation"]); let mut ctx = Rc::into_inner(loader).unwrap().into_ctx(); log::debug!("aggregation: assigning barycentric"); @@ -275,7 +275,7 @@ impl Circuit for AggregationCircuit { self.batch_hash.point_evaluation_assignments.evaluation, ); - ctx.print_stats(&["barycentric"]); + // ctx.print_stats(&["barycentric"]); config.range().finalize(&mut ctx); diff --git a/aggregator/src/compression/circuit.rs b/aggregator/src/compression/circuit.rs index 9e693c895e..ea38c7f866 100644 --- a/aggregator/src/compression/circuit.rs +++ b/aggregator/src/compression/circuit.rs @@ -135,6 +135,9 @@ impl Circuit for CompressionCircuit { self.as_proof(), ); + let acc: KzgAccumulator>> = + acc; + // instance of the compression circuit is defined as // - accumulators // - re-export the public input from snark diff --git a/aggregator/src/compression/config.rs b/aggregator/src/compression/config.rs index 111483d63f..150ce37282 100644 --- a/aggregator/src/compression/config.rs +++ b/aggregator/src/compression/config.rs @@ -60,16 +60,17 @@ impl CompressionConfig { /// Range gate configuration pub fn range(&self) -> &RangeConfig { - &self.base_field_config.range + &self.base_field_config } /// Flex gate configuration pub fn gate(&self) -> &FlexGateConfig { - &self.base_field_config.range.gate + &self.base_field_config.gate } /// Ecc gate configuration pub fn ecc_chip(&self) -> BaseFieldEccChip { - EccChip::construct(self.base_field_config.clone()) + unimplemented!() + // EccChip::construct(self.base_field_config.clone()) } } diff --git a/aggregator/src/core.rs b/aggregator/src/core.rs index 3b7becd300..a8a4c9c541 100644 --- a/aggregator/src/core.rs +++ b/aggregator/src/core.rs @@ -4,14 +4,14 @@ use aggregator_snark_verifier::{ loader::native::NativeLoader, pcs::{ kzg::{Bdfg21, KzgAccumulator, KzgAs}, - AccumulationSchemeProver, + AccumulationScheme, AccumulationSchemeProver, }, util::arithmetic::fe_to_limbs, Error as SnarkVerifierError, }; use aggregator_snark_verifier_sdk::{ halo2::{PoseidonTranscript, POSEIDON_SPEC}, - PlonkVerifier, Snark, + PlonkVerifier, Snark, SHPLONK, }; use ark_std::{end_timer, start_timer}; use ethers_core::utils::keccak256; @@ -40,6 +40,9 @@ use crate::{ PREV_STATE_ROOT_INDEX, WITHDRAW_ROOT_INDEX, }; +// type PlonkSuccinctVerifier = PlonkSuccinctVerifier; +// type PlonkVerifier = verifier::plonk::PlonkVerifier>; + /// Subroutine for the witness generations. /// Extract the accumulator and proof that from previous snarks. /// Uses SHPlonk for accumulation. @@ -58,7 +61,7 @@ pub(crate) fn extract_accumulators_and_proof( .iter() .flat_map(|snark| { transcript_read.new_stream(snark.proof.as_slice()); - let proof = KzgAs::read_proof( + let proof = PlonkSuccinctVerifier::::read_proof( &svk, &snark.protocol, &snark.instances, @@ -66,9 +69,15 @@ pub(crate) fn extract_accumulators_and_proof( ); // each accumulator has (lhs, rhs) based on Shplonk // lhs and rhs are EC points - KzgAs::verify(&svk, &snark.protocol, &snark.instances, &proof) + PlonkSuccinctVerifier::::verify( + &svk, + &snark.protocol, + &snark.instances, + &proof, + ) }) .collect::>(); + // sanity check on the accumulator { for (i, acc) in accumulators.iter().enumerate() { diff --git a/aggregator/src/util.rs b/aggregator/src/util.rs index a087e840e1..c0ef8402f9 100644 --- a/aggregator/src/util.rs +++ b/aggregator/src/util.rs @@ -3,7 +3,10 @@ use aggregator_snark_verifier::{ halo2_proofs::{circuit::AssignedCell, plonk::Error}, AssignedValue, }, - loader::native::NativeLoader, + loader::halo2::{ + halo2_ecc::ecc::{BaseFieldEccChip, EccChip}, + Halo2Loader, + }, pcs::kzg::KzgAccumulator, }; use eth_types::Field; @@ -112,7 +115,7 @@ pub(crate) fn rlc(inputs: &[Fr], randomness: &Fr) -> Fr { // TODO: does this already exist in snark-verifier? pub fn flatten_accumulator<'a>( - accumulator: KzgAccumulator, + accumulator: Rc>>>, ) -> Vec> { let KzgAccumulator { lhs, rhs } = accumulator; From f16421fc7787ad3ca9186b20d86cb5cd7d28006a Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Thu, 27 Jun 2024 23:38:25 +0800 Subject: [PATCH 11/18] fix barycentric circuit compilation errors --- aggregator/src/aggregation/barycentric.rs | 36 +++++++-------- aggregator/src/aggregation/batch_data.rs | 56 ++++++++++++++++------- aggregator/src/aggregation/blob_data.rs | 20 ++++---- aggregator/src/aggregation/circuit.rs | 11 ++++- aggregator/src/compression/circuit.rs | 8 ++-- aggregator/src/compression/config.rs | 21 +++++---- aggregator/src/util.rs | 1 + 7 files changed, 96 insertions(+), 57 deletions(-) diff --git a/aggregator/src/aggregation/barycentric.rs b/aggregator/src/aggregation/barycentric.rs index 2ff9da82bd..da2e269368 100644 --- a/aggregator/src/aggregation/barycentric.rs +++ b/aggregator/src/aggregation/barycentric.rs @@ -2,7 +2,7 @@ use aggregator_snark_verifier::loader::halo2::IntegerInstructions; use aggregator_snark_verifier::{ halo2_base::{ gates::{ - circuit::BaseCircuitBuilder, + circuit::builder::BaseCircuitBuilder, flex_gate::GateChip, range::{RangeChip, RangeConfig}, GateInstructions, @@ -12,7 +12,7 @@ use aggregator_snark_verifier::{ AssignedValue, QuantumCell, }, halo2_ecc::{ - bigint::{CRTInteger, OverflowInteger}, + bigint::{CRTInteger, OverflowInteger, ProperCrtUint}, fields::{ fp::{FpChip, FpConfig}, FieldChip, @@ -99,7 +99,7 @@ impl BarycentricEvaluationConfig { pub fn assign( &self, - ctx: &mut Context, + ctx: &mut SinglePhaseCoreManager, blob: &[U256; BLOB_WIDTH], challenge_digest: U256, evaluation: U256, @@ -138,11 +138,11 @@ impl BarycentricEvaluationConfig { ctx, fp_chip.gate(), &challenge_le, - &challenge_digest_crt, + &challenge_digest_crt.limbs(), &powers_of_256, ); - let challenge_digest_mod = fp_chip.carry_mod(ctx, &challenge_digest_crt); + let challenge_digest_mod = fp_chip.carry_mod(ctx, challenge_digest_crt); let challenge_crt = fp_chip.load_private(ctx, challenge_scalar); fp_chip.assert_equal(ctx, &challenge_digest_mod, &challenge_crt); @@ -155,16 +155,13 @@ impl BarycentricEvaluationConfig { .iter() .map(|&x| Fr::from(u64::from(x))), ); - let evaluation_crt = fp_chip.load_private( - ctx, - Value::known(fe_to_biguint(&Scalar::from_raw(evaluation.0)).into()), - ); + let evaluation_crt = fp_chip.load_private(ctx, Scalar::from_raw(evaluation.0)); assert_le_bytes_equal_crt( ctx, fp_chip.gate(), &evaluation_le, - &evaluation_crt, + &evaluation_crt.limbs(), &powers_of_256, ); @@ -180,19 +177,21 @@ impl BarycentricEvaluationConfig { let blob_i_le = ctx .assign_witnesses(blob_i.to_le_bytes().iter().map(|&x| Fr::from(u64::from(x)))); let blob_i_scalar = Scalar::from_raw(blob_i.0); - let blob_i_crt = fp_chip.load_private(ctx, fe_to_biguint(&blob_i_scalar)); + let blob_i_crt = fp_chip.load_private(ctx, blob_i_scalar); assert_le_bytes_equal_crt( ctx, fp_chip.gate(), &blob_i_le, - &blob_i_crt, + &blob_i_crt.limbs(), &powers_of_256, ); // the most-significant byte of blob scalar field element is 0 as we expect this // representation to be in its canonical form. - fp_chip.gate().assert_equal(ctx, &blob_i_le[31], Fr::zero()); + fp_chip + .gate() + .assert_is_const(ctx, &blob_i_le[31], &Fr::zero()); // a = int(polynomial[i]) * int(roots_of_unity_brp[i]) % BLS_MODULUS let a = fp_chip.mul(ctx, &blob_i_crt, root_i_crt); @@ -225,7 +224,8 @@ impl BarycentricEvaluationConfig { AssignedBarycentricEvaluationConfig { barycentric_assignments: blob_crts .into_iter() - .chain(std::iter::once(ProperCrtUint::from(challenge_digest_crt))) + .map(CRTInteger::from) + .chain(std::iter::once(challenge_digest_crt)) .collect(), z_le: challenge_le, y_le: evaluation_le, @@ -245,10 +245,10 @@ pub fn interpolate(z: Scalar, coefficients: &[Scalar; BLOB_WIDTH]) -> Scalar { } fn assert_le_bytes_equal_crt( - ctx: &mut Context, + ctx: &mut SinglePhaseCoreManager, gate: &GateChip, le_bytes: &[AssignedValue], - crt: &CRTInteger, + crt_limbs: &[AssignedValue], powers_of_256: &[QuantumCell], ) { assert_eq!(le_bytes.len(), 32); @@ -260,12 +260,12 @@ fn assert_le_bytes_equal_crt( le_bytes[22..32].iter(), ] .iter() - .zip_eq(crt.limbs()) + .zip_eq(crt_limbs) { let limb_from_le_bytes = gate.inner_product( ctx, limb_le_bytes.map(|&x| QuantumCell::Existing(x)), - &powers_of_256[..limb_le_bytes.len()], + powers_of_256[..limb_le_bytes.len()].into_iter().cloned(), ); gate.assert_equal(ctx, limb, &limb_from_le_bytes); } diff --git a/aggregator/src/aggregation/batch_data.rs b/aggregator/src/aggregation/batch_data.rs index b095b19c70..3b3b5fcb8e 100644 --- a/aggregator/src/aggregation/batch_data.rs +++ b/aggregator/src/aggregation/batch_data.rs @@ -1,9 +1,13 @@ use aggregator_snark_verifier::{ - halo2_base::halo2_proofs::{ - circuit::{AssignedCell, Layouter, Region, Value}, - halo2curves::bn256::Fr, - plonk::{Advice, Column, ConstraintSystem, Error, Expression, SecondPhase, Selector}, - poly::Rotation, + halo2_base::{ + halo2_proofs::{ + circuit::{AssignedCell, Layouter, Region, Value}, + halo2curves::bn256::Fr, + plonk::{Advice, Column, ConstraintSystem, Error, Expression, SecondPhase, Selector}, + poly::Rotation, + }, + utils::halo2::constrain_virtual_equals_external, + virtual_region::copy_constraints::CopyConstraintManager, }, halo2_ecc::bigint::CRTInteger, }; @@ -533,6 +537,7 @@ impl BatchDataConfig { chunks_are_padding: &[AssignedCell], barycentric_assignments: &[CRTInteger], assigned_rows: &[AssignedBatchDataConfig], + copy_manager: &mut CopyConstraintManager, ) -> Result { let n_rows_metadata = BatchData::::n_rows_metadata(); let n_rows_digest_rlc = BatchData::::n_rows_digest_rlc(); @@ -1000,18 +1005,35 @@ impl BatchDataConfig { &pows_of_256[0..10], &mut rlc_config_offset, )?; - region.constrain_equal( - challenge_digest_limb1.cell(), - challenge_digest_crt.truncation.limbs[0].cell(), - )?; - region.constrain_equal( - challenge_digest_limb2.cell(), - challenge_digest_crt.truncation.limbs[1].cell(), - )?; - region.constrain_equal( - challenge_digest_limb3.cell(), - challenge_digest_crt.truncation.limbs[2].cell(), - )?; + + for (external_value, virtual_value) in [ + challenge_digest_limb1, + challenge_digest_limb2, + challenge_digest_limb3, + ] + .into_iter() + .zip_eq(challenge_digest_crt.truncation.limbs.into_iter()) + { + constrain_virtual_equals_external( + region, + virtual_value, + external_value.cell(), + copy_manager, + ) + } + + // region.constrain_equal( + // challenge_digest_limb1.cell(), + // challenge_digest_crt.truncation.limbs[0].cell(), + // )?; + // region.constrain_equal( + // challenge_digest_limb2.cell(), + // challenge_digest_crt.truncation.limbs[1].cell(), + // )?; + // region.constrain_equal( + // challenge_digest_limb3.cell(), + // challenge_digest_crt.truncation.limbs[2].cell(), + // )?; Ok(export) } diff --git a/aggregator/src/aggregation/blob_data.rs b/aggregator/src/aggregation/blob_data.rs index dc8e9f13e5..91fab95e5c 100644 --- a/aggregator/src/aggregation/blob_data.rs +++ b/aggregator/src/aggregation/blob_data.rs @@ -1,11 +1,14 @@ use std::io::Write; use aggregator_snark_verifier::{ - halo2_base::halo2_proofs::{ - circuit::{AssignedCell, Layouter, Region, Value}, - halo2curves::bn256::Fr, - plonk::{Advice, Column, ConstraintSystem, Error, Expression, SecondPhase, Selector}, - poly::Rotation, + halo2_base::{ + halo2_proofs::{ + circuit::{AssignedCell, Layouter, Region, Value}, + halo2curves::bn256::Fr, + plonk::{Advice, Column, ConstraintSystem, Error, Expression, SecondPhase, Selector}, + poly::Rotation, + }, + virtual_region::copy_constraints::CopyConstraintManager, }, halo2_ecc::bigint::CRTInteger, }; @@ -282,6 +285,7 @@ impl BlobDataConfig { barycentric_assignments: &[CRTInteger], assigned_bytes: &[AssignedCell], bytes_len: &AssignedCell, + copy_manager: &&mut CopyConstraintManager, ) -> Result, Error> { rlc_config.init(region)?; let mut rlc_config_offset = 0; @@ -344,9 +348,9 @@ impl BlobDataConfig { &pows_of_256[0..9], &mut rlc_config_offset, )?; - region.constrain_equal(limb1.cell(), blob_crt.truncation.limbs[0].cell())?; - region.constrain_equal(limb2.cell(), blob_crt.truncation.limbs[1].cell())?; - region.constrain_equal(limb3.cell(), blob_crt.truncation.limbs[2].cell())?; + region.constrain_equal(limb1.cell(), blob_crt.truncation.limbs[0].cell)?; + region.constrain_equal(limb2.cell(), blob_crt.truncation.limbs[1].cell)?; + region.constrain_equal(limb3.cell(), blob_crt.truncation.limbs[2].cell)?; } // The zstd decoder (DecoderConfig) exports an encoded length that is 1 more than the diff --git a/aggregator/src/aggregation/circuit.rs b/aggregator/src/aggregation/circuit.rs index 7729b51326..66eeb43d24 100644 --- a/aggregator/src/aggregation/circuit.rs +++ b/aggregator/src/aggregation/circuit.rs @@ -159,6 +159,11 @@ impl Circuit for AggregationCircuit { config: Self::Config, mut layouter: impl Layouter, ) -> Result<(), Error> { + // let builder = BaseCircuitBuilder + // builder.core.copy_manager .... + + let builder = BaseCircuitBuilder::default(); + let (config, challenge) = config; let witness_time = start_timer!(|| "synthesize | Aggregation Circuit"); @@ -277,7 +282,8 @@ impl Circuit for AggregationCircuit { // ctx.print_stats(&["barycentric"]); - config.range().finalize(&mut ctx); + // TODO: figure out where to call this!!! + // config.range().finalize(&mut ctx); Ok((accumulator_instances, snark_inputs, barycentric)) }, @@ -402,7 +408,8 @@ impl Circuit for AggregationCircuit { { assert!(accumulator_instances.len() == ACC_LEN); for (i, v) in accumulator_instances.iter().enumerate() { - layouter.constrain_instance(v.cell(), config.instance, i)?; + // let cell: halo2_proofs::circuit::Cell = v.cell(); + layouter.constrain_instance(v.cell.unwrap(), config.instance, i)?; } } diff --git a/aggregator/src/compression/circuit.rs b/aggregator/src/compression/circuit.rs index ea38c7f866..4afe898cc8 100644 --- a/aggregator/src/compression/circuit.rs +++ b/aggregator/src/compression/circuit.rs @@ -26,6 +26,7 @@ use aggregator_snark_verifier::{ }, pcs::kzg::{Bdfg21, KzgAs, KzgSuccinctVerifyingKey}, }; +use aggregator_snark_verifier_sdk::halo2::aggregation::BaseFieldEccChip; use aggregator_snark_verifier_sdk::{ halo2::aggregation::{aggregate, Svk}, Snark, @@ -144,7 +145,7 @@ impl Circuit for CompressionCircuit { instances.extend( flatten_accumulator(acc) .iter() - .map(|assigned| assigned.cell()), + .map(|assigned| assigned.cell), ); // - if the snark is not a fresh one, assigned_instances already contains an // accumulator so we want to skip the first 12 elements from the public input @@ -153,9 +154,10 @@ impl Circuit for CompressionCircuit { instance_column.iter().skip(skip).map(|x| x.cell()) })); - config.range().finalize(&mut loader.ctx_mut()); + // TODO: figure out where to call this! + // config.range().finalize(&mut loader.ctx_mut()); - loader.ctx_mut().print_stats(&["Range"]); + // loader.ctx_mut().print_stats(&["Range"]); Ok(instances) }, )?; diff --git a/aggregator/src/compression/config.rs b/aggregator/src/compression/config.rs index 150ce37282..03f8a67d22 100644 --- a/aggregator/src/compression/config.rs +++ b/aggregator/src/compression/config.rs @@ -7,7 +7,10 @@ use aggregator_snark_verifier::{ ecc::{BaseFieldEccChip, EccChip}, fields::fp::FpConfig, halo2_base::{ - gates::{flex_gate::FlexGateConfig, range::RangeConfig}, + gates::{ + flex_gate::{FlexGateConfig, FlexGateConfigParams}, + range::RangeConfig, + }, utils::modulus, }, }, @@ -35,18 +38,18 @@ impl CompressionConfig { params.limb_bits == BITS && params.num_limbs == LIMBS, "For now we fix limb_bits = {BITS}, otherwise change code", ); + + let gate_params = FlexGateConfigParams { + k: params.degree.try_into().unwrap(), + num_fixed: params.num_fixed, + num_advice_per_phase: params.num_advice, + }; + let base_field_config = FpConfig::configure( meta, - params.strategy, - ¶ms.num_advice, + gate_params, ¶ms.num_lookup_advice, - params.num_fixed, params.lookup_bits, - params.limb_bits, - params.num_limbs, - modulus::(), - 0, - params.degree as usize, ); let instance = meta.instance_column(); diff --git a/aggregator/src/util.rs b/aggregator/src/util.rs index c0ef8402f9..287a895144 100644 --- a/aggregator/src/util.rs +++ b/aggregator/src/util.rs @@ -9,6 +9,7 @@ use aggregator_snark_verifier::{ }, pcs::kzg::KzgAccumulator, }; +// use std::rc::Rc; use eth_types::Field; use halo2curves::bn256::{Fr, G1Affine}; From 6ba0925cfc2ea4b6473c4c99e2a50450e5fa945c Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Mon, 1 Jul 2024 15:29:40 +0800 Subject: [PATCH 12/18] wip --- aggregator/src/aggregation/barycentric.rs | 12 +++++--- aggregator/src/aggregation/blob_data.rs | 18 ++++++++--- aggregator/src/aggregation/circuit.rs | 11 ++++--- aggregator/src/aggregation/config.rs | 3 +- aggregator/src/compression/circuit.rs | 1 + aggregator/src/tests/blob.rs | 2 ++ aggregator/src/util.rs | 37 ++++++++++++----------- 7 files changed, 52 insertions(+), 32 deletions(-) diff --git a/aggregator/src/aggregation/barycentric.rs b/aggregator/src/aggregation/barycentric.rs index da2e269368..729f20f999 100644 --- a/aggregator/src/aggregation/barycentric.rs +++ b/aggregator/src/aggregation/barycentric.rs @@ -57,6 +57,10 @@ pub static ROOTS_OF_UNITY: LazyLock> = LazyLock::new(|| { .collect() }); +pub struct BarycentricEvaluationChip { + inner: BaseCircuitBuilder, +} + #[derive(Clone, Debug)] pub struct BarycentricEvaluationConfig { pub scalar: FpConfig, @@ -99,14 +103,12 @@ impl BarycentricEvaluationConfig { pub fn assign( &self, - ctx: &mut SinglePhaseCoreManager, + ctx: &mut Context, + range_chip: &RangeChip, blob: &[U256; BLOB_WIDTH], challenge_digest: U256, evaluation: U256, ) -> AssignedBarycentricEvaluationConfig { - // some constants for later use. - // todo: move builder up... - let builder = BaseCircuitBuilder::default(); let fp_chip = FpChip::::new(&builder.range_chip(), BITS, LIMBS); let one = fp_chip.load_constant(ctx, Scalar::one()); @@ -245,7 +247,7 @@ pub fn interpolate(z: Scalar, coefficients: &[Scalar; BLOB_WIDTH]) -> Scalar { } fn assert_le_bytes_equal_crt( - ctx: &mut SinglePhaseCoreManager, + ctx: &mut Context, gate: &GateChip, le_bytes: &[AssignedValue], crt_limbs: &[AssignedValue], diff --git a/aggregator/src/aggregation/blob_data.rs b/aggregator/src/aggregation/blob_data.rs index 91fab95e5c..80b4db610f 100644 --- a/aggregator/src/aggregation/blob_data.rs +++ b/aggregator/src/aggregation/blob_data.rs @@ -8,6 +8,7 @@ use aggregator_snark_verifier::{ plonk::{Advice, Column, ConstraintSystem, Error, Expression, SecondPhase, Selector}, poly::Rotation, }, + utils::halo2::constrain_virtual_equals_external, virtual_region::copy_constraints::CopyConstraintManager, }, halo2_ecc::bigint::CRTInteger, @@ -285,7 +286,7 @@ impl BlobDataConfig { barycentric_assignments: &[CRTInteger], assigned_bytes: &[AssignedCell], bytes_len: &AssignedCell, - copy_manager: &&mut CopyConstraintManager, + copy_manager: &mut CopyConstraintManager, ) -> Result, Error> { rlc_config.init(region)?; let mut rlc_config_offset = 0; @@ -348,9 +349,18 @@ impl BlobDataConfig { &pows_of_256[0..9], &mut rlc_config_offset, )?; - region.constrain_equal(limb1.cell(), blob_crt.truncation.limbs[0].cell)?; - region.constrain_equal(limb2.cell(), blob_crt.truncation.limbs[1].cell)?; - region.constrain_equal(limb3.cell(), blob_crt.truncation.limbs[2].cell)?; + + for (external_value, virtual_value) in [limb1, limb2, limb3] + .iter() + .zip_eq(&blob_crt.truncation.limbs) + { + constrain_virtual_equals_external( + region, + virtual_value, + external_value.cell(), + copy_manager, + ); + } } // The zstd decoder (DecoderConfig) exports an encoded length that is 1 more than the diff --git a/aggregator/src/aggregation/circuit.rs b/aggregator/src/aggregation/circuit.rs index 66eeb43d24..120e097d81 100644 --- a/aggregator/src/aggregation/circuit.rs +++ b/aggregator/src/aggregation/circuit.rs @@ -163,6 +163,7 @@ impl Circuit for AggregationCircuit { // builder.core.copy_manager .... let builder = BaseCircuitBuilder::default(); + let copy_manager = bulder.core.copy_manager(); let (config, challenge) = config; @@ -513,7 +514,7 @@ impl Circuit for AggregationCircuit { .zip_eq(expected_chunk_data_digest.iter()) { log::trace!("blob chunk tx: {:?} {:?}", c.value(), ec.value()); - region.constrain_equal(c.cell(), ec.cell())?; + // region.constrain_equal(c.cell(), ec.cell())?; } } @@ -522,7 +523,7 @@ impl Circuit for AggregationCircuit { .zip_eq(assigned_batch_hash.blob.y.iter().rev()) { log::trace!("blob y: {:?} {:?}", c.value(), ec.value()); - region.constrain_equal(c.cell(), ec.cell())?; + // region.constrain_equal(c.cell(), ec.cell())?; } for (c, ec) in challenge_le @@ -530,7 +531,7 @@ impl Circuit for AggregationCircuit { .zip_eq(assigned_batch_hash.blob.z.iter().rev()) { log::trace!("blob z: {:?} {:?}", c.value(), ec.value()); - region.constrain_equal(c.cell(), ec.cell())?; + // region.constrain_equal(c.cell(), ec.cell())?; } for (c, ec) in batch_data_exports @@ -539,7 +540,7 @@ impl Circuit for AggregationCircuit { .zip_eq(assigned_batch_hash.blob.versioned_hash.iter()) { log::trace!("blob version hash: {:?} {:?}", c.value(), ec.value()); - region.constrain_equal(c.cell(), ec.cell())?; + // region.constrain_equal(c.cell(), ec.cell())?; } // equate rlc (from blob data) with decoder's encoded_rlc @@ -568,6 +569,8 @@ impl Circuit for AggregationCircuit { )?; } + builder.assign_instances(&[instance_column], layouter); + end_timer!(witness_time); Ok(()) diff --git a/aggregator/src/aggregation/config.rs b/aggregator/src/aggregation/config.rs index e7c36e0c13..c010c59b7a 100644 --- a/aggregator/src/aggregation/config.rs +++ b/aggregator/src/aggregation/config.rs @@ -182,7 +182,8 @@ impl AggregationConfig { /// Flex gate configuration pub fn flex_gate(&self) -> &FlexGateConfig { - self.ecc_chip().gate() + unimplemented!() + // self.ecc_chip().gate() } /// Ecc gate configuration diff --git a/aggregator/src/compression/circuit.rs b/aggregator/src/compression/circuit.rs index 4afe898cc8..e299ecd7b7 100644 --- a/aggregator/src/compression/circuit.rs +++ b/aggregator/src/compression/circuit.rs @@ -26,6 +26,7 @@ use aggregator_snark_verifier::{ }, pcs::kzg::{Bdfg21, KzgAs, KzgSuccinctVerifyingKey}, }; +use aggregator_snark_verifier::pcs::kzg::KzgAccumulator; use aggregator_snark_verifier_sdk::halo2::aggregation::BaseFieldEccChip; use aggregator_snark_verifier_sdk::{ halo2::aggregation::{aggregate, Svk}, diff --git a/aggregator/src/tests/blob.rs b/aggregator/src/tests/blob.rs index 82152cdb39..21b5dbc38e 100644 --- a/aggregator/src/tests/blob.rs +++ b/aggregator/src/tests/blob.rs @@ -35,6 +35,8 @@ struct BlobCircuit { overwrite_digest_rlc: Option, overwrite_is_boundary: Option, overwrite_is_padding: Option, + + inner: BaseCircuitBuilder, } #[derive(Clone, Debug)] diff --git a/aggregator/src/util.rs b/aggregator/src/util.rs index 287a895144..9dcc6a4881 100644 --- a/aggregator/src/util.rs +++ b/aggregator/src/util.rs @@ -12,6 +12,7 @@ use aggregator_snark_verifier::{ // use std::rc::Rc; use eth_types::Field; use halo2curves::bn256::{Fr, G1Affine}; +use std::rc::Rc; #[cfg(test)] #[ctor::ctor] @@ -114,23 +115,23 @@ pub(crate) fn rlc(inputs: &[Fr], randomness: &Fr) -> Fr { acc } -// TODO: does this already exist in snark-verifier? -pub fn flatten_accumulator<'a>( - accumulator: Rc>>>, -) -> Vec> { - let KzgAccumulator { lhs, rhs } = accumulator; +// // TODO: does this already exist in snark-verifier? +// pub fn flatten_accumulator<'a>( +// accumulator: Rc>>>, +// ) -> Vec> { +// let KzgAccumulator { lhs, rhs } = accumulator; - // TODO: this prevents compilation??? - // figure out what to copy paste here..... - let lhs = lhs.into_assigned(); - let rhs = rhs.into_assigned(); +// // TODO: this prevents compilation??? +// // figure out what to copy paste here..... +// let lhs = lhs.into_assigned(); +// let rhs = rhs.into_assigned(); - lhs.x - .truncation - .limbs - .into_iter() - .chain(lhs.y.truncation.limbs.into_iter()) - .chain(rhs.x.truncation.limbs.into_iter()) - .chain(rhs.y.truncation.limbs.into_iter()) - .collect() -} +// lhs.x +// .truncation +// .limbs +// .into_iter() +// .chain(lhs.y.truncation.limbs.into_iter()) +// .chain(rhs.x.truncation.limbs.into_iter()) +// .chain(rhs.y.truncation.limbs.into_iter()) +// .collect() +// } From 7bbfb7ed765af123643cf6ae3c86edab89725a6a Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Mon, 1 Jul 2024 21:00:22 +0800 Subject: [PATCH 13/18] make compression workspace member --- {aggregator/src/compression => compression/src}/circuit.rs | 0 {aggregator/src/compression => compression/src}/circuit_ext.rs | 0 {aggregator/src/compression => compression/src}/config.rs | 0 aggregator/src/compression.rs => compression/src/lib.rs | 0 aggregator/src/tests/compression.rs => compression/src/tests.rs | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename {aggregator/src/compression => compression/src}/circuit.rs (100%) rename {aggregator/src/compression => compression/src}/circuit_ext.rs (100%) rename {aggregator/src/compression => compression/src}/config.rs (100%) rename aggregator/src/compression.rs => compression/src/lib.rs (100%) rename aggregator/src/tests/compression.rs => compression/src/tests.rs (100%) diff --git a/aggregator/src/compression/circuit.rs b/compression/src/circuit.rs similarity index 100% rename from aggregator/src/compression/circuit.rs rename to compression/src/circuit.rs diff --git a/aggregator/src/compression/circuit_ext.rs b/compression/src/circuit_ext.rs similarity index 100% rename from aggregator/src/compression/circuit_ext.rs rename to compression/src/circuit_ext.rs diff --git a/aggregator/src/compression/config.rs b/compression/src/config.rs similarity index 100% rename from aggregator/src/compression/config.rs rename to compression/src/config.rs diff --git a/aggregator/src/compression.rs b/compression/src/lib.rs similarity index 100% rename from aggregator/src/compression.rs rename to compression/src/lib.rs diff --git a/aggregator/src/tests/compression.rs b/compression/src/tests.rs similarity index 100% rename from aggregator/src/tests/compression.rs rename to compression/src/tests.rs From 4213258135672172a0377d6b0a3f2197bb496931 Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Mon, 1 Jul 2024 23:22:53 +0800 Subject: [PATCH 14/18] move compression circuit into own workspace member --- Cargo.lock | 27 ++++++ Cargo.toml | 3 +- aggregator/src/lib.rs | 3 - compression/Cargo.toml | 35 +++++++ compression/src/circuit.rs | 16 ++-- compression/src/circuit_ext.rs | 2 +- compression/src/config.rs | 9 +- compression/src/constants.rs | 3 + compression/src/lib.rs | 5 + compression/src/params.rs | 57 +++++++++++ compression/src/util.rs | 166 +++++++++++++++++++++++++++++++++ 11 files changed, 307 insertions(+), 19 deletions(-) create mode 100644 compression/Cargo.toml create mode 100644 compression/src/constants.rs create mode 100644 compression/src/params.rs create mode 100644 compression/src/util.rs diff --git a/Cargo.lock b/Cargo.lock index 91b7b9648f..facf4261f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1000,6 +1000,33 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "compression" +version = "0.11.0" +dependencies = [ + "ark-std 0.3.0", + "csv", + "ctor", + "env_logger", + "eth-types", + "ethers-core", + "gadgets", + "halo2_proofs", + "halo2curves", + "hex", + "itertools 0.11.0", + "log", + "once_cell", + "rand", + "serde", + "serde_json", + "snark-verifier 0.1.8", + "snark-verifier-sdk 0.1.8", + "strum 0.25.0", + "strum_macros 0.25.3", + "zkevm-circuits", +] + [[package]] name = "const-hex" version = "1.12.0" diff --git a/Cargo.toml b/Cargo.toml index 74d2988b96..0142bd067d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,8 @@ members = [ "mock", "testool", "aggregator", - "prover" + "prover", + "compression", ] resolver = "2" diff --git a/aggregator/src/lib.rs b/aggregator/src/lib.rs index 46b5036889..114dbcdb4c 100644 --- a/aggregator/src/lib.rs +++ b/aggregator/src/lib.rs @@ -10,8 +10,6 @@ mod blob; // This module implements `Chunk` related data types. // A chunk is a list of blocks. mod chunk; -/// proof compression -mod compression; /// Configurations mod constants; /// Core module for circuit assignment @@ -28,7 +26,6 @@ pub use self::core::extract_proof_and_instances_with_pairing_check; pub use aggregation::*; pub use batch::BatchHash; pub use chunk::ChunkInfo; -pub use compression::*; pub use constants::MAX_AGG_SNARKS; pub(crate) use constants::*; pub use param::*; diff --git a/compression/Cargo.toml b/compression/Cargo.toml new file mode 100644 index 0000000000..c54a049427 --- /dev/null +++ b/compression/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "compression" +version.workspace = true +edition.workspace = true +license.workspace = true + +[dependencies] +# aggregator = { path = "../aggregator" } +eth-types = { path = "../eth-types" } +gadgets = { path = "../gadgets" } +zkevm-circuits = { path = "../zkevm-circuits" } + +ark-std.workspace = true +ctor.workspace = true +env_logger.workspace = true +ethers-core.workspace = true +halo2_proofs.workspace = true +hex.workspace = true +log.workspace = true +itertools.workspace = true +once_cell.workspace = true +serde.workspace = true +serde_json.workspace = true +rand.workspace = true +# halo2-base.workspace = true +# halo2-ecc.workspace = true +# halo2_proofs.workspace = true +halo2curves.workspace = true +aggregator-snark-verifier.workspace = true +aggregator-snark-verifier-sdk.workspace = true +strum.workspace = true +strum_macros.workspace = true + +[dev-dependencies] +csv = "1.1" diff --git a/compression/src/circuit.rs b/compression/src/circuit.rs index e299ecd7b7..ae23a33d17 100644 --- a/compression/src/circuit.rs +++ b/compression/src/circuit.rs @@ -1,7 +1,10 @@ //! Circuit implementation for compression circuit. -use std::fs::File; - +use crate::{ + constants::ACC_LEN, + params::ConfigParams, + util::{extract_proof_and_instances_with_pairing_check, flatten_accumulator}, +}; use aggregator_snark_verifier::{ halo2_base::{ gates::flex_gate::threads::MultiPhaseCoreManager, @@ -24,9 +27,8 @@ use aggregator_snark_verifier::{ }, Halo2Loader, }, - pcs::kzg::{Bdfg21, KzgAs, KzgSuccinctVerifyingKey}, + pcs::kzg::{Bdfg21, KzgAccumulator, KzgAs, KzgSuccinctVerifyingKey}, }; -use aggregator_snark_verifier::pcs::kzg::KzgAccumulator; use aggregator_snark_verifier_sdk::halo2::aggregation::BaseFieldEccChip; use aggregator_snark_verifier_sdk::{ halo2::aggregation::{aggregate, Svk}, @@ -34,11 +36,7 @@ use aggregator_snark_verifier_sdk::{ }; use ark_std::{end_timer, start_timer}; use rand::Rng; - -use crate::{ - core::extract_proof_and_instances_with_pairing_check, param::ConfigParams, - util::flatten_accumulator, ACC_LEN, -}; +use std::fs::File; use super::config::CompressionConfig; diff --git a/compression/src/circuit_ext.rs b/compression/src/circuit_ext.rs index dc7bd827fb..29446b5503 100644 --- a/compression/src/circuit_ext.rs +++ b/compression/src/circuit_ext.rs @@ -5,7 +5,7 @@ use aggregator_snark_verifier::halo2_base::halo2_proofs::{ }; use aggregator_snark_verifier_sdk::CircuitExt; -use crate::ACC_LEN; +use crate::constants::ACC_LEN; use super::circuit::CompressionCircuit; diff --git a/compression/src/config.rs b/compression/src/config.rs index 03f8a67d22..b21c031a4d 100644 --- a/compression/src/config.rs +++ b/compression/src/config.rs @@ -1,3 +1,7 @@ +use crate::{ + constants::{BITS, LIMBS}, + params::ConfigParams, +}; use aggregator_snark_verifier::{ halo2_base::halo2_proofs::{ halo2curves::bn256::{Fq, Fr, G1Affine}, @@ -16,11 +20,6 @@ use aggregator_snark_verifier::{ }, }; -use crate::{ - constants::{BITS, LIMBS}, - param::ConfigParams, -}; - #[derive(Clone, Debug)] /// Configurations for compression circuit /// This config is hard coded for BN256 curve diff --git a/compression/src/constants.rs b/compression/src/constants.rs new file mode 100644 index 0000000000..c617a76954 --- /dev/null +++ b/compression/src/constants.rs @@ -0,0 +1,3 @@ +pub const ACC_LEN: usize = 12; +pub const LIMBS: usize = 3; +pub const BITS: usize = 88; diff --git a/compression/src/lib.rs b/compression/src/lib.rs index 5ed296ac86..fdd6fba1a9 100644 --- a/compression/src/lib.rs +++ b/compression/src/lib.rs @@ -10,5 +10,10 @@ mod circuit_ext; /// Config for compression circuit mod config; +mod constants; +mod params; + +pub mod util; + pub use circuit::CompressionCircuit; pub use config::CompressionConfig; diff --git a/compression/src/params.rs b/compression/src/params.rs new file mode 100644 index 0000000000..f5c1a8a4ee --- /dev/null +++ b/compression/src/params.rs @@ -0,0 +1,57 @@ +use crate::constants::{BITS, LIMBS}; +use aggregator_snark_verifier::loader::halo2::halo2_ecc::fields::FpStrategy; + +#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] +/// Parameters for aggregation circuit and compression circuit configs. +pub struct ConfigParams { + pub strategy: FpStrategy, + pub degree: u32, + pub num_advice: Vec, + pub num_lookup_advice: Vec, + pub num_fixed: usize, + pub lookup_bits: usize, + pub limb_bits: usize, + pub num_limbs: usize, +} + +impl ConfigParams { + /// Same with scroll-prover/integration/configs/layer3.config + pub(crate) fn aggregation_param() -> Self { + Self { + strategy: FpStrategy::Simple, + degree: 21, + num_advice: vec![63], + num_lookup_advice: vec![8], + num_fixed: 2, + lookup_bits: 20, + limb_bits: BITS, + num_limbs: LIMBS, + } + } + + pub(crate) fn default_compress_wide_param() -> Self { + Self { + strategy: FpStrategy::Simple, + degree: 22, + num_advice: vec![35], + num_lookup_advice: vec![1], + num_fixed: 1, + lookup_bits: 20, + limb_bits: BITS, + num_limbs: LIMBS, + } + } + + pub(crate) fn _compress_thin_param() -> Self { + Self { + strategy: FpStrategy::Simple, + degree: 25, + num_advice: vec![1], + num_lookup_advice: vec![1], + num_fixed: 1, + lookup_bits: 20, + limb_bits: BITS, + num_limbs: LIMBS, + } + } +} diff --git a/compression/src/util.rs b/compression/src/util.rs new file mode 100644 index 0000000000..15733b8b35 --- /dev/null +++ b/compression/src/util.rs @@ -0,0 +1,166 @@ +use std::iter::repeat; + +use crate::constants::{BITS, LIMBS}; +use aggregator_snark_verifier::loader::halo2::halo2_ecc::ecc::EccChip; +use aggregator_snark_verifier::loader::halo2::halo2_ecc::halo2_base::AssignedValue; +use aggregator_snark_verifier::loader::halo2::Halo2Loader; +use aggregator_snark_verifier::{ + loader::native::NativeLoader, + pcs::{ + kzg::{Bdfg21, KzgAccumulator, KzgAs}, + AccumulationScheme, AccumulationSchemeProver, + }, + util::arithmetic::fe_to_limbs, + Error as SnarkVerifierError, +}; +use aggregator_snark_verifier_sdk::halo2::aggregation::BaseFieldEccChip; +use aggregator_snark_verifier_sdk::PlonkSuccinctVerifier; +use aggregator_snark_verifier_sdk::{ + halo2::{PoseidonTranscript, POSEIDON_SPEC}, + PlonkVerifier, Snark, SHPLONK, +}; +use ark_std::{end_timer, start_timer}; +use ethers_core::utils::keccak256; +use halo2_proofs::{ + circuit::{AssignedCell, Layouter, Region, Value}, + halo2curves::{ + bn256::{Bn256, Fq, Fr, G1Affine, G2Affine}, + pairing::Engine, + }, + plonk::Error, + poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, +}; +use itertools::Itertools; +use rand::Rng; +use std::rc::Rc; +use zkevm_circuits::{ + keccak_circuit::{keccak_packed_multi::multi_keccak, KeccakCircuit, KeccakCircuitConfig}, + util::Challenges, +}; + +/// Subroutine for the witness generations. +/// Extract proof from previous snarks and check pairing for accumulation. +pub fn extract_proof_and_instances_with_pairing_check( + params: &ParamsKZG, + snarks: &[Snark], + rng: impl Rng + Send, +) -> Result<(Vec, Vec), SnarkVerifierError> { + // (old_accumulator, public inputs) -> (new_accumulator, public inputs) + let (accumulator, as_proof) = + extract_accumulators_and_proof(params, snarks, rng, ¶ms.g2(), ¶ms.s_g2())?; + + // the instance for the outer circuit is + // - new accumulator, consists of 12 elements + // - inner circuit's instance, flattened (old accumulator is stripped out if exists) + // + // it is important that new accumulator is the first 12 elements + // as specified in CircuitExt::accumulator_indices() + let KzgAccumulator:: { lhs, rhs } = accumulator; + + // sanity check on the accumulator + { + let left = Bn256::pairing(&lhs, ¶ms.g2()); + let right = Bn256::pairing(&rhs, ¶ms.s_g2()); + log::trace!("circuit acc check: left {:?}", left); + log::trace!("circuit acc check: right {:?}", right); + + if left != right { + return Err(SnarkVerifierError::AssertionFailure(format!( + "accumulator check failed {left:?} {right:?}", + ))); + } + } + + let acc_instances = [lhs.x, lhs.y, rhs.x, rhs.y] + .map(fe_to_limbs::) + .concat(); + + Ok((as_proof, acc_instances)) +} + +pub fn flatten_accumulator<'a>( + accumulator: KzgAccumulator>>, +) -> Vec> { + let KzgAccumulator { lhs, rhs } = accumulator; + + // TODO: this prevents compilation??? + // figure out what to copy paste here..... + let lhs = lhs.into_assigned(); + let rhs = rhs.into_assigned(); + + lhs.x + .truncation + .limbs + .into_iter() + .chain(lhs.y.truncation.limbs.into_iter()) + .chain(rhs.x.truncation.limbs.into_iter()) + .chain(rhs.y.truncation.limbs.into_iter()) + .collect() +} + +fn extract_accumulators_and_proof( + params: &ParamsKZG, + snarks: &[Snark], + rng: impl Rng + Send, + g2: &G2Affine, + s_g2: &G2Affine, +) -> Result<(KzgAccumulator, Vec), SnarkVerifierError> { + let svk = params.get_g()[0].into(); + + let mut transcript_read = + PoseidonTranscript::::from_spec(&[], POSEIDON_SPEC.clone()); + let accumulators = snarks + .iter() + .flat_map(|snark| { + transcript_read.new_stream(snark.proof.as_slice()); + let proof = PlonkSuccinctVerifier::::read_proof( + &svk, + &snark.protocol, + &snark.instances, + &mut transcript_read, + ); + // each accumulator has (lhs, rhs) based on Shplonk + // lhs and rhs are EC points + PlonkSuccinctVerifier::::verify( + &svk, + &snark.protocol, + &snark.instances, + &proof, + ) + }) + .collect::>(); + + // sanity check on the accumulator + { + for (i, acc) in accumulators.iter().enumerate() { + let KzgAccumulator { lhs, rhs } = acc; + let left = Bn256::pairing(lhs, g2); + let right = Bn256::pairing(rhs, s_g2); + log::trace!("acc extraction {}-th acc check: left {:?}", i, left); + log::trace!("acc extraction {}-th acc check: right {:?}", i, right); + if left != right { + return Err(SnarkVerifierError::AssertionFailure(format!( + "accumulator check failed {left:?} {right:?}, index {i}", + ))); + } + //assert_eq!(left, right, "accumulator check failed"); + } + } + + let mut transcript_write = + PoseidonTranscript::>::from_spec(vec![], POSEIDON_SPEC.clone()); + // We always use SHPLONK for accumulation scheme when aggregating proofs + let accumulator = + // core step + // KzgAs does KZG accumulation scheme based on given accumulators and random number (for adding blinding) + // accumulated ec_pt = ec_pt_1 * 1 + ec_pt_2 * r + ... + ec_pt_n * r^{n-1} + // ec_pt can be lhs and rhs + // r is the challenge squeezed from proof + KzgAs::::create_proof::>, _>( + &Default::default(), + &accumulators, + &mut transcript_write, + rng, + )?; + Ok((accumulator, transcript_write.finalize())) +} From a3848248ef18b2968fa539b1826165a1881d129d Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Tue, 2 Jul 2024 16:22:47 +0800 Subject: [PATCH 15/18] compiles by commenting out --- compression/src/circuit.rs | 155 +++++++++++++++++++------------------ compression/src/util.rs | 38 +++++---- 2 files changed, 102 insertions(+), 91 deletions(-) diff --git a/compression/src/circuit.rs b/compression/src/circuit.rs index ae23a33d17..a8fc0cb0d4 100644 --- a/compression/src/circuit.rs +++ b/compression/src/circuit.rs @@ -65,20 +65,24 @@ impl Circuit for CompressionCircuit { type FloorPlanner = SimpleFloorPlanner; fn without_witnesses(&self) -> Self { - let flattened_instances = self - .snark - .instances - .iter() - .flat_map(|instance| instance.iter().map(|_| Fr::zero())) - .collect(); - - Self { - svk: self.svk, - snark: Snark::without_witnesses(&self.snark), - has_accumulator: false, - flattened_instances, - as_proof: Value::unknown(), - } + unimplemented!() + // // TODO: check if unimplement + // let instances = self.snark.instances.iter().map() + // let snark = Snark::new(self.snark.protocol, instances, ); + // let flattened_instances = self + // .snark + // .instances + // .iter() + // .flat_map(|instance| instance.iter().map(|_| Fr::zero())) + // .collect(); + + // Self { + // svk: self.svk, + // snark: Snark::without_witnesses(&self.snark), + // has_accumulator: false, + // flattened_instances, + // as_proof: Value::unknown(), + // } } fn configure(meta: &mut ConstraintSystem) -> Self::Config { @@ -107,66 +111,69 @@ impl Circuit for CompressionCircuit { config: Self::Config, mut layouter: impl Layouter, ) -> Result<(), Error> { - let witness_time = start_timer!(|| "synthesize | compression Circuit"); - config - .range() - .load_lookup_table(&mut layouter) - .expect("load range lookup table"); - - let mut first_pass = halo2_base::SKIP_FIRST_PASS; - - let instances = layouter.assign_region( - || "compression circuit", - |region| -> Result, Error> { - if first_pass { - first_pass = false; - return Ok(vec![]); - } - let mut instances = vec![]; - // TODO: check correctness of this! - let mut ctx = MultiPhaseCoreManager::new(false).main(0); - - let ecc_chip = config.ecc_chip(); - let loader = Halo2Loader::new(ecc_chip, ctx); - let (assigned_instances, acc) = aggregate::>( - &self.svk, - &loader, - &[self.snark.clone()], - self.as_proof(), - ); - - let acc: KzgAccumulator>> = - acc; - - // instance of the compression circuit is defined as - // - accumulators - // - re-export the public input from snark - instances.extend( - flatten_accumulator(acc) - .iter() - .map(|assigned| assigned.cell), - ); - // - if the snark is not a fresh one, assigned_instances already contains an - // accumulator so we want to skip the first 12 elements from the public input - let skip = if self.has_accumulator { ACC_LEN } else { 0 }; - instances.extend(assigned_instances.iter().flat_map(|instance_column| { - instance_column.iter().skip(skip).map(|x| x.cell()) - })); - - // TODO: figure out where to call this! - // config.range().finalize(&mut loader.ctx_mut()); - - // loader.ctx_mut().print_stats(&["Range"]); - Ok(instances) - }, - )?; - - // Expose instances - for (i, cell) in instances.into_iter().enumerate() { - layouter.constrain_instance(cell, config.instance, i)?; - } - - end_timer!(witness_time); + // let witness_time = start_timer!(|| "synthesize | compression Circuit"); + // config + // .range() + // .load_lookup_table(&mut layouter) + // .expect("load range lookup table"); + + // let mut first_pass = halo2_base::SKIP_FIRST_PASS; + + // let instances = layouter.assign_region( + // || "compression circuit", + // |region| -> Result, Error> { + // if first_pass { + // first_pass = false; + // return Ok(vec![]); + // } + // let mut instances = vec![]; + // // TODO: check correctness of this! + // let mut ctx = MultiPhaseCoreManager::new(false).main(0); + + // let KzgAccumulator { lhs, rhs } = + // aggregate(&svk, &loader, &snarks, as_proof.as_slice()); + + // let ecc_chip = config.ecc_chip(); + // let loader = Halo2Loader::new(ecc_chip, ctx); + // let witness = aggregate::>( + // &self.svk, + // &loader, + // &[self.snark.clone()], + // self.as_proof(), + // ); + + // let assigned_instances = witness.previous_instances; + // let acc = witness.accumulator; + + // // instance of the compression circuit is defined as + // // - accumulators + // // - re-export the public input from snark + // instances.extend( + // flatten_accumulator(acc) + // .iter() + // .map(|assigned| assigned.cell), + // ); + // // - if the snark is not a fresh one, assigned_instances already contains an + // // accumulator so we want to skip the first 12 elements from the public input + // let skip = if self.has_accumulator { ACC_LEN } else { 0 }; + // instances.extend(assigned_instances.iter().flat_map(|instance_column| { + // instance_column.iter().skip(skip).map(|x| x.cell()) + // })); + + // // TODO: figure out where to call this! + // // config.range().finalize(&mut loader.ctx_mut()); + + // // loader.ctx_mut().print_stats(&["Range"]); + // Ok(instances) + // }, + // )?; + + // // Expose instances + // for (i, cell) in instances.into_iter().enumerate() { + // layouter.constrain_instance(cell, config.instance, i)?; + // } + + // end_timer!(witness_time); Ok(()) } } diff --git a/compression/src/util.rs b/compression/src/util.rs index 15733b8b35..b46e83332f 100644 --- a/compression/src/util.rs +++ b/compression/src/util.rs @@ -11,6 +11,7 @@ use aggregator_snark_verifier::{ AccumulationScheme, AccumulationSchemeProver, }, util::arithmetic::fe_to_limbs, + verifier::SnarkVerifier, Error as SnarkVerifierError, }; use aggregator_snark_verifier_sdk::halo2::aggregation::BaseFieldEccChip; @@ -81,21 +82,22 @@ pub fn extract_proof_and_instances_with_pairing_check( pub fn flatten_accumulator<'a>( accumulator: KzgAccumulator>>, ) -> Vec> { - let KzgAccumulator { lhs, rhs } = accumulator; + unimplemented!(); + // let KzgAccumulator { lhs, rhs } = accumulator; - // TODO: this prevents compilation??? - // figure out what to copy paste here..... - let lhs = lhs.into_assigned(); - let rhs = rhs.into_assigned(); + // // TODO: this prevents compilation??? + // // figure out what to copy paste here..... + // let lhs = lhs.into_assigned(); + // let rhs = rhs.into_assigned(); - lhs.x - .truncation - .limbs - .into_iter() - .chain(lhs.y.truncation.limbs.into_iter()) - .chain(rhs.x.truncation.limbs.into_iter()) - .chain(rhs.y.truncation.limbs.into_iter()) - .collect() + // lhs.x + // .truncation + // .limbs + // .into_iter() + // .chain(lhs.y.truncation.limbs.into_iter()) + // .chain(rhs.x.truncation.limbs.into_iter()) + // .chain(rhs.y.truncation.limbs.into_iter()) + // .collect() } fn extract_accumulators_and_proof( @@ -109,7 +111,7 @@ fn extract_accumulators_and_proof( let mut transcript_read = PoseidonTranscript::::from_spec(&[], POSEIDON_SPEC.clone()); - let accumulators = snarks + let accumulators: Vec> = snarks .iter() .flat_map(|snark| { transcript_read.new_stream(snark.proof.as_slice()); @@ -118,15 +120,17 @@ fn extract_accumulators_and_proof( &snark.protocol, &snark.instances, &mut transcript_read, - ); + ) + .unwrap(); // each accumulator has (lhs, rhs) based on Shplonk // lhs and rhs are EC points - PlonkSuccinctVerifier::::verify( + let x: Vec> = PlonkSuccinctVerifier::::verify( &svk, &snark.protocol, &snark.instances, &proof, - ) + ).unwrap(); + x }) .collect::>(); From 7d292b8630ad1246f0790ac48af103a11275a08f Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Tue, 2 Jul 2024 16:59:54 +0800 Subject: [PATCH 16/18] fix flatten_snarks function --- compression/src/util.rs | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/compression/src/util.rs b/compression/src/util.rs index b46e83332f..edccc2dfa1 100644 --- a/compression/src/util.rs +++ b/compression/src/util.rs @@ -1,8 +1,8 @@ -use std::iter::repeat; - use crate::constants::{BITS, LIMBS}; +use aggregator_snark_verifier::halo2_ecc::bigint::ProperCrtUint; use aggregator_snark_verifier::loader::halo2::halo2_ecc::ecc::EccChip; use aggregator_snark_verifier::loader::halo2::halo2_ecc::halo2_base::AssignedValue; +use aggregator_snark_verifier::loader::halo2::EcPoint; use aggregator_snark_verifier::loader::halo2::Halo2Loader; use aggregator_snark_verifier::{ loader::native::NativeLoader, @@ -33,6 +33,7 @@ use halo2_proofs::{ }; use itertools::Itertools; use rand::Rng; +use std::iter::repeat; use std::rc::Rc; use zkevm_circuits::{ keccak_circuit::{keccak_packed_multi::multi_keccak, KeccakCircuit, KeccakCircuitConfig}, @@ -79,25 +80,21 @@ pub fn extract_proof_and_instances_with_pairing_check( Ok((as_proof, acc_instances)) } -pub fn flatten_accumulator<'a>( +pub fn flatten_accumulator( accumulator: KzgAccumulator>>, ) -> Vec> { - unimplemented!(); - // let KzgAccumulator { lhs, rhs } = accumulator; - - // // TODO: this prevents compilation??? - // // figure out what to copy paste here..... - // let lhs = lhs.into_assigned(); - // let rhs = rhs.into_assigned(); - - // lhs.x - // .truncation - // .limbs - // .into_iter() - // .chain(lhs.y.truncation.limbs.into_iter()) - // .chain(rhs.x.truncation.limbs.into_iter()) - // .chain(rhs.y.truncation.limbs.into_iter()) - // .collect() + let KzgAccumulator { lhs, rhs } = accumulator; + let [lhs_assigned, rhs_assigned] = [lhs, rhs].map(EcPoint::into_assigned); + [ + lhs_assigned.x, + lhs_assigned.y, + rhs_assigned.x, + rhs_assigned.y, + ] + .iter() + .flat_map(ProperCrtUint::limbs) + .cloned() + .collect() } fn extract_accumulators_and_proof( @@ -129,7 +126,8 @@ fn extract_accumulators_and_proof( &snark.protocol, &snark.instances, &proof, - ).unwrap(); + ) + .unwrap(); x }) .collect::>(); From 27cb21f445484b969e6930b6fd922b3bf192e851 Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Tue, 2 Jul 2024 17:31:16 +0800 Subject: [PATCH 17/18] cleanup --- compression/src/circuit.rs | 47 ++++++++++-------------------------- compression/src/config.rs | 19 ++++++--------- compression/src/constants.rs | 2 -- compression/src/params.rs | 2 +- compression/src/util.rs | 27 ++++++--------------- 5 files changed, 28 insertions(+), 69 deletions(-) diff --git a/compression/src/circuit.rs b/compression/src/circuit.rs index a8fc0cb0d4..ff078a3c1c 100644 --- a/compression/src/circuit.rs +++ b/compression/src/circuit.rs @@ -1,40 +1,23 @@ //! Circuit implementation for compression circuit. use crate::{ - constants::ACC_LEN, - params::ConfigParams, - util::{extract_proof_and_instances_with_pairing_check, flatten_accumulator}, + constants::ACC_LEN, params::ConfigParams, util::extract_proof_and_instances_with_pairing_check, }; use aggregator_snark_verifier::{ - halo2_base::{ - gates::flex_gate::threads::MultiPhaseCoreManager, - halo2_proofs::{ - circuit::{Cell, Layouter, SimpleFloorPlanner, Value}, - halo2curves::bn256::G1Affine, - plonk::{Circuit, ConstraintSystem, Error}, - }, + halo2_base::halo2_proofs::{ + circuit::{Layouter, SimpleFloorPlanner, Value}, + halo2curves::bn256::G1Affine, + plonk::{Circuit, ConstraintSystem, Error}, }, - loader::halo2::{ - halo2_ecc::{ - halo2_base, - halo2_base::{ - halo2_proofs::{ - halo2curves::bn256::{Bn256, Fr}, - poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, - }, - Context, - }, - }, - Halo2Loader, + loader::halo2::halo2_ecc::halo2_base::halo2_proofs::{ + halo2curves::bn256::{Bn256, Fr}, + poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, }, - pcs::kzg::{Bdfg21, KzgAccumulator, KzgAs, KzgSuccinctVerifyingKey}, + pcs::kzg::KzgSuccinctVerifyingKey, }; -use aggregator_snark_verifier_sdk::halo2::aggregation::BaseFieldEccChip; -use aggregator_snark_verifier_sdk::{ - halo2::aggregation::{aggregate, Svk}, - Snark, -}; -use ark_std::{end_timer, start_timer}; + +use aggregator_snark_verifier_sdk::{halo2::aggregation::Svk, Snark}; + use rand::Rng; use std::fs::File; @@ -106,11 +89,7 @@ impl Circuit for CompressionCircuit { Self::Config::configure(meta, params) } - fn synthesize( - &self, - config: Self::Config, - mut layouter: impl Layouter, - ) -> Result<(), Error> { + fn synthesize(&self, _config: Self::Config, _layouter: impl Layouter) -> Result<(), Error> { // let witness_time = start_timer!(|| "synthesize | compression Circuit"); // config // .range() diff --git a/compression/src/config.rs b/compression/src/config.rs index b21c031a4d..936085f496 100644 --- a/compression/src/config.rs +++ b/compression/src/config.rs @@ -1,24 +1,19 @@ -use crate::{ - constants::{BITS, LIMBS}, - params::ConfigParams, -}; +use crate::params::ConfigParams; use aggregator_snark_verifier::{ halo2_base::halo2_proofs::{ - halo2curves::bn256::{Fq, Fr, G1Affine}, + halo2curves::bn256::{Fr, G1Affine}, plonk::{Column, ConstraintSystem, Instance}, }, loader::halo2::halo2_ecc::{ - ecc::{BaseFieldEccChip, EccChip}, + ecc::BaseFieldEccChip, fields::fp::FpConfig, - halo2_base::{ - gates::{ - flex_gate::{FlexGateConfig, FlexGateConfigParams}, - range::RangeConfig, - }, - utils::modulus, + halo2_base::gates::{ + flex_gate::{FlexGateConfig, FlexGateConfigParams}, + range::RangeConfig, }, }, }; +use aggregator_snark_verifier_sdk::{BITS, LIMBS}; #[derive(Clone, Debug)] /// Configurations for compression circuit diff --git a/compression/src/constants.rs b/compression/src/constants.rs index c617a76954..2cf0b6bf2c 100644 --- a/compression/src/constants.rs +++ b/compression/src/constants.rs @@ -1,3 +1 @@ pub const ACC_LEN: usize = 12; -pub const LIMBS: usize = 3; -pub const BITS: usize = 88; diff --git a/compression/src/params.rs b/compression/src/params.rs index f5c1a8a4ee..a36e30d6cb 100644 --- a/compression/src/params.rs +++ b/compression/src/params.rs @@ -1,4 +1,4 @@ -use crate::constants::{BITS, LIMBS}; +use aggregator_snark_verifier_sdk::{BITS, LIMBS}; use aggregator_snark_verifier::loader::halo2::halo2_ecc::fields::FpStrategy; #[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] diff --git a/compression/src/util.rs b/compression/src/util.rs index edccc2dfa1..6d6bccc572 100644 --- a/compression/src/util.rs +++ b/compression/src/util.rs @@ -1,11 +1,9 @@ -use crate::constants::{BITS, LIMBS}; -use aggregator_snark_verifier::halo2_ecc::bigint::ProperCrtUint; -use aggregator_snark_verifier::loader::halo2::halo2_ecc::ecc::EccChip; -use aggregator_snark_verifier::loader::halo2::halo2_ecc::halo2_base::AssignedValue; -use aggregator_snark_verifier::loader::halo2::EcPoint; -use aggregator_snark_verifier::loader::halo2::Halo2Loader; use aggregator_snark_verifier::{ - loader::native::NativeLoader, + halo2_ecc::bigint::ProperCrtUint, + loader::{ + halo2::{halo2_ecc::halo2_base::AssignedValue, EcPoint, Halo2Loader}, + native::NativeLoader, + }, pcs::{ kzg::{Bdfg21, KzgAccumulator, KzgAs}, AccumulationScheme, AccumulationSchemeProver, @@ -14,31 +12,20 @@ use aggregator_snark_verifier::{ verifier::SnarkVerifier, Error as SnarkVerifierError, }; -use aggregator_snark_verifier_sdk::halo2::aggregation::BaseFieldEccChip; -use aggregator_snark_verifier_sdk::PlonkSuccinctVerifier; use aggregator_snark_verifier_sdk::{ - halo2::{PoseidonTranscript, POSEIDON_SPEC}, - PlonkVerifier, Snark, SHPLONK, + halo2::{aggregation::BaseFieldEccChip, PoseidonTranscript, POSEIDON_SPEC}, + PlonkSuccinctVerifier, Snark, BITS, LIMBS, SHPLONK, }; -use ark_std::{end_timer, start_timer}; -use ethers_core::utils::keccak256; use halo2_proofs::{ - circuit::{AssignedCell, Layouter, Region, Value}, halo2curves::{ bn256::{Bn256, Fq, Fr, G1Affine, G2Affine}, pairing::Engine, }, - plonk::Error, poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, }; use itertools::Itertools; use rand::Rng; -use std::iter::repeat; use std::rc::Rc; -use zkevm_circuits::{ - keccak_circuit::{keccak_packed_multi::multi_keccak, KeccakCircuit, KeccakCircuitConfig}, - util::Challenges, -}; /// Subroutine for the witness generations. /// Extract proof from previous snarks and check pairing for accumulation. From 506c17f87edbe9193f909c1dc8b1e8e43c5ba954 Mon Sep 17 00:00:00 2001 From: Mason Liang Date: Mon, 8 Jul 2024 11:03:56 +0800 Subject: [PATCH 18/18] cleanup --- compression/src/circuit.rs | 53 ++++++++++++++++------------------ compression/src/circuit_ext.rs | 10 ++----- compression/src/config.rs | 17 ++++------- compression/src/params.rs | 2 +- compression/src/util.rs | 16 +++++----- 5 files changed, 42 insertions(+), 56 deletions(-) diff --git a/compression/src/circuit.rs b/compression/src/circuit.rs index ff078a3c1c..1e0b712831 100644 --- a/compression/src/circuit.rs +++ b/compression/src/circuit.rs @@ -1,28 +1,21 @@ //! Circuit implementation for compression circuit. use crate::{ - constants::ACC_LEN, params::ConfigParams, util::extract_proof_and_instances_with_pairing_check, + config::CompressionConfig, constants::ACC_LEN, params::ConfigParams, + util::extract_proof_and_instances_with_pairing_check, }; -use aggregator_snark_verifier::{ - halo2_base::halo2_proofs::{ - circuit::{Layouter, SimpleFloorPlanner, Value}, - halo2curves::bn256::G1Affine, - plonk::{Circuit, ConstraintSystem, Error}, - }, - loader::halo2::halo2_ecc::halo2_base::halo2_proofs::{ - halo2curves::bn256::{Bn256, Fr}, - poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, - }, - pcs::kzg::KzgSuccinctVerifyingKey, -}; - +use aggregator_snark_verifier::{halo2_base::SKIP_FIRST_PASS, pcs::kzg::KzgSuccinctVerifyingKey}; use aggregator_snark_verifier_sdk::{halo2::aggregation::Svk, Snark}; - +use ark_std::{end_timer, start_timer}; +use halo2_proofs::{ + circuit::{Layouter, SimpleFloorPlanner, Value}, + plonk::{Circuit, ConstraintSystem, Error}, + poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, +}; +use halo2curves::bn256::{Bn256, Fr, G1Affine}; use rand::Rng; use std::fs::File; -use super::config::CompressionConfig; - /// Input a proof, this compression circuit generates a new proof that may have smaller size. /// /// It re-exposes same public inputs from the input snark. @@ -89,17 +82,21 @@ impl Circuit for CompressionCircuit { Self::Config::configure(meta, params) } - fn synthesize(&self, _config: Self::Config, _layouter: impl Layouter) -> Result<(), Error> { - // let witness_time = start_timer!(|| "synthesize | compression Circuit"); - // config - // .range() - // .load_lookup_table(&mut layouter) - // .expect("load range lookup table"); + fn synthesize( + &self, + config: Self::Config, + mut layouter: impl Layouter, + ) -> Result<(), Error> { + let witness_time = start_timer!(|| "synthesize | compression Circuit"); + config + .range() + .load_lookup_table(&mut layouter) + .expect("load range lookup table"); - // let mut first_pass = halo2_base::SKIP_FIRST_PASS; + let mut first_pass = SKIP_FIRST_PASS; // let instances = layouter.assign_region( - // || "compression circuit", + // || "compression circuit", // |region| -> Result, Error> { // if first_pass { // first_pass = false; @@ -143,8 +140,8 @@ impl Circuit for CompressionCircuit { // // config.range().finalize(&mut loader.ctx_mut()); // // loader.ctx_mut().print_stats(&["Range"]); - // Ok(instances) - // }, + // Ok(instances) + // }, // )?; // // Expose instances @@ -152,7 +149,7 @@ impl Circuit for CompressionCircuit { // layouter.constrain_instance(cell, config.instance, i)?; // } - // end_timer!(witness_time); + end_timer!(witness_time); Ok(()) } } diff --git a/compression/src/circuit_ext.rs b/compression/src/circuit_ext.rs index 29446b5503..ed30dfa5a6 100644 --- a/compression/src/circuit_ext.rs +++ b/compression/src/circuit_ext.rs @@ -1,13 +1,9 @@ //! CircuitExt implementation for compression circuit. -use aggregator_snark_verifier::halo2_base::halo2_proofs::{ - halo2curves::bn256::Fr, plonk::Selector, -}; +use crate::{circuit::CompressionCircuit, constants::ACC_LEN}; use aggregator_snark_verifier_sdk::CircuitExt; - -use crate::constants::ACC_LEN; - -use super::circuit::CompressionCircuit; +use halo2_proofs::plonk::Selector; +use halo2curves::bn256::Fr; impl CircuitExt for CompressionCircuit { fn num_instance(&self) -> Vec { diff --git a/compression/src/config.rs b/compression/src/config.rs index 936085f496..b27c6c5a81 100644 --- a/compression/src/config.rs +++ b/compression/src/config.rs @@ -1,19 +1,14 @@ use crate::params::ConfigParams; use aggregator_snark_verifier::{ - halo2_base::halo2_proofs::{ - halo2curves::bn256::{Fr, G1Affine}, - plonk::{Column, ConstraintSystem, Instance}, - }, - loader::halo2::halo2_ecc::{ - ecc::BaseFieldEccChip, - fields::fp::FpConfig, - halo2_base::gates::{ - flex_gate::{FlexGateConfig, FlexGateConfigParams}, - range::RangeConfig, - }, + halo2_base::gates::{ + flex_gate::{FlexGateConfig, FlexGateConfigParams}, + range::RangeConfig, }, + halo2_ecc::{ecc::BaseFieldEccChip, fields::fp::FpConfig}, }; use aggregator_snark_verifier_sdk::{BITS, LIMBS}; +use halo2_proofs::plonk::{Column, ConstraintSystem, Instance}; +use halo2curves::bn256::{Fr, G1Affine}; #[derive(Clone, Debug)] /// Configurations for compression circuit diff --git a/compression/src/params.rs b/compression/src/params.rs index a36e30d6cb..1caf72ef58 100644 --- a/compression/src/params.rs +++ b/compression/src/params.rs @@ -1,5 +1,5 @@ -use aggregator_snark_verifier_sdk::{BITS, LIMBS}; use aggregator_snark_verifier::loader::halo2::halo2_ecc::fields::FpStrategy; +use aggregator_snark_verifier_sdk::{BITS, LIMBS}; #[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] /// Parameters for aggregation circuit and compression circuit configs. diff --git a/compression/src/util.rs b/compression/src/util.rs index 6d6bccc572..ca6fdf3d1a 100644 --- a/compression/src/util.rs +++ b/compression/src/util.rs @@ -1,12 +1,13 @@ use aggregator_snark_verifier::{ + halo2_base::AssignedValue, halo2_ecc::bigint::ProperCrtUint, loader::{ - halo2::{halo2_ecc::halo2_base::AssignedValue, EcPoint, Halo2Loader}, + halo2::{EcPoint, Halo2Loader}, native::NativeLoader, }, pcs::{ kzg::{Bdfg21, KzgAccumulator, KzgAs}, - AccumulationScheme, AccumulationSchemeProver, + AccumulationSchemeProver, }, util::arithmetic::fe_to_limbs, verifier::SnarkVerifier, @@ -16,14 +17,11 @@ use aggregator_snark_verifier_sdk::{ halo2::{aggregation::BaseFieldEccChip, PoseidonTranscript, POSEIDON_SPEC}, PlonkSuccinctVerifier, Snark, BITS, LIMBS, SHPLONK, }; -use halo2_proofs::{ - halo2curves::{ - bn256::{Bn256, Fq, Fr, G1Affine, G2Affine}, - pairing::Engine, - }, - poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}, +use halo2_proofs::poly::{commitment::ParamsProver, kzg::commitment::ParamsKZG}; +use halo2curves::{ + bn256::{Bn256, Fq, Fr, G1Affine, G2Affine}, + pairing::Engine, }; -use itertools::Itertools; use rand::Rng; use std::rc::Rc;