Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stick to num_chunk of quotient poly calculated by constraint system #29

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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