From b67a23ea40283bb41c834a8e91b931010bec793d Mon Sep 17 00:00:00 2001 From: kunxian xia Date: Mon, 22 Apr 2024 21:29:12 +0800 Subject: [PATCH] cherry-pick pse pr#29 to let quotient has same number of chunk as it in prover --- snark-verifier/src/system/halo2.rs | 4 +++- snark-verifier/src/util/protocol.rs | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/snark-verifier/src/system/halo2.rs b/snark-verifier/src/system/halo2.rs index 4555b647..b83d14e2 100644 --- a/snark-verifier/src/system/halo2.rs +++ b/snark-verifier/src/system/halo2.rs @@ -178,6 +178,7 @@ struct Polynomials<'a, F: PrimeField> { cs: &'a ConstraintSystem, zk: bool, query_instance: bool, + degree: usize, num_proof: usize, num_fixed: usize, num_permutation_fixed: usize, @@ -234,6 +235,7 @@ impl<'a, F: PrimeField> Polynomials<'a, F> { cs, zk, query_instance, + degree, num_proof, num_fixed: cs.num_fixed_columns(), num_permutation_fixed: cs.permutation().get_columns().len(), @@ -653,7 +655,7 @@ impl<'a, F: PrimeField> Polynomials<'a, F> { }) .collect_vec(); let numerator = Expression::DistributePowers(constraints, self.alpha().into()); - QuotientPolynomial { chunk_degree: 1, numerator } + QuotientPolynomial { num_chunk: self.degree - 1, chunk_degree: 1, numerator } } fn accumulator_indices( diff --git a/snark-verifier/src/util/protocol.rs b/snark-verifier/src/util/protocol.rs index 31ea253b..f1a880e2 100644 --- a/snark-verifier/src/util/protocol.rs +++ b/snark-verifier/src/util/protocol.rs @@ -146,13 +146,16 @@ where #[derive(Clone, Debug, Serialize, Deserialize)] pub struct QuotientPolynomial { + // Note that `num_chunk` might be larger than necessary, due to the degree of + // constraint system (in the form of 2^k + 1) + pub num_chunk: usize, pub chunk_degree: usize, pub numerator: Expression, } impl QuotientPolynomial { pub fn num_chunk(&self) -> usize { - Integer::div_ceil(&(self.numerator.degree() - 1), &self.chunk_degree) + self.num_chunk } }