diff --git a/src/plonk/prover.rs b/src/plonk/prover.rs index e82777d..54c15f3 100644 --- a/src/plonk/prover.rs +++ b/src/plonk/prover.rs @@ -105,7 +105,9 @@ impl Proof { drop(aux_commitments_projective); for commitment in &aux_commitments { - transcript.absorb_point(commitment).ok(); + transcript + .absorb_point(commitment) + .map_err(|_| Error::TranscriptError)?; } let aux_polys: Vec<_> = aux @@ -143,7 +145,9 @@ impl Proof { drop(advice_commitments_projective); for commitment in &advice_commitments { - transcript.absorb_point(commitment).ok(); + transcript + .absorb_point(commitment) + .map_err(|_| Error::TranscriptError)?; } let advice_polys: Vec<_> = witness @@ -277,7 +281,9 @@ impl Proof { // Hash each permutation product commitment for c in &permutation_product_commitments { - transcript.absorb_point(c).ok(); + transcript + .absorb_point(c) + .map_err(|_| Error::TranscriptError)?; } // Obtain challenge for keeping all separate gates linearly independent @@ -385,7 +391,9 @@ impl Proof { // Hash each h(X) piece for c in h_commitments.iter() { - transcript.absorb_point(c).ok(); + transcript + .absorb_point(c) + .map_err(|_| Error::TranscriptError)?; } let x_3: C::Scalar = get_challenge_scalar(Challenge(transcript.squeeze().get_lower_128())); diff --git a/src/plonk/verifier.rs b/src/plonk/verifier.rs index 7a949d8..23fd8f6 100644 --- a/src/plonk/verifier.rs +++ b/src/plonk/verifier.rs @@ -31,12 +31,16 @@ impl<'a, C: CurveAffine> Proof { // Hash the aux (external) commitments into the transcript for commitment in aux_commitments { - transcript.absorb_point(commitment).ok(); + transcript + .absorb_point(commitment) + .map_err(|_| Error::TranscriptError)?; } // Hash the prover's advice commitments into the transcript for commitment in &self.advice_commitments { - transcript.absorb_point(commitment).ok(); + transcript + .absorb_point(commitment) + .map_err(|_| Error::TranscriptError)?; } // Sample x_0 challenge @@ -47,7 +51,9 @@ impl<'a, C: CurveAffine> Proof { // Hash each permutation product commitment for c in &self.permutation_product_commitments { - transcript.absorb_point(c).ok(); + transcript + .absorb_point(c) + .map_err(|_| Error::TranscriptError)?; } // Sample x_2 challenge, which keeps the gates linearly independent. @@ -55,7 +61,9 @@ impl<'a, C: CurveAffine> Proof { // Obtain a commitment to h(X) in the form of multiple pieces of degree n - 1 for c in &self.h_commitments { - transcript.absorb_point(c).ok(); + transcript + .absorb_point(c) + .map_err(|_| Error::TranscriptError)?; } // Sample x_3 challenge, which is used to ensure the circuit is diff --git a/src/poly/commitment/prover.rs b/src/poly/commitment/prover.rs index 6efc316..8b87e05 100644 --- a/src/poly/commitment/prover.rs +++ b/src/poly/commitment/prover.rs @@ -96,8 +96,12 @@ impl Proof { // Feed L and R into the cloned transcript. // We expect these to not be points at infinity due to the randomness. - transcript.absorb_point(&l).ok(); - transcript.absorb_point(&r).ok(); + transcript + .absorb_point(&l) + .map_err(|_| Error::SamplingError)?; + transcript + .absorb_point(&r) + .map_err(|_| Error::SamplingError)?; // ... and get the squared challenge. let challenge_sq_packed = transcript.squeeze().get_lower_128(); @@ -121,8 +125,12 @@ impl Proof { let challenge_sq = challenge.square(); // Feed L and R into the real transcript - transcript.absorb_point(&l).ok(); - transcript.absorb_point(&r).ok(); + transcript + .absorb_point(&l) + .map_err(|_| Error::SamplingError)?; + transcript + .absorb_point(&r) + .map_err(|_| Error::SamplingError)?; // And obtain the challenge, even though we already have it, since // squeezing affects the transcript. @@ -168,7 +176,9 @@ impl Proof { let delta = best_multiexp(&[d, d * &b, s], &[g, u, params.h]).to_affine(); // Feed delta into the transcript - transcript.absorb_point(&delta).ok(); + transcript + .absorb_point(&delta) + .map_err(|_| Error::SamplingError)?; // Obtain the challenge c. let c_packed = transcript.squeeze().get_lower_128(); diff --git a/src/poly/commitment/verifier.rs b/src/poly/commitment/verifier.rs index 827a53b..94361bd 100644 --- a/src/poly/commitment/verifier.rs +++ b/src/poly/commitment/verifier.rs @@ -114,8 +114,12 @@ impl Proof { if bool::from(l.get_xy().is_none() | r.get_xy().is_none()) { return Err(Error::OpeningError); } - transcript.absorb_point(&l).ok(); - transcript.absorb_point(&r).ok(); + transcript + .absorb_point(&l) + .map_err(|_| Error::OpeningError)?; + transcript + .absorb_point(&r) + .map_err(|_| Error::OpeningError)?; let challenge_sq_packed = transcript.squeeze().get_lower_128(); let challenge_sq: C::Scalar = get_challenge_scalar(Challenge(challenge_sq_packed)); @@ -154,7 +158,9 @@ impl Proof { } // Feed delta into the transcript - transcript.absorb_point(&delta).ok(); + transcript + .absorb_point(&delta) + .map_err(|_| Error::OpeningError)?; // Get the challenge `c` let c_packed = transcript.squeeze().get_lower_128();