diff --git a/src/plonk/lookup/prover.rs b/src/plonk/lookup/prover.rs index f13bcdb..2ee207d 100644 --- a/src/plonk/lookup/prover.rs +++ b/src/plonk/lookup/prover.rs @@ -344,13 +344,10 @@ impl<'a, C: CurveAffine> Committed<'a, C> { theta: ChallengeTheta, beta: ChallengeBeta, gamma: ChallengeGamma, - ) -> Result< - ( - Constructed, - impl Iterator> + 'a, - ), - Error, - > { + ) -> ( + Constructed, + impl Iterator> + 'a, + ) { let permuted = self.permuted; let expressions = iter::empty() @@ -417,7 +414,7 @@ impl<'a, C: CurveAffine> Committed<'a, C> { * &(permuted.permuted_input_coset.clone() - &permuted.permuted_input_inv_coset), )); - Ok(( + ( Constructed { permuted_input_poly: permuted.permuted_input_poly, permuted_input_blind: permuted.permuted_input_blind, @@ -427,7 +424,7 @@ impl<'a, C: CurveAffine> Committed<'a, C> { product_blind: self.product_blind, }, expressions, - )) + ) } } @@ -506,6 +503,8 @@ impl Evaluated { } } +type ColumnPair = (Polynomial, Polynomial); + /// Given a column of input values A and a column of table values S, /// this method permutes A and S to produce A' and S', such that: /// - like values in A' are vertically adjacent to each other; and @@ -516,13 +515,7 @@ fn permute_column_pair( domain: &EvaluationDomain, input_column: &Polynomial, table_column: &Polynomial, -) -> Result< - ( - Polynomial, - Polynomial, - ), - Error, -> { +) -> Result, Error> { let mut permuted_input_column = input_column.clone(); // Sort input lookup column values diff --git a/src/plonk/permutation/prover.rs b/src/plonk/permutation/prover.rs index 5af58e8..fb75a0a 100644 --- a/src/plonk/permutation/prover.rs +++ b/src/plonk/permutation/prover.rs @@ -141,13 +141,10 @@ impl Committed { advice_cosets: &'a [Polynomial], beta: ChallengeBeta, gamma: ChallengeGamma, - ) -> Result< - ( - Constructed, - impl Iterator> + 'a, - ), - Error, - > { + ) -> ( + Constructed, + impl Iterator> + 'a, + ) { let domain = &pk.vk.domain; let expressions = iter::empty() @@ -197,13 +194,13 @@ impl Committed { left - &right })); - Ok(( + ( Constructed { permutation_product_poly: self.permutation_product_poly, permutation_product_blind: self.permutation_product_blind, }, expressions, - )) + ) } } diff --git a/src/plonk/prover.rs b/src/plonk/prover.rs index 3f2db38..a7f1118 100644 --- a/src/plonk/prover.rs +++ b/src/plonk/prover.rs @@ -208,24 +208,24 @@ pub fn create_proof, ConcreteCircuit: Circ // Evaluate the h(X) polynomial's constraint system expressions for the permutation constraints, if any. let (permutations, permutation_expressions): (Vec<_>, Vec<_>) = { - let tmp = permutations + let tmp: Vec<_> = permutations .into_iter() .zip(pk.vk.cs.permutations.iter()) .zip(pk.permutations.iter()) .map(|((p, argument), pkey)| { p.construct(pk, argument, pkey, &advice_cosets, beta, gamma) }) - .collect::, _>>()?; + .collect(); tmp.into_iter().unzip() }; // Evaluate the h(X) polynomial's constraint system expressions for the lookup constraints, if any. let (lookups, lookup_expressions): (Vec<_>, Vec<_>) = { - let tmp = lookups + let tmp: Vec<_> = lookups .into_iter() .map(|p| p.construct(pk, theta, beta, gamma)) - .collect::, _>>()?; + .collect(); tmp.into_iter().unzip() }; diff --git a/src/plonk/vanishing/prover.rs b/src/plonk/vanishing/prover.rs index 30f11d1..2e0eccc 100644 --- a/src/plonk/vanishing/prover.rs +++ b/src/plonk/vanishing/prover.rs @@ -89,10 +89,10 @@ impl Constructed { } impl Evaluated { - pub(in crate::plonk) fn open<'a>( - &'a self, + pub(in crate::plonk) fn open( + &self, x: ChallengeX, - ) -> impl Iterator> + Clone { + ) -> impl Iterator> + Clone { self.constructed .h_pieces .iter() diff --git a/src/plonk/vanishing/verifier.rs b/src/plonk/vanishing/verifier.rs index f132756..7a4f134 100644 --- a/src/plonk/vanishing/verifier.rs +++ b/src/plonk/vanishing/verifier.rs @@ -70,10 +70,10 @@ impl Evaluated { Ok(()) } - pub(in crate::plonk) fn queries<'a>( - &'a self, + pub(in crate::plonk) fn queries( + &self, x: ChallengeX, - ) -> impl Iterator> + Clone { + ) -> impl Iterator> + Clone { self.h_commitments .iter() .zip(self.h_evals.iter()) diff --git a/src/poly/commitment/prover.rs b/src/poly/commitment/prover.rs index 7c043cc..3f51865 100644 --- a/src/poly/commitment/prover.rs +++ b/src/poly/commitment/prover.rs @@ -63,10 +63,8 @@ pub fn create_proof>( let mut final_poly = s_poly * iota + px; let v = eval_polynomial(&final_poly, x); final_poly[0] = final_poly[0] - &v; - drop(px); let blind = s_poly_blind * Blind(iota) + blind; let mut blind = blind.0; - drop(s_poly_blind); // Initialize the vector `a` as the coefficients of the polynomial, // rounding up to the parameters. diff --git a/src/poly/commitment/verifier.rs b/src/poly/commitment/verifier.rs index f902c37..da057fd 100644 --- a/src/poly/commitment/verifier.rs +++ b/src/poly/commitment/verifier.rs @@ -61,7 +61,7 @@ impl<'a, C: CurveAffine> Guard<'a, C> { } } -/// Checks to see if an [`Proof`] is valid given the current `transcript`, and a +/// Checks to see if the proof represented within `transcript` is valid, and a /// point `x` that the polynomial commitment `P` opens purportedly to the value /// `v`. The provided `msm` should evaluate to the commitment `P` being opened. pub fn verify_proof<'a, C: CurveAffine, T: TranscriptRead>( @@ -160,7 +160,7 @@ fn compute_b(x: F, challenges: &[F]) -> F { /// Computes the coefficients of $g(X) = \prod\limits_{i=0}^{k-1} (1 + u_i X^{2^i})$. fn compute_s(challenges: &[F], init: F) -> Vec { - assert!(challenges.len() > 0); + assert!(!challenges.is_empty()); let mut v = vec![F::zero(); 1 << challenges.len()]; v[0] = init; diff --git a/src/poly/multiopen.rs b/src/poly/multiopen.rs index a8880e7..98fd746 100644 --- a/src/poly/multiopen.rs +++ b/src/poly/multiopen.rs @@ -87,9 +87,12 @@ trait Query: Sized { fn get_commitment(&self) -> Self::Commitment; } -fn construct_intermediate_sets>( - queries: I, -) -> (Vec>, Vec>) +type IntermediateSets = ( + Vec>::Eval, >::Commitment>>, + Vec>, +); + +fn construct_intermediate_sets>(queries: I) -> IntermediateSets where I: IntoIterator + Clone, { diff --git a/src/poly/multiopen/prover.rs b/src/poly/multiopen/prover.rs index 1b9faf4..1eb1c58 100644 --- a/src/poly/multiopen/prover.rs +++ b/src/poly/multiopen/prover.rs @@ -104,7 +104,7 @@ where let x_4 = ChallengeX4::get(transcript); let (f_poly, f_blind_try) = q_polys.iter().zip(q_blinds.iter()).fold( - (f_poly.clone(), f_blind), + (f_poly, f_blind), |(f_poly, f_blind), (poly, blind)| { ( f_poly * *x_4 + poly.as_ref().unwrap(), diff --git a/src/transcript.rs b/src/transcript.rs index 7772fac..b1cbeb9 100644 --- a/src/transcript.rs +++ b/src/transcript.rs @@ -66,10 +66,9 @@ impl TranscriptRead for DummyHashRead { fn read_point(&mut self) -> io::Result { let mut compressed = [0u8; 32]; self.reader.read_exact(&mut compressed[..])?; - let point: C = Option::from(C::from_bytes(&compressed)).ok_or(io::Error::new( - io::ErrorKind::Other, - "invalid point encoding in proof", - ))?; + let point: C = Option::from(C::from_bytes(&compressed)).ok_or_else(|| { + io::Error::new(io::ErrorKind::Other, "invalid point encoding in proof") + })?; self.common_point(point)?; Ok(point) @@ -78,10 +77,12 @@ impl TranscriptRead for DummyHashRead { fn read_scalar(&mut self) -> io::Result { let mut data = [0u8; 32]; self.reader.read_exact(&mut data)?; - let scalar = Option::from(C::Scalar::from_bytes(&data)).ok_or(io::Error::new( - io::ErrorKind::Other, - "invalid field element encoding in proof", - ))?; + let scalar = Option::from(C::Scalar::from_bytes(&data)).ok_or_else(|| { + io::Error::new( + io::ErrorKind::Other, + "invalid field element encoding in proof", + ) + })?; self.scalar_state += &(scalar * &C::Scalar::ZETA); self.scalar_state = self.scalar_state.square(); self.read_scalar = true; @@ -92,10 +93,12 @@ impl TranscriptRead for DummyHashRead { impl Transcript for DummyHashRead { fn common_point(&mut self, point: C) -> io::Result<()> { - let (x, y) = Option::from(point.get_xy()).ok_or(io::Error::new( - io::ErrorKind::Other, - "cannot write points at infinity to the transcript", - ))?; + let (x, y) = Option::from(point.get_xy()).ok_or_else(|| { + io::Error::new( + io::ErrorKind::Other, + "cannot write points at infinity to the transcript", + ) + })?; self.base_state += &(x * &C::Base::ZETA); self.base_state = self.base_state.square(); self.base_state += &(y * &C::Base::ZETA); @@ -170,10 +173,12 @@ impl TranscriptWrite for DummyHashWrite { impl Transcript for DummyHashWrite { fn common_point(&mut self, point: C) -> io::Result<()> { - let (x, y) = Option::from(point.get_xy()).ok_or(io::Error::new( - io::ErrorKind::Other, - "cannot write points at infinity to the transcript", - ))?; + let (x, y) = Option::from(point.get_xy()).ok_or_else(|| { + io::Error::new( + io::ErrorKind::Other, + "cannot write points at infinity to the transcript", + ) + })?; self.base_state += &(x * &C::Base::ZETA); self.base_state = self.base_state.square(); self.base_state += &(y * &C::Base::ZETA);