diff --git a/src/sonic/helped/prover.rs b/src/sonic/helped/prover.rs index 2ae45ec..43355d6 100644 --- a/src/sonic/helped/prover.rs +++ b/src/sonic/helped/prover.rs @@ -20,7 +20,7 @@ pub fn create_advice_on_information_and_srs, S: Synthes proof: &Proof, srs: &SRS, n: usize -) -> SxyAdvice +) -> Result, SynthesisError> { let z: E::Fr; let y: E::Fr; @@ -31,11 +31,11 @@ pub fn create_advice_on_information_and_srs, S: Synthes transcript.commit_point(&proof.t); z = transcript.get_challenge_scalar(); } - let z_inv = z.inverse().unwrap(); // TODO + let z_inv = z.inverse().ok_or(SynthesisError::DivisionByZero)?; let (s_poly_negative, s_poly_positive) = { let mut tmp = SxEval::new(y, n); - S::synthesize(&mut tmp, circuit).unwrap(); // TODO + S::synthesize(&mut tmp, circuit)?; tmp.poly() }; @@ -87,18 +87,18 @@ pub fn create_advice_on_information_and_srs, S: Synthes ).into_affine() }; - SxyAdvice { + Ok(SxyAdvice { s, szy, opening - } + }) } pub fn create_advice, S: SynthesisDriver>( circuit: &C, proof: &Proof, parameters: &Parameters, -) -> SxyAdvice +) -> Result, SynthesisError> { let n = parameters.vk.n; create_advice_on_information_and_srs::(circuit, proof, ¶meters.srs, n) @@ -108,7 +108,7 @@ pub fn create_advice_on_srs, S: SynthesisDriver>( circuit: &C, proof: &Proof, srs: &SRS -) -> SxyAdvice +) -> Result, SynthesisError> { // annoying, but we need n to compute s(z, y), and this isn't // precomputed anywhere yet @@ -124,7 +124,7 @@ pub fn create_advice_on_srs, S: SynthesisDriver>( } let mut tmp = CountN{n:0}; - S::synthesize(&mut tmp, circuit).unwrap(); // TODO + S::synthesize(&mut tmp, circuit)?; tmp.n }; @@ -216,7 +216,7 @@ pub fn create_proof, S: SynthesisDriver>( rx1.extend(wires.a); let mut rxy = rx1.clone(); - let y_inv = y.inverse().unwrap(); // TODO + let y_inv = y.inverse().ok_or(SynthesisError::DivisionByZero)?; let mut tmp = y.pow(&[n as u64]); for rxy in rxy.iter_mut().rev() { @@ -226,7 +226,7 @@ pub fn create_proof, S: SynthesisDriver>( let (s_poly_negative, s_poly_positive) = { let mut tmp = SxEval::new(y, n); - S::synthesize(&mut tmp, circuit).unwrap(); // TODO + S::synthesize(&mut tmp, circuit)?; tmp.poly() }; @@ -262,7 +262,7 @@ pub fn create_proof, S: SynthesisDriver>( transcript.commit_point(&t); let z: E::Fr = transcript.get_challenge_scalar(); - let z_inv = z.inverse().unwrap(); // TODO + let z_inv = z.inverse().ok_or(SynthesisError::DivisionByZero)?; // TODO: use the faster way to evaluate the polynomials let mut rz = E::Fr::zero();