diff --git a/Cargo.lock b/Cargo.lock index 118837a2..2049508d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,7 +26,7 @@ dependencies = [ [[package]] name = "air" version = "0.3.0" -source = "git+https://github.com/leanEthereum/multilinear-toolkit.git#eeb6404188e4b4c9207b9e8e8a2120156602d92e" +source = "git+https://github.com/leanEthereum/multilinear-toolkit.git#bd8a91199f45fcb3c21af056468340e2f9de2d1d" dependencies = [ "p3-field", ] @@ -99,7 +99,7 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "backend" version = "0.3.0" -source = "git+https://github.com/leanEthereum/multilinear-toolkit.git#eeb6404188e4b4c9207b9e8e8a2120156602d92e" +source = "git+https://github.com/leanEthereum/multilinear-toolkit.git#bd8a91199f45fcb3c21af056468340e2f9de2d1d" dependencies = [ "itertools", "p3-field", @@ -134,9 +134,9 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "clap" -version = "4.5.54" +version = "4.5.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e6ff9dcd79cff5cd969a17a545d79e84ab086e444102a591e288a8aa3ce394" +checksum = "a75ca66430e33a14957acc24c5077b503e7d374151b2b4b3a10c83b4ceb4be0e" dependencies = [ "clap_builder", "clap_derive", @@ -144,9 +144,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.54" +version = "4.5.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa42cf4d2b7a41bc8f663a7cab4031ebafa1bf3875705bfaf8466dc60ab52c00" +checksum = "793207c7fa6300a0608d1080b858e5fdbe713cdc1c8db9fb17777d8a13e63df0" dependencies = [ "anstream", "anstyle", @@ -156,9 +156,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.49" +version = "4.5.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" +checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5" dependencies = [ "heck", "proc-macro2", @@ -190,7 +190,7 @@ dependencies = [ [[package]] name = "constraints-folder" version = "0.3.0" -source = "git+https://github.com/leanEthereum/multilinear-toolkit.git#eeb6404188e4b4c9207b9e8e8a2120156602d92e" +source = "git+https://github.com/leanEthereum/multilinear-toolkit.git#bd8a91199f45fcb3c21af056468340e2f9de2d1d" dependencies = [ "air 0.3.0", "backend", @@ -265,10 +265,12 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "fiat-shamir" -version = "0.1.0" -source = "git+https://github.com/leanEthereum/fiat-shamir.git#493be07bdd8669a816d28c3befc08bc3e68e590a" +version = "0.3.0" +source = "git+https://github.com/leanEthereum/multilinear-toolkit.git#bd8a91199f45fcb3c21af056468340e2f9de2d1d" dependencies = [ "p3-field", + "p3-koala-bear", + "p3-poseidon2", "p3-symmetric", "rayon", "serde", @@ -367,7 +369,6 @@ dependencies = [ "rec_aggregation", "sub_protocols", "utils", - "whir-p3", "xmss", ] @@ -388,7 +389,6 @@ dependencies = [ "sub_protocols", "tracing", "utils", - "whir-p3", "xmss", ] @@ -411,7 +411,6 @@ dependencies = [ "sub_protocols", "tracing", "utils", - "whir-p3", "witness_generation", "xmss", ] @@ -436,7 +435,6 @@ dependencies = [ "thiserror", "tracing", "utils", - "whir-p3", "xmss", ] @@ -470,17 +468,19 @@ checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "multilinear-toolkit" version = "0.3.0" -source = "git+https://github.com/leanEthereum/multilinear-toolkit.git#eeb6404188e4b4c9207b9e8e8a2120156602d92e" +source = "git+https://github.com/leanEthereum/multilinear-toolkit.git#bd8a91199f45fcb3c21af056468340e2f9de2d1d" dependencies = [ "air 0.3.0", "backend", "constraints-folder", "fiat-shamir", "p3-field", + "p3-maybe-rayon", "p3-util", "rayon", "sumcheck", "tracing", + "whir", ] [[package]] @@ -554,19 +554,6 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" -[[package]] -name = "p3-baby-bear" -version = "0.3.0" -source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-multisig#1f5aca1d6845caec76fa25b00fae3ea4f07ef930" -dependencies = [ - "p3-field", - "p3-mds", - "p3-monty-31", - "p3-poseidon2", - "p3-symmetric", - "rand", -] - [[package]] name = "p3-challenger" version = "0.3.0" @@ -621,17 +608,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "p3-interpolation" -version = "0.3.0" -source = "git+https://github.com/TomWambsgans/Plonky3.git?branch=lean-multisig#1f5aca1d6845caec76fa25b00fae3ea4f07ef930" -dependencies = [ - "p3-field", - "p3-matrix", - "p3-maybe-rayon", - "p3-util", -] - [[package]] name = "p3-koala-bear" version = "0.3.0" @@ -919,7 +895,6 @@ dependencies = [ "sub_protocols", "tracing", "utils", - "whir-p3", "xmss", ] @@ -1069,13 +1044,12 @@ dependencies = [ "rand", "tracing", "utils", - "whir-p3", ] [[package]] name = "sumcheck" version = "0.3.0" -source = "git+https://github.com/leanEthereum/multilinear-toolkit.git#eeb6404188e4b4c9207b9e8e8a2120156602d92e" +source = "git+https://github.com/leanEthereum/multilinear-toolkit.git#bd8a91199f45fcb3c21af056468340e2f9de2d1d" dependencies = [ "air 0.3.0", "backend", @@ -1301,28 +1275,25 @@ dependencies = [ ] [[package]] -name = "whir-p3" -version = "0.1.0" -source = "git+https://github.com/TomWambsgans/whir-p3?branch=lean-multisig#bc7bf99c224d63582945f065f555b9824d843d3c" +name = "whir" +version = "0.3.0" +source = "git+https://github.com/leanEthereum/multilinear-toolkit.git#bd8a91199f45fcb3c21af056468340e2f9de2d1d" dependencies = [ + "backend", + "fiat-shamir", "itertools", - "multilinear-toolkit", - "p3-baby-bear", "p3-commit", "p3-dft", "p3-field", - "p3-interpolation", "p3-koala-bear", "p3-matrix", - "p3-maybe-rayon", "p3-merkle-tree", "p3-symmetric", "p3-util", "rand", "rayon", + "sumcheck", "tracing", - "tracing-forest", - "tracing-subscriber", ] [[package]] @@ -1396,7 +1367,6 @@ dependencies = [ "sub_protocols", "tracing", "utils", - "whir-p3", "xmss", ] @@ -1414,18 +1384,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.34" +version = "0.8.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71ddd76bcebeed25db614f82bf31a9f4222d3fbba300e6fb6c00afa26cbd4d9d" +checksum = "7456cf00f0685ad319c5b1693f291a650eaf345e941d082fc4e03df8a03996ac" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.34" +version = "0.8.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8187381b52e32220d50b255276aa16a084ec0a9017a0ca2152a1f55c539758d" +checksum = "1328722bbf2115db7e19d69ebcc15e795719e2d66b60827c6a69a117365e37a0" dependencies = [ "proc-macro2", "quote", @@ -1434,6 +1404,6 @@ dependencies = [ [[package]] name = "zmij" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02aae0f83f69aafc94776e879363e9771d7ecbffe2c7fbb6c14c5e00dfe88439" +checksum = "1966f8ac2c1f76987d69a74d0e0f929241c10e78136434e3be70ff7f58f64214" diff --git a/Cargo.toml b/Cargo.toml index bc37a467..9e8d3fd1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,8 +78,8 @@ p3-goldilocks = { git = "https://github.com/TomWambsgans/Plonky3.git", branch = p3-util = { git = "https://github.com/TomWambsgans/Plonky3.git", branch = "lean-multisig" } p3-monty-31 = { git = "https://github.com/TomWambsgans/Plonky3.git", branch = "lean-multisig" } -whir-p3 = { git = "https://github.com/TomWambsgans/whir-p3", branch = "lean-multisig" } multilinear-toolkit = { git = "https://github.com/leanEthereum/multilinear-toolkit.git" } + [dependencies] clap.workspace = true rec_aggregation.workspace = true @@ -91,7 +91,6 @@ utils.workspace = true p3-koala-bear.workspace = true lean_vm.workspace = true multilinear-toolkit.workspace = true -whir-p3.workspace = true [profile.release] lto = "thin" diff --git a/README.md b/README.md index 2e171dcd..cda2c3c7 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ To reproduce: ### Proof size -WHIR intial rate = 1/4. Proof size ≈ 380 KiB. TODO: Merkle pruning + WHIR batch opening -> 256 KiB. (To go below 256 KiB -> rate 1/8 or 1/16 in the final recursion). +WHIR intial rate = 1/4. Proof size ≈ 325 KiB. TODO: WHIR batch opening + [2024/108](https://eprint.iacr.org/2024/108.pdf) section 3.1 -> close to 256 KiB. (To go below 256 KiB -> rate 1/8 or 1/16 in the final recursion). ## Credits diff --git a/crates/lean_compiler/Cargo.toml b/crates/lean_compiler/Cargo.toml index e33b21b2..506d006e 100644 --- a/crates/lean_compiler/Cargo.toml +++ b/crates/lean_compiler/Cargo.toml @@ -16,7 +16,6 @@ p3-poseidon2.workspace = true p3-koala-bear.workspace = true p3-symmetric.workspace = true p3-util.workspace = true -whir-p3.workspace = true tracing.workspace = true air.workspace = true sub_protocols.workspace = true diff --git a/crates/lean_prover/Cargo.toml b/crates/lean_prover/Cargo.toml index ed4593e7..caf9d445 100644 --- a/crates/lean_prover/Cargo.toml +++ b/crates/lean_prover/Cargo.toml @@ -16,7 +16,6 @@ p3-poseidon2.workspace = true p3-koala-bear.workspace = true p3-symmetric.workspace = true p3-util.workspace = true -whir-p3.workspace = true tracing.workspace = true air.workspace = true sub_protocols.workspace = true diff --git a/crates/lean_prover/src/common.rs b/crates/lean_prover/src/common.rs index b196fde7..411cf433 100644 --- a/crates/lean_prover/src/common.rs +++ b/crates/lean_prover/src/common.rs @@ -1,6 +1,5 @@ use crate::*; use lean_vm::*; -use multilinear_toolkit::prelude::*; pub(crate) fn fold_bytecode(bytecode: &Bytecode, folding_challenges: &MultilinearPoint) -> Vec { let encoded_bytecode = padd_with_zero_to_next_power_of_two( diff --git a/crates/lean_prover/src/lib.rs b/crates/lean_prover/src/lib.rs index e14d05bb..92339a1c 100644 --- a/crates/lean_prover/src/lib.rs +++ b/crates/lean_prover/src/lib.rs @@ -1,10 +1,10 @@ #![cfg_attr(not(test), allow(unused_crate_dependencies))] use lean_vm::{EF, F}; +use multilinear_toolkit::prelude::*; use utils::*; use lean_vm::execute_bytecode; -use whir_p3::{FoldingFactor, SecurityAssumption, WhirConfigBuilder}; use witness_generation::*; mod common; diff --git a/crates/lean_prover/src/prove_execution.rs b/crates/lean_prover/src/prove_execution.rs index 12da4c96..5ef4f698 100644 --- a/crates/lean_prover/src/prove_execution.rs +++ b/crates/lean_prover/src/prove_execution.rs @@ -4,13 +4,11 @@ use crate::common::*; use crate::*; use air::prove_air; use lean_vm::*; -use multilinear_toolkit::prelude::*; use p3_util::log2_ceil_usize; use sub_protocols::*; use tracing::info_span; use utils::{build_prover_state, padd_with_zero_to_next_power_of_two}; -use whir_p3::{SparseStatement, SparseValue, WhirConfig}; use xmss::Poseidon16History; #[derive(Debug)] @@ -219,9 +217,9 @@ pub fn prove_execution( bytecode_pushforward_commitment, &bytecode_pushforward.by_ref(), ); - let proof_size_fe = prover_state.proof_size_fe(); + let proof_size_fe = prover_state.pruned_proof().proof_size_fe(); ExecutionProof { - proof: prover_state.into_proof(), + proof: prover_state.raw_proof(), proof_size_fe, exec_summary, first_whir_n_vars, diff --git a/crates/lean_prover/src/verify_execution.rs b/crates/lean_prover/src/verify_execution.rs index e5a0ac17..e2d227b9 100644 --- a/crates/lean_prover/src/verify_execution.rs +++ b/crates/lean_prover/src/verify_execution.rs @@ -4,12 +4,10 @@ use crate::*; use crate::{SnarkParams, common::*}; use air::verify_air; use lean_vm::*; -use multilinear_toolkit::prelude::*; use p3_util::{log2_ceil_usize, log2_strict_usize}; use sub_protocols::verify_logup_star; use sub_protocols::*; use utils::ToUsize; -use whir_p3::{SparseStatement, SparseValue, WhirConfig}; #[derive(Debug, Clone)] pub struct ProofVerificationDetails { diff --git a/crates/lean_prover/witness_generation/Cargo.toml b/crates/lean_prover/witness_generation/Cargo.toml index 01cfdb45..714476e9 100644 --- a/crates/lean_prover/witness_generation/Cargo.toml +++ b/crates/lean_prover/witness_generation/Cargo.toml @@ -16,7 +16,6 @@ p3-poseidon2.workspace = true p3-koala-bear.workspace = true p3-symmetric.workspace = true p3-util.workspace = true -whir-p3.workspace = true tracing.workspace = true air.workspace = true sub_protocols.workspace = true diff --git a/crates/lean_vm/Cargo.toml b/crates/lean_vm/Cargo.toml index 1f3b9bf3..bc61e2ad 100644 --- a/crates/lean_vm/Cargo.toml +++ b/crates/lean_vm/Cargo.toml @@ -17,7 +17,6 @@ p3-poseidon2.workspace = true p3-koala-bear.workspace = true p3-symmetric.workspace = true p3-util.workspace = true -whir-p3.workspace = true tracing.workspace = true air.workspace = true thiserror.workspace = true diff --git a/crates/rec_aggregation/Cargo.toml b/crates/rec_aggregation/Cargo.toml index 07c2dbd4..5db55cfc 100644 --- a/crates/rec_aggregation/Cargo.toml +++ b/crates/rec_aggregation/Cargo.toml @@ -14,7 +14,6 @@ p3-poseidon2.workspace = true p3-koala-bear.workspace = true p3-symmetric.workspace = true p3-util.workspace = true -whir-p3.workspace = true tracing.workspace = true air.workspace = true sub_protocols.workspace = true diff --git a/crates/rec_aggregation/src/recursion.rs b/crates/rec_aggregation/src/recursion.rs index 0f4aabdb..bd2b90b8 100644 --- a/crates/rec_aggregation/src/recursion.rs +++ b/crates/rec_aggregation/src/recursion.rs @@ -13,7 +13,6 @@ use multilinear_toolkit::prelude::symbolic::{ }; use multilinear_toolkit::prelude::*; use utils::{Counter, MEMORY_TABLE_INDEX}; -use whir_p3::{WhirConfig, precompute_dft_twiddles}; pub fn run_recursion_benchmark(count: usize, tracing: bool) { if tracing { @@ -341,7 +340,7 @@ def main(): ); println!("{}", recursion_proof.exec_summary); println!( - "{}->1 recursion proving time: {} ms (1->1: {} ms), proof size: {} KiB (not optimized)", + "{}->1 recursion proving time: {} ms (1->1: {} ms), proof size: {} KiB", count, proving_time.as_millis(), proving_time.as_millis() / count as u128, diff --git a/crates/rec_aggregation/src/xmss_aggregate.rs b/crates/rec_aggregation/src/xmss_aggregate.rs index 7dbacea9..c26070d0 100644 --- a/crates/rec_aggregation/src/xmss_aggregate.rs +++ b/crates/rec_aggregation/src/xmss_aggregate.rs @@ -8,7 +8,6 @@ use std::sync::OnceLock; use std::time::Instant; use tracing::{info_span, instrument}; use utils::to_little_endian_in_field; -use whir_p3::precompute_dft_twiddles; use xmss::{ Poseidon16History, V, XMSS_MAX_LOG_LIFETIME, XmssPublicKey, XmssSignature, xmss_generate_phony_signatures, xmss_verify_with_poseidon_trace, @@ -97,7 +96,7 @@ pub fn run_xmss_benchmark(log_lifetimes: &[usize], tracing: bool) { println!("{summary}"); println!( - "XMSS aggregation, proving time: {:.3} s ({:.1} XMSS/s), proof size: {} KiB (not optimized)", + "XMSS aggregation, proving time: {:.3} s ({:.1} XMSS/s), proof size: {} KiB", proving_time.as_secs_f64(), log_lifetimes.len() as f64 / proving_time.as_secs_f64(), n_field_elements_in_proof * F::bits() / (8 * 1024) diff --git a/crates/sub_protocols/Cargo.toml b/crates/sub_protocols/Cargo.toml index 51d8314d..bc353456 100644 --- a/crates/sub_protocols/Cargo.toml +++ b/crates/sub_protocols/Cargo.toml @@ -9,7 +9,6 @@ workspace = true [dependencies] tracing.workspace = true utils.workspace = true -whir-p3.workspace = true p3-util.workspace = true lean_vm.workspace = true multilinear-toolkit.workspace = true diff --git a/crates/sub_protocols/src/packed_pcs.rs b/crates/sub_protocols/src/packed_pcs.rs index b8919ee0..68c7c47b 100644 --- a/crates/sub_protocols/src/packed_pcs.rs +++ b/crates/sub_protocols/src/packed_pcs.rs @@ -5,7 +5,6 @@ use p3_util::log2_ceil_usize; use std::collections::BTreeMap; use tracing::instrument; use utils::{VarCount, transpose_slice_to_basis_coefficients}; -use whir_p3::*; #[derive(Debug)] pub struct MultiCommitmentWitness { diff --git a/crates/utils/src/wrappers.rs b/crates/utils/src/wrappers.rs index 0c2aca6d..37e0dd9f 100644 --- a/crates/utils/src/wrappers.rs +++ b/crates/utils/src/wrappers.rs @@ -15,7 +15,7 @@ pub fn build_prover_state() -> ProverState pub fn build_verifier_state( prover_state: ProverState, ) -> VerifierState { - let mut verifier_state = VerifierState::new(prover_state.into_proof(), get_poseidon16().clone()); + let mut verifier_state = VerifierState::new(prover_state.raw_proof(), get_poseidon16().clone()); verifier_state.duplexing(); verifier_state } diff --git a/src/lib.rs b/src/lib.rs index 042356e0..78ee4d3c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +use multilinear_toolkit::prelude::*; pub use multilinear_toolkit::prelude::{ PrimeCharacteristicRing, // to allow `F::from_usize` ProofError, @@ -17,7 +18,7 @@ pub use xmss::{ pub fn xmss_aggregation_setup_prover() { rec_aggregation::xmss_aggregate::xmss_setup_aggregation_program(); - whir_p3::precompute_dft_twiddles::(1 << 24); + precompute_dft_twiddles::(1 << 24); } pub fn xmss_aggregation_setup_verifier() { diff --git a/src/prove_poseidons.rs b/src/prove_poseidons.rs index 87a6aafc..714a3010 100644 --- a/src/prove_poseidons.rs +++ b/src/prove_poseidons.rs @@ -9,7 +9,6 @@ use rand::{Rng, SeedableRng, rngs::StdRng}; use utils::{ build_prover_state, build_verifier_state, collect_refs, init_tracing, padd_with_zero_to_next_power_of_two, }; -use whir_p3::{FoldingFactor, SecurityAssumption, SparseStatement, WhirConfig, WhirConfigBuilder}; const WIDTH: usize = 16; const UNIVARIATE_SKIPS: usize = 3;