diff --git a/optimism/src/proof.rs b/optimism/src/proof.rs index bf7193f424..3e86055ea1 100644 --- a/optimism/src/proof.rs +++ b/optimism/src/proof.rs @@ -80,9 +80,10 @@ pub fn fold< }; let mut fq_sponge = EFqSponge::new(G::other_curve_sponge_params()); - for column in commitments.into_iter() { - absorb_commitment(&mut fq_sponge, &column); - } + commitments.into_iter().for_each(|comm| { + absorb_commitment(&mut fq_sponge, &comm); + }); + let scaling_challenge = ScalarChallenge(fq_sponge.challenge()); let (_, endo_r) = G::endos(); let scaling_challenge = scaling_challenge.to_field(endo_r); @@ -235,9 +236,9 @@ pub fn verify< } = proof; let mut fq_sponge = EFqSponge::new(G::other_curve_sponge_params()); - for column in commitments.clone().into_iter() { - absorb_commitment(&mut fq_sponge, &column); - } + commitments.into_iter().for_each(|comm| { + absorb_commitment(&mut fq_sponge, comm); + }); let zeta_chal = ScalarChallenge(fq_sponge.challenge()); let (_, endo_r) = G::endos(); let zeta: G::ScalarField = zeta_chal.to_field(endo_r); diff --git a/optimism/src/witness.rs b/optimism/src/witness.rs index 8df9dab665..9d1bd11803 100644 --- a/optimism/src/witness.rs +++ b/optimism/src/witness.rs @@ -20,7 +20,7 @@ impl Default for Witness { // IMPLEMENTATION OF ITERATORS FOR THE WITNESS STRUCTURE -impl IntoIterator for Witness { +impl IntoIterator for Witness { type Item = F; type IntoIter = std::vec::IntoIter; @@ -32,6 +32,17 @@ impl IntoIterator for Witness { } } +impl<'lt, const N: usize, G> IntoIterator for &'lt Witness { + type Item = &'lt G; + type IntoIter = std::vec::IntoIter<&'lt G>; + + fn into_iter(self) -> Self::IntoIter { + let mut iter_contents = Vec::with_capacity(N); + iter_contents.extend(&self.cols); + iter_contents.into_iter() + } +} + impl IntoParallelIterator for Witness where Vec: IntoParallelIterator,