Skip to content

Commit

Permalink
fix: stick to num_chunk of quotient poly calculated by constraint s…
Browse files Browse the repository at this point in the history
…ystem (#29)
  • Loading branch information
han0110 authored Feb 22, 2023
1 parent f1265f5 commit 54452c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions snark-verifier/src/system/halo2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ struct Polynomials<'a, F: FieldExt> {
zk: bool,
query_instance: bool,
num_proof: usize,
degree: usize,
num_fixed: usize,
num_permutation_fixed: usize,
num_instance: Vec<usize>,
Expand Down Expand Up @@ -245,6 +246,7 @@ impl<'a, F: FieldExt> Polynomials<'a, F> {
zk,
query_instance,
num_proof,
degree,
num_fixed: cs.num_fixed_columns(),
num_permutation_fixed: cs.permutation().get_columns().len(),
num_instance,
Expand Down Expand Up @@ -733,6 +735,7 @@ impl<'a, F: FieldExt> Polynomials<'a, F> {
.collect_vec();
let numerator = Expression::DistributePowers(constraints, self.alpha().into());
QuotientPolynomial {
num_chunk: self.degree - 1,
chunk_degree: 1,
numerator,
}
Expand Down
9 changes: 4 additions & 5 deletions snark-verifier/src/verifier/plonk/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::{
Itertools,
},
};
use num_integer::Integer;
use num_traits::One;
use std::{
cmp::max,
Expand Down Expand Up @@ -264,15 +263,15 @@ where
#[derive(Clone, Debug)]
pub struct QuotientPolynomial<F: Clone> {
pub chunk_degree: usize,
// Note that `num_chunk` might be larger than necessary, due to the degree
// calculation of the constraint system (e.g. halo2 has minimum degree 3).
pub num_chunk: usize,
pub numerator: Expression<F>,
}

impl<F: Clone> QuotientPolynomial<F> {
pub fn num_chunk(&self) -> usize {
Integer::div_ceil(
&(self.numerator.degree().checked_sub(1).unwrap_or_default()),
&self.chunk_degree,
)
self.num_chunk
}
}

Expand Down

0 comments on commit 54452c7

Please sign in to comment.