diff --git a/src/bin/benchmark.rs b/src/bin/benchmark.rs index 2a67c5d..e4a805f 100644 --- a/src/bin/benchmark.rs +++ b/src/bin/benchmark.rs @@ -339,7 +339,7 @@ fn run_whir( .collect(); let evaluations = points .iter() - .map(|point| polynomial.evaluate_at_extension(&point)) + .map(|point| polynomial.evaluate_at_extension(point)) .collect(); let statement = Statement { points, diff --git a/src/bin/main.rs b/src/bin/main.rs index a1d83b8..a90818a 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -356,7 +356,7 @@ fn run_whir_pcs( .collect(); let evaluations = points .iter() - .map(|point| polynomial.evaluate_at_extension(&point)) + .map(|point| polynomial.evaluate_at_extension(point)) .collect(); let statement = Statement { diff --git a/src/crypto/merkle_tree/blake3.rs b/src/crypto/merkle_tree/blake3.rs index 4f30592..6090915 100644 --- a/src/crypto/merkle_tree/blake3.rs +++ b/src/crypto/merkle_tree/blake3.rs @@ -122,8 +122,8 @@ pub fn default_config( as CRHScheme>::Parameters, ::Parameters, ) { - let leaf_hash_params = as CRHScheme>::setup(rng).unwrap(); - let two_to_one_params = ::setup(rng).unwrap(); + as CRHScheme>::setup(rng).unwrap(); + ::setup(rng).unwrap(); - (leaf_hash_params, two_to_one_params) + ((), ()) } diff --git a/src/crypto/merkle_tree/keccak.rs b/src/crypto/merkle_tree/keccak.rs index 93a97b9..c4f8558 100644 --- a/src/crypto/merkle_tree/keccak.rs +++ b/src/crypto/merkle_tree/keccak.rs @@ -83,8 +83,8 @@ impl TwoToOneCRHScheme for KeccakTwoToOneCRHScheme { right_input: T, ) -> Result { let mut h = sha3::Keccak256::new(); - h.update(&left_input.borrow().0); - h.update(&right_input.borrow().0); + h.update(left_input.borrow().0); + h.update(right_input.borrow().0); let mut output = [0; 32]; output.copy_from_slice(&h.finalize()[..]); HashCounter::add(); @@ -123,8 +123,8 @@ pub fn default_config( as CRHScheme>::Parameters, ::Parameters, ) { - let leaf_hash_params = as CRHScheme>::setup(rng).unwrap(); - let two_to_one_params = ::setup(rng).unwrap(); + as CRHScheme>::setup(rng).unwrap(); + ::setup(rng).unwrap(); - (leaf_hash_params, two_to_one_params) + ((), ()) } diff --git a/src/crypto/merkle_tree/mock.rs b/src/crypto/merkle_tree/mock.rs index 8ac9f3b..9102490 100644 --- a/src/crypto/merkle_tree/mock.rs +++ b/src/crypto/merkle_tree/mock.rs @@ -58,10 +58,12 @@ pub fn default_config( as CRHScheme>::Parameters, ::Parameters, ) { - let leaf_hash_params = as CRHScheme>::setup(rng).unwrap(); - let two_to_one_params = ::setup(rng) - .unwrap() - .clone(); + as CRHScheme>::setup(rng).unwrap(); + { + ::setup(rng) + .unwrap(); + + }; - (leaf_hash_params, two_to_one_params) + ((), ()) } diff --git a/src/ntt/transpose.rs b/src/ntt/transpose.rs index e6bc6c8..be81ebf 100644 --- a/src/ntt/transpose.rs +++ b/src/ntt/transpose.rs @@ -54,9 +54,9 @@ fn transpose_copy(src: MatrixMut, dst: MatrixMut) /// Sets `dst` to the transpose of `src`. This will panic if the sizes of `src` and `dst` are not compatible. #[cfg(feature = "parallel")] -fn transpose_copy_parallel<'a, 'b, F: Sized + Copy + Send>( - src: MatrixMut<'a, F>, - mut dst: MatrixMut<'b, F>, +fn transpose_copy_parallel( + src: MatrixMut<'_, F>, + mut dst: MatrixMut<'_, F>, ) { assert_eq!(src.rows(), dst.cols()); assert_eq!(src.cols(), dst.rows()); @@ -85,9 +85,9 @@ fn transpose_copy_parallel<'a, 'b, F: Sized + Copy + Send>( /// Sets `dst` to the transpose of `src`. This will panic if the sizes of `src` and `dst` are not compatible. /// This is the non-parallel version -fn transpose_copy_not_parallel<'a, 'b, F: Sized + Copy>( - src: MatrixMut<'a, F>, - mut dst: MatrixMut<'b, F>, +fn transpose_copy_not_parallel( + src: MatrixMut<'_, F>, + mut dst: MatrixMut<'_, F>, ) { assert_eq!(src.rows(), dst.cols()); assert_eq!(src.cols(), dst.rows()); diff --git a/src/ntt/utils.rs b/src/ntt/utils.rs index 11ccdc3..e177d4e 100644 --- a/src/ntt/utils.rs +++ b/src/ntt/utils.rs @@ -142,7 +142,6 @@ mod tests { ); let should_not_work = std::panic::catch_unwind(|| { as_chunks_exact_mut::<_, 2>(&mut [1, 2, 3]); - return; }); assert!(should_not_work.is_err()) } diff --git a/src/poly_utils/fold.rs b/src/poly_utils/fold.rs index 44bf9a8..69f5e90 100644 --- a/src/poly_utils/fold.rs +++ b/src/poly_utils/fold.rs @@ -179,7 +179,7 @@ mod tests { // Evaluate the polynomial on the domain let domain_evaluations: Vec<_> = (0..domain_size) - .map(|w| root_of_unity.pow([w as u64])) + .map(|w| root_of_unity.pow([w])) .map(|point| { poly.evaluate(&MultilinearPoint::expand_from_univariate( point, @@ -199,10 +199,10 @@ mod tests { ); let num = domain_size / folding_factor_exp; - let coset_gen_inv = root_of_unity_inv.pow(&[num]); + let coset_gen_inv = root_of_unity_inv.pow([num]); for index in 0..num { - let offset_inv = root_of_unity_inv.pow(&[index]); + let offset_inv = root_of_unity_inv.pow([index]); let span = (index * folding_factor_exp) as usize..((index + 1) * folding_factor_exp) as usize; diff --git a/src/poly_utils/sequential_lag_poly.rs b/src/poly_utils/sequential_lag_poly.rs index c59355f..d9a203f 100644 --- a/src/poly_utils/sequential_lag_poly.rs +++ b/src/poly_utils/sequential_lag_poly.rs @@ -6,6 +6,7 @@ use super::{hypercube::BinaryHypercubePoint, MultilinearPoint}; /// There is an alternative (possibly more efficient) implementation that iterates over the x in Gray code ordering. +/// /// LagrangePolynomialIterator for a given multilinear n-dimensional `point` iterates over pairs (x, y) /// where x ranges over all possible {0,1}^n /// and y equals the product y_1 * ... * y_n where @@ -60,7 +61,7 @@ impl Iterator for LagrangePolynomialIterator { // Iterator implementation for the struct fn next(&mut self) -> Option { // a) Check if this is the first iteration - if self.last_position == None { + if self.last_position.is_none() { // Initialize last position self.last_position = Some(0); // Return the top of the stack diff --git a/src/poly_utils/streaming_evaluation_helper.rs b/src/poly_utils/streaming_evaluation_helper.rs index 322a6e5..8b2cfe3 100644 --- a/src/poly_utils/streaming_evaluation_helper.rs +++ b/src/poly_utils/streaming_evaluation_helper.rs @@ -37,7 +37,7 @@ impl Iterator for TermPolynomialIterator { // Iterator implementation for the struct fn next(&mut self) -> Option { // a) Check if this is the first iteration - if self.last_position == None { + if self.last_position.is_none() { // Initialize last position self.last_position = Some(0); // Return the top of the stack diff --git a/src/sumcheck/mod.rs b/src/sumcheck/mod.rs index eaeac85..0c1d45a 100644 --- a/src/sumcheck/mod.rs +++ b/src/sumcheck/mod.rs @@ -99,7 +99,7 @@ mod tests { // First, check that is sums to the right value over the hypercube assert_eq!(poly_1.sum_over_hypercube(), claimed_value); - let combination_randomness = vec![F::from(293), F::from(42)]; + let combination_randomness = [F::from(293), F::from(42)]; let folding_randomness = MultilinearPoint(vec![F::from(335), F::from(222)]); let new_eval_point = MultilinearPoint(vec![F::from(32); num_variables - folding_factor]); @@ -146,7 +146,7 @@ mod tests { let [epsilon_1, epsilon_2] = [F::from(15), F::from(32)]; let folding_randomness_1 = MultilinearPoint(vec![F::from(11), F::from(31)]); let fold_point = MultilinearPoint(vec![F::from(31), F::from(15)]); - let combination_randomness = vec![F::from(31), F::from(4999)]; + let combination_randomness = [F::from(31), F::from(4999)]; let folding_randomness_2 = MultilinearPoint(vec![F::from(97), F::from(36)]); let mut prover = SumcheckCore::new( @@ -184,7 +184,7 @@ mod tests { ); let full_folding = - MultilinearPoint(vec![folding_randomness_2.0.clone(), folding_randomness_1.0].concat()); + MultilinearPoint([folding_randomness_2.0.clone(), folding_randomness_1.0].concat()); let eval_coeff = folded_poly_1.fold(&folding_randomness_2).coeffs()[0]; assert_eq!( sumcheck_poly_2.evaluate_at_point(&folding_randomness_2), @@ -217,8 +217,8 @@ mod tests { let fold_point_12 = MultilinearPoint(vec![F::from(1231), F::from(15), F::from(4231), F::from(15)]); let fold_point_2 = MultilinearPoint(vec![F::from(311), F::from(115)]); - let combination_randomness_1 = vec![F::from(1289), F::from(3281), F::from(10921)]; - let combination_randomness_2 = vec![F::from(3281), F::from(3232)]; + let combination_randomness_1 = [F::from(1289), F::from(3281), F::from(10921)]; + let combination_randomness_2 = [F::from(3281), F::from(3232)]; let mut prover = SumcheckCore::new( polynomial.clone(), diff --git a/src/sumcheck/proof.rs b/src/sumcheck/proof.rs index 36cfe27..2455541 100644 --- a/src/sumcheck/proof.rs +++ b/src/sumcheck/proof.rs @@ -90,7 +90,7 @@ mod tests { let num_evaluation_points = 3_usize.pow(num_variables as u32); let evaluations = (0..num_evaluation_points as u64).map(F::from).collect(); - let poly = SumcheckPolynomial::new(evaluations, num_variables as usize); + let poly = SumcheckPolynomial::new(evaluations, num_variables); for i in 0..num_evaluation_points { let decomp = base_decomposition(i, 3, num_variables); diff --git a/src/utils.rs b/src/utils.rs index 9fcc0aa..fc0104a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -121,11 +121,11 @@ mod tests { #[test] fn test_is_power_of_two() { - assert_eq!(is_power_of_two(0), false); - assert_eq!(is_power_of_two(1), true); - assert_eq!(is_power_of_two(2), true); - assert_eq!(is_power_of_two(3), false); - assert_eq!(is_power_of_two(usize::MAX), false); + assert!(!is_power_of_two(0)); + assert!(is_power_of_two(1)); + assert!(is_power_of_two(2)); + assert!(!is_power_of_two(3)); + assert!(!is_power_of_two(usize::MAX)); } #[test] diff --git a/src/whir/fs_utils.rs b/src/whir/fs_utils.rs index 245cbb5..e435b99 100644 --- a/src/whir/fs_utils.rs +++ b/src/whir/fs_utils.rs @@ -1,8 +1,4 @@ -use crate::domain::Domain; use crate::utils::dedup; -use crate::whir::parameters::{RoundConfig, WhirConfig}; -use ark_crypto_primitives::merkle_tree; -use ark_ff::FftField; use nimue::{ByteChallenges, ProofResult}; pub fn get_challenge_stir_queries( diff --git a/src/whir/parameters.rs b/src/whir/parameters.rs index 9ee3476..5d45116 100644 --- a/src/whir/parameters.rs +++ b/src/whir/parameters.rs @@ -198,7 +198,7 @@ where final_pow_bits, final_sumcheck_rounds, final_folding_pow_bits, - pow_strategy: PhantomData::default(), + pow_strategy: PhantomData, fold_optimisation: whir_parameters.fold_optimisation, final_log_inv_rate: log_inv_rate, leaf_hash_params: whir_parameters.leaf_hash_params, @@ -241,13 +241,13 @@ where ) -> f64 { match soundness_type { SoundnessType::ConjectureList => { - let result = (num_variables + log_inv_rate) as f64 - log_eta; - result + + (num_variables + log_inv_rate) as f64 - log_eta } SoundnessType::ProvableList => { let log_inv_sqrt_rate: f64 = log_inv_rate as f64 / 2.; - let result = log_inv_sqrt_rate - (1. + log_eta); - result + + log_inv_sqrt_rate - (1. + log_eta) } SoundnessType::UniqueDecoding => 0.0, } @@ -385,7 +385,9 @@ where num_queries: usize, ) -> f64 { let num_queries = num_queries as f64; - let bits_of_sec_queries = match soundness_type { + + + match soundness_type { SoundnessType::UniqueDecoding => { let rate = 1. / ((1 << log_inv_rate) as f64); let denom = -(0.5 * (1. + rate)).log2(); @@ -394,9 +396,7 @@ where } SoundnessType::ProvableList => num_queries * 0.5 * log_inv_rate as f64, SoundnessType::ConjectureList => num_queries * log_inv_rate as f64, - }; - - bits_of_sec_queries + } } pub fn rbr_soundness_queries_combination( @@ -488,7 +488,7 @@ where writeln!( f, "{:.1} bits -- (x{}) prox gaps: {:.1}, sumcheck: {:.1}, pow: {:.1}", - prox_gaps_error.min(sumcheck_error) + self.starting_folding_pow_bits as f64, + prox_gaps_error.min(sumcheck_error) + self.starting_folding_pow_bits, self.folding_factor, prox_gaps_error, sumcheck_error, @@ -529,7 +529,7 @@ where writeln!( f, "{:.1} bits -- query error: {:.1}, combination: {:.1}, pow: {:.1}", - query_error.min(combination_error) + r.pow_bits as f64, + query_error.min(combination_error) + r.pow_bits, query_error, combination_error, r.pow_bits, @@ -553,7 +553,7 @@ where writeln!( f, "{:.1} bits -- (x{}) prox gaps: {:.1}, sumcheck: {:.1}, pow: {:.1}", - prox_gaps_error.min(sumcheck_error) + r.folding_pow_bits as f64, + prox_gaps_error.min(sumcheck_error) + r.folding_pow_bits, self.folding_factor, prox_gaps_error, sumcheck_error, @@ -571,7 +571,7 @@ where writeln!( f, "{:.1} bits -- query error: {:.1}, pow: {:.1}", - query_error + self.final_pow_bits as f64, + query_error + self.final_pow_bits, query_error, self.final_pow_bits, )?; @@ -581,7 +581,7 @@ where writeln!( f, "{:.1} bits -- (x{}) combination: {:.1}, pow: {:.1}", - combination_error + self.final_pow_bits as f64, + combination_error + self.final_pow_bits, self.final_sumcheck_rounds, combination_error, self.final_folding_pow_bits, diff --git a/src/whir/prover.rs b/src/whir/prover.rs index 2505050..62ed1cd 100644 --- a/src/whir/prover.rs +++ b/src/whir/prover.rs @@ -15,11 +15,9 @@ use ark_crypto_primitives::merkle_tree::{Config, MerkleTree, MultiPath}; use ark_ff::FftField; use ark_poly::EvaluationDomain; use nimue::{ - plugins::ark::{FieldChallenges, FieldWriter}, - ByteChallenges, ByteWriter, Merlin, ProofResult, + plugins::ark::{FieldChallenges, FieldWriter}, ByteWriter, Merlin, ProofResult, }; use nimue_pow::{self, PoWChallenge}; -use rand::{Rng, SeedableRng}; use crate::whir::fs_utils::get_challenge_stir_queries; #[cfg(feature = "parallel")] diff --git a/src/whir/verifier.rs b/src/whir/verifier.rs index 5f72a50..885ef53 100644 --- a/src/whir/verifier.rs +++ b/src/whir/verifier.rs @@ -5,10 +5,9 @@ use ark_ff::FftField; use ark_poly::EvaluationDomain; use nimue::{ plugins::ark::{FieldChallenges, FieldReader}, - Arthur, ByteChallenges, ByteReader, ProofError, ProofResult, + Arthur, ByteReader, ProofError, ProofResult, }; use nimue_pow::{self, PoWChallenge}; -use rand::{Rng, SeedableRng}; use super::{parameters::WhirConfig, Statement, WhirProof}; use crate::whir::fs_utils::get_challenge_stir_queries; @@ -16,7 +15,7 @@ use crate::{ parameters::FoldType, poly_utils::{coeffs::CoefficientList, eq_poly_outside, fold::compute_fold, MultilinearPoint}, sumcheck::proof::SumcheckPolynomial, - utils::{self, expand_randomness}, + utils::{expand_randomness}, }; pub struct Verifier @@ -335,7 +334,7 @@ where .map(|(point, rand)| point * rand) .sum(); - value = value + sum_of_claims; + value += sum_of_claims; } value diff --git a/src/whir_ldt/parameters.rs b/src/whir_ldt/parameters.rs index 2a579e6..72d21fd 100644 --- a/src/whir_ldt/parameters.rs +++ b/src/whir_ldt/parameters.rs @@ -181,7 +181,7 @@ where final_pow_bits, final_sumcheck_rounds, final_folding_pow_bits, - pow_strategy: PhantomData::default(), + pow_strategy: PhantomData, fold_optimisation: whir_parameters.fold_optimisation, final_log_inv_rate: log_inv_rate, leaf_hash_params: whir_parameters.leaf_hash_params, @@ -219,13 +219,13 @@ where ) -> f64 { match soundness_type { SoundnessType::ConjectureList => { - let result = (num_variables + log_inv_rate) as f64 - log_eta; - result + + (num_variables + log_inv_rate) as f64 - log_eta } SoundnessType::ProvableList => { let log_inv_sqrt_rate: f64 = log_inv_rate as f64 / 2.; - let result = log_inv_sqrt_rate - (1. + log_eta); - result + + log_inv_sqrt_rate - (1. + log_eta) } SoundnessType::UniqueDecoding => 0.0, } @@ -363,7 +363,9 @@ where num_queries: usize, ) -> f64 { let num_queries = num_queries as f64; - let bits_of_sec_queries = match soundness_type { + + + match soundness_type { SoundnessType::UniqueDecoding => { let rate = 1. / ((1 << log_inv_rate) as f64); let denom = -(0.5 * (1. + rate)).log2(); @@ -372,9 +374,7 @@ where } SoundnessType::ProvableList => num_queries * 0.5 * log_inv_rate as f64, SoundnessType::ConjectureList => num_queries * log_inv_rate as f64, - }; - - bits_of_sec_queries + } } pub fn rbr_soundness_queries_combination( @@ -445,7 +445,7 @@ where writeln!( f, "{:.1} bits -- prox gaps: {:.1}, pow: {:.1}", - prox_gaps_error + self.starting_folding_pow_bits as f64, + prox_gaps_error + self.starting_folding_pow_bits, prox_gaps_error, self.starting_folding_pow_bits, )?; @@ -484,7 +484,7 @@ where writeln!( f, "{:.1} bits -- query error: {:.1}, combination: {:.1}, pow: {:.1}", - query_error.min(combination_error) + r.pow_bits as f64, + query_error.min(combination_error) + r.pow_bits, query_error, combination_error, r.pow_bits, @@ -508,7 +508,7 @@ where writeln!( f, "{:.1} bits -- (x{}) prox gaps: {:.1}, sumcheck: {:.1}, pow: {:.1}", - prox_gaps_error.min(sumcheck_error) + r.folding_pow_bits as f64, + prox_gaps_error.min(sumcheck_error) + r.folding_pow_bits, self.folding_factor, prox_gaps_error, sumcheck_error, @@ -526,7 +526,7 @@ where writeln!( f, "{:.1} bits -- query error: {:.1}, pow: {:.1}", - query_error + self.final_pow_bits as f64, + query_error + self.final_pow_bits, query_error, self.final_pow_bits, )?; @@ -536,7 +536,7 @@ where writeln!( f, "{:.1} bits -- (x{}) combination: {:.1}, pow: {:.1}", - combination_error + self.final_pow_bits as f64, + combination_error + self.final_pow_bits, self.final_sumcheck_rounds, combination_error, self.final_folding_pow_bits, diff --git a/src/whir_ldt/verifier.rs b/src/whir_ldt/verifier.rs index e5e47f8..6b47901 100644 --- a/src/whir_ldt/verifier.rs +++ b/src/whir_ldt/verifier.rs @@ -291,7 +291,7 @@ where .map(|(point, rand)| point * rand) .sum(); - value = value + sum_of_claims; + value += sum_of_claims; } value