Skip to content

Commit

Permalink
handle division by zero error
Browse files Browse the repository at this point in the history
  • Loading branch information
jotabulacios committed Feb 24, 2025
1 parent 66b4ef5 commit 669e7a3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion provers/plonk/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ use lambdaworks_math::{
};
use lambdaworks_math::{field::traits::IsField, traits::ByteConversion};

#[derive(Debug)]
pub enum ProverError {
DivisionByZero,
}
/// Plonk proof.
/// The challenges are denoted
/// Round 2: β,γ,
Expand Down Expand Up @@ -362,7 +366,9 @@ where
* lp(c_i, &(&cpi.domain[i] * &k2));
let den = lp(a_i, &s1[i]) * lp(b_i, &s2[i]) * lp(c_i, &s3[i]);
// We are using that den != 0 with high probability because beta and gamma are random elements.
let new_factor = (num / den).expect("Unexpected zero denominator in round 2");
let new_factor = (num / den)
.map_err(|_| ProverError::DivisionByZero)
.unwrap();

let new_term = coefficients.last().unwrap() * &new_factor;
coefficients.push(new_term);
Expand Down

0 comments on commit 669e7a3

Please # to comment.