From 4171495e6e6d5db635747911a00a25cd1204180d Mon Sep 17 00:00:00 2001 From: Chao Ma Date: Sat, 30 Nov 2024 16:00:38 +0700 Subject: [PATCH] cargo fmt --- src/crypto/merkle_tree/mock.rs | 4 +--- src/fs_utils.rs | 2 +- src/ntt/transpose.rs | 5 +---- src/sumcheck/prover_not_skipping.rs | 31 +++++++++++++++++++++-------- src/whir/mod.rs | 8 ++++---- src/whir/pcs.rs | 2 +- src/whir/prover.rs | 13 ++++++------ src/whir/verifier.rs | 4 ++-- 8 files changed, 40 insertions(+), 29 deletions(-) diff --git a/src/crypto/merkle_tree/mock.rs b/src/crypto/merkle_tree/mock.rs index 9102490..4becc42 100644 --- a/src/crypto/merkle_tree/mock.rs +++ b/src/crypto/merkle_tree/mock.rs @@ -60,9 +60,7 @@ pub fn default_config( ) { as CRHScheme>::setup(rng).unwrap(); { - ::setup(rng) - .unwrap(); - + ::setup(rng).unwrap(); }; ((), ()) diff --git a/src/fs_utils.rs b/src/fs_utils.rs index d3cceaa..4cc732d 100644 --- a/src/fs_utils.rs +++ b/src/fs_utils.rs @@ -24,7 +24,7 @@ pub trait WhirPoWIOPattern { fn pow(self, bits: f64) -> Self; } -impl WhirPoWIOPattern for IOPattern +impl WhirPoWIOPattern for IOPattern where IOPattern: PoWIOPattern, { diff --git a/src/ntt/transpose.rs b/src/ntt/transpose.rs index be81ebf..ec96e52 100644 --- a/src/ntt/transpose.rs +++ b/src/ntt/transpose.rs @@ -85,10 +85,7 @@ fn transpose_copy_parallel( /// 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( - src: MatrixMut<'_, F>, - mut dst: MatrixMut<'_, 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()); if src.rows() * src.cols() > workload_size::() { diff --git a/src/sumcheck/prover_not_skipping.rs b/src/sumcheck/prover_not_skipping.rs index 6edae62..79c9aaf 100644 --- a/src/sumcheck/prover_not_skipping.rs +++ b/src/sumcheck/prover_not_skipping.rs @@ -1,5 +1,8 @@ use ark_ff::Field; -use nimue::{plugins::ark::{FieldChallenges, FieldIOPattern, FieldWriter}, IOPattern, ProofResult}; +use nimue::{ + plugins::ark::{FieldChallenges, FieldIOPattern, FieldWriter}, + IOPattern, ProofResult, +}; use nimue_pow::{PoWChallenge, PowStrategy}; use crate::{ @@ -101,7 +104,10 @@ where #[cfg(test)] mod tests { use ark_ff::Field; - use nimue::{plugins::ark::{FieldChallenges, FieldIOPattern, FieldReader}, IOPattern, Merlin, ProofResult}; + use nimue::{ + plugins::ark::{FieldChallenges, FieldIOPattern, FieldReader}, + IOPattern, Merlin, ProofResult, + }; use nimue_pow::blake3::Blake3PoW; use crate::{ @@ -151,8 +157,11 @@ mod tests { ], ); - let folding_randomness_1 = - prover.compute_sumcheck_polynomials::(&mut merlin, folding_factor, 0.)?; + let folding_randomness_1 = prover.compute_sumcheck_polynomials::( + &mut merlin, + folding_factor, + 0., + )?; // Compute the answers let folded_poly_1 = polynomial.fold(&folding_randomness_1); @@ -237,15 +246,21 @@ mod tests { ], ); - let folding_randomness_1 = - prover.compute_sumcheck_polynomials::(&mut merlin, folding_factor, 0.)?; + let folding_randomness_1 = prover.compute_sumcheck_polynomials::( + &mut merlin, + folding_factor, + 0., + )?; let folded_poly_1 = polynomial.fold(&folding_randomness_1); let fold_eval = folded_poly_1.evaluate_at_extension(&fold_point); prover.add_new_equality(&[fold_point.clone()], &combination_randomness, &[fold_eval]); - let folding_randomness_2 = - prover.compute_sumcheck_polynomials::(&mut merlin, folding_factor, 0.)?; + let folding_randomness_2 = prover.compute_sumcheck_polynomials::( + &mut merlin, + folding_factor, + 0., + )?; // Compute the answers let folded_poly_1 = polynomial.fold(&folding_randomness_1); diff --git a/src/whir/mod.rs b/src/whir/mod.rs index a8c5d24..b189755 100644 --- a/src/whir/mod.rs +++ b/src/whir/mod.rs @@ -1,19 +1,19 @@ use ark_crypto_primitives::merkle_tree::{Config, MultiPath}; +use ark_ff::FftField; use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; -use goldilocks::ExtensionField; -use serde::{de::DeserializeOwned, Serialize}; +// use goldilocks::ExtensionField; use std::fmt::Debug; use crate::errors::Error; use crate::poly_utils::MultilinearPoint; pub mod committer; +mod fs_utils; pub mod iopattern; pub mod parameters; pub mod pcs; pub mod prover; pub mod verifier; -mod fs_utils; #[derive(Debug, Clone, Default)] pub struct Statement { @@ -39,7 +39,7 @@ where transcript.len() + whir_proof.serialized_size(ark_serialize::Compress::Yes) } -pub trait PolynomialCommitmentScheme: Clone { +pub trait PolynomialCommitmentScheme: Clone { type Param: Clone; type ProverParam: Clone; type VerifierParam: Clone; diff --git a/src/whir/pcs.rs b/src/whir/pcs.rs index cb13e79..21c38ad 100644 --- a/src/whir/pcs.rs +++ b/src/whir/pcs.rs @@ -19,7 +19,7 @@ type WhirPCSConfig = WhirConfig, ()>; impl PolynomialCommitmentScheme for Whir where - E: FftField + ExtensionField + CanonicalSerialize + CanonicalDeserialize, + E: FftField + CanonicalSerialize + CanonicalDeserialize, { type Param = WhirPCSConfig; type ProverParam = WhirPCSConfig; diff --git a/src/whir/prover.rs b/src/whir/prover.rs index cc04ba7..2bc5694 100644 --- a/src/whir/prover.rs +++ b/src/whir/prover.rs @@ -176,7 +176,7 @@ where self.0.final_queries, merlin, )?; - + let merkle_proof = round_state .prev_merkle .generate_multi_proof(final_challenge_indexes.clone()) @@ -351,11 +351,12 @@ where ) }); - let folding_randomness = sumcheck_prover.compute_sumcheck_polynomials::( - merlin, - self.0.folding_factor, - round_params.folding_pow_bits, - )?; + let folding_randomness = sumcheck_prover + .compute_sumcheck_polynomials::( + merlin, + self.0.folding_factor, + round_params.folding_pow_bits, + )?; let round_state = RoundState { round: round_state.round + 1, diff --git a/src/whir/verifier.rs b/src/whir/verifier.rs index f1663a0..3969cd5 100644 --- a/src/whir/verifier.rs +++ b/src/whir/verifier.rs @@ -4,8 +4,8 @@ use ark_crypto_primitives::merkle_tree::Config; use ark_ff::FftField; use ark_poly::EvaluationDomain; use nimue::{ - plugins::ark::{FieldChallenges, FieldReader} - , ByteChallenges, ByteReader, ProofError, ProofResult, + plugins::ark::{FieldChallenges, FieldReader}, + ByteChallenges, ByteReader, ProofError, ProofResult, }; use nimue_pow::{self, PoWChallenge};