diff --git a/snark-verifier/src/system/halo2.rs b/snark-verifier/src/system/halo2.rs index a271a17c..c3f0e7ef 100644 --- a/snark-verifier/src/system/halo2.rs +++ b/snark-verifier/src/system/halo2.rs @@ -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, @@ -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, @@ -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, } diff --git a/snark-verifier/src/verifier/plonk/protocol.rs b/snark-verifier/src/verifier/plonk/protocol.rs index 94f97201..3cf8e462 100644 --- a/snark-verifier/src/verifier/plonk/protocol.rs +++ b/snark-verifier/src/verifier/plonk/protocol.rs @@ -5,7 +5,6 @@ use crate::{ Itertools, }, }; -use num_integer::Integer; use num_traits::One; use std::{ cmp::max, @@ -264,15 +263,15 @@ where #[derive(Clone, Debug)] pub struct QuotientPolynomial { 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, } impl QuotientPolynomial { pub fn num_chunk(&self) -> usize { - Integer::div_ceil( - &(self.numerator.degree().checked_sub(1).unwrap_or_default()), - &self.chunk_degree, - ) + self.num_chunk } }