Skip to content

Commit

Permalink
Merge pull request #60 from clearmatics/plonk-error-handling-issue-57
Browse files Browse the repository at this point in the history
Plonk: error-handling
  • Loading branch information
dtebbs authored Jul 29, 2022
2 parents 3397c23 + d879714 commit ae9d145
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
10 changes: 3 additions & 7 deletions libsnark/zk_proof_systems/plonk/prover.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,9 @@ round_three_out_t<ppT> plonk_prover<ppT>::round_three(
polynomial<Field> remainder;
libfqfft::_polynomial_division(
t_poly_long, remainder, t_poly_long, round_zero_out.zh_poly);
try {
bool b_zero_remainder = libfqfft::_is_zero(remainder);
if (!b_zero_remainder) {
throw std::logic_error("Non-zero remainder in polynomial division");
}
} catch (const std::logic_error &e) {
std::cout << "Error: " << e.what() << "\n";
bool b_zero_remainder = libfqfft::_is_zero(remainder);
if (!b_zero_remainder) {
throw std::logic_error("Non-zero remainder in polynomial division");
}

// break this->t_poly_long into three parts: lo, mid, hi, each of
Expand Down
26 changes: 10 additions & 16 deletions libsnark/zk_proof_systems/plonk/utils.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,11 @@ void plonk_compute_roots_of_unity_omega(
{
// ensure that num_gates is not 0 and is power of 2
// TODO: check also that it's less than 2^(ppT::s)
try {
bool b_nonzero = (num_gates > 0);
bool b_is_power2 = ((num_gates & (num_gates - 1)) == 0);
if (!(b_nonzero && b_is_power2)) {
throw std::invalid_argument("Curve is not BLS12-381");
}
} catch (const std::invalid_argument &e) {
std::cout << "Error: " << e.what() << "\n";
bool b_nonzero = (num_gates > 0);
bool b_is_power2 = ((num_gates & (num_gates - 1)) == 0);
if (!(b_nonzero && b_is_power2)) {
throw std::invalid_argument(
"Number of gates not power of 2 or is zero.");
}
omega.resize(NUM_HSETS, std::vector<FieldT>(num_gates));

Expand Down Expand Up @@ -177,14 +174,11 @@ void plonk_compute_cosets_H_k1H_k2H(
std::vector<FieldT> &H_gen)
{
// ensure that num_gates is not 0 and is power of 2
try {
bool b_nonzero = (num_gates > 0);
bool b_is_power2 = ((num_gates & (num_gates - 1)) == 0);
if (!(b_nonzero && b_is_power2)) {
throw std::invalid_argument("Curve is not BLS12-381");
}
} catch (const std::invalid_argument &e) {
std::cout << "Error: " << e.what() << "\n";
bool b_nonzero = (num_gates > 0);
bool b_is_power2 = ((num_gates & (num_gates - 1)) == 0);
if (!(b_nonzero && b_is_power2)) {
throw std::invalid_argument(
"Number of gates not power of 2 or is zero.");
}

// omega[0] are the n roots of unity, omega[1] are omega[0]*k1,
Expand Down

0 comments on commit ae9d145

Please sign in to comment.