mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-03 19:53:40 +00:00
Update error handling
This commit is contained in:
parent
43337dea1b
commit
2375507f4f
4 changed files with 48 additions and 16 deletions
|
|
@ -105,7 +105,9 @@ impl<C: CurveAffine> Proof<C> {
|
|||
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<C: CurveAffine> Proof<C> {
|
|||
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<C: CurveAffine> Proof<C> {
|
|||
|
||||
// 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<C: CurveAffine> Proof<C> {
|
|||
|
||||
// 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()));
|
||||
|
|
|
|||
|
|
@ -31,12 +31,16 @@ impl<'a, C: CurveAffine> Proof<C> {
|
|||
|
||||
// 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<C> {
|
|||
|
||||
// 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<C> {
|
|||
|
||||
// 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
|
||||
|
|
|
|||
|
|
@ -96,8 +96,12 @@ impl<C: CurveAffine> Proof<C> {
|
|||
|
||||
// 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<C: CurveAffine> Proof<C> {
|
|||
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<C: CurveAffine> Proof<C> {
|
|||
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();
|
||||
|
|
|
|||
|
|
@ -114,8 +114,12 @@ impl<C: CurveAffine> Proof<C> {
|
|||
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<C: CurveAffine> Proof<C> {
|
|||
}
|
||||
|
||||
// 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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue