diff --git a/kzg_prover/benches/kzg.rs b/kzg_prover/benches/kzg.rs index b4600da8..c9f80a09 100644 --- a/kzg_prover/benches/kzg.rs +++ b/kzg_prover/benches/kzg.rs @@ -56,7 +56,7 @@ fn bench_kzg< let verifying_grand_sum_bench_name = format!("<{}> verifying grand sum", name); let verifying_user_bench_name = format!("<{}> verifying user inclusion", name); - let mut entries: Vec> = vec![Entry::init_empty(); N_USERS]; + let mut entries: Vec> = vec![Entry::init_empty(); 64]; let mut cryptos = vec![Cryptocurrency::init_empty(); N_CURRENCIES]; parse_csv_to_entries::<&str, N_CURRENCIES>(csv_path, &mut entries, &mut cryptos).unwrap(); @@ -71,15 +71,15 @@ fn bench_kzg< let circuit = UnivariateGrandSum::::init(entries.to_vec()); - // c.bench_function(&range_check_proof_bench_name, |b| { - // b.iter_batched( - // || circuit.clone(), // Setup function: clone the circuit for each iteration - // |circuit| { - // full_prover(¶ms, &pk, circuit, &[vec![]]); - // }, - // criterion::BatchSize::SmallInput, // Choose an appropriate batch size - // ); - // }); + c.bench_function(&range_check_proof_bench_name, |b| { + b.iter_batched( + || circuit.clone(), // Setup function: clone the circuit for each iteration + |circuit| { + full_prover(¶ms, &pk, circuit, &[vec![]]); + }, + criterion::BatchSize::SmallInput, // Choose an appropriate batch size + ); + }); let (zk_snark_proof, advice_polys, omega) = full_prover(¶ms, &pk, circuit, &[vec![]]); @@ -126,10 +126,10 @@ fn bench_kzg< // }); // Generate a random user index - let get_random_user_index = || { - let user_range: std::ops::Range = 0..N_USERS; - OsRng.gen_range(user_range) as u16 - }; + // let get_random_user_index = || { + // let user_range: std::ops::Range = 0..N_USERS; + // OsRng.gen_range(user_range) as u16 + // }; // c.bench_function(&opening_user_bench_name, |b| { // b.iter_batched( @@ -156,25 +156,25 @@ fn bench_kzg< // ); // }); - c.bench_function(&calculate_h_bench_name, |b| { - b.iter_batched( - || (0..N_CURRENCIES + 1), - |column_range| compute_h_parallel(&advice_polys.advice_polys, ¶ms, column_range), - criterion::BatchSize::SmallInput, - ); - }); + // c.bench_function(&calculate_h_bench_name, |b| { + // b.iter_batched( + // || (0..N_CURRENCIES + 1), + // |column_range| compute_h_parallel(&advice_polys.advice_polys, ¶ms, column_range), + // criterion::BatchSize::SmallInput, + // ); + // }); - let h_vectors = compute_h_parallel(&advice_polys.advice_polys, ¶ms, 0..N_CURRENCIES + 1); - let vec_of_slices = h_vectors.iter().map(|v| v.as_slice()).collect::>(); - let h_slices = vec_of_slices.as_slice(); + // let h_vectors = compute_h_parallel(&advice_polys.advice_polys, ¶ms, 0..N_CURRENCIES + 1); + // let vec_of_slices = h_vectors.iter().map(|v| v.as_slice()).collect::>(); + // let h_slices = vec_of_slices.as_slice(); - c.bench_function(&amortized_opening_all_bench_name, |b| { - b.iter_batched( - || {}, - |_| open_all_user_points_amortized(h_slices, omega), - criterion::BatchSize::SmallInput, - ); - }); + // c.bench_function(&amortized_opening_all_bench_name, |b| { + // b.iter_batched( + // || {}, + // |_| open_all_user_points_amortized(h_slices, omega), + // criterion::BatchSize::SmallInput, + // ); + // }); // c.bench_function(&amortized_opening_user_bench_name, |b| { // b.iter_batched( @@ -273,11 +273,11 @@ fn criterion_benchmark(_c: &mut Criterion) { // } #[cfg(not(feature = "no_range_check"))] { - const K: u32 = 18; - const N_USERS: usize = 64; + const K: u32 = 26; + const N_USERS: usize = (2_u32.pow(25_u32)) as usize; bench_kzg::>( format!("K = {K}, N_USERS = {N_USERS}, N_CURRENCIES = {N_CURRENCIES}").as_str(), - format!("../csv/entry_64.csv").as_str(), + format!("../csv/entry_64_350.csv").as_str(), ); } // Use the following benchmarks for quick evaluation/prototyping (no range check) diff --git a/kzg_prover/src/circuits/univariate_grand_sum.rs b/kzg_prover/src/circuits/univariate_grand_sum.rs index fb8a9524..ea072919 100644 --- a/kzg_prover/src/circuits/univariate_grand_sum.rs +++ b/kzg_prover/src/circuits/univariate_grand_sum.rs @@ -203,12 +203,16 @@ pub trait CircuitConfig: Clone || "username", self.get_username(), i, - || Value::known(big_uint_to_fp(entries[i].username_as_big_uint())), + || { + Value::known(big_uint_to_fp( + entries[i % entries.len()].username_as_big_uint(), + )) + }, )?; let mut assigned_balances_row = vec![]; - for (j, balance) in entries[i].balances().iter().enumerate() { + for (j, balance) in entries[i % entries.len()].balances().iter().enumerate() { let assigned_balance = region.assign_advice( || format!("balance {}", j), self.get_balances()[j],