From fc502add01dc90e8fd6ce83fba23e111fa8b374b Mon Sep 17 00:00:00 2001 From: wborgeaud Date: Fri, 4 Feb 2022 20:24:58 +0100 Subject: [PATCH] Add `quotient_degree_factor` function --- starky/src/prover.rs | 4 ++-- starky/src/stark.rs | 7 ++++++- starky/src/verifier.rs | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/starky/src/prover.rs b/starky/src/prover.rs index 171ea92a..335d5384 100644 --- a/starky/src/prover.rs +++ b/starky/src/prover.rs @@ -82,7 +82,7 @@ where .flat_map(|mut quotient_poly| { quotient_poly.trim(); quotient_poly - .pad(degree * (stark.constraint_degree() - 1)) + .pad(degree * stark.quotient_degree_factor()) .expect("Quotient has failed, the vanishing polynomial is not divisible by `Z_H"); // Split quotient into degree-n chunks. quotient_poly.chunks(degree) @@ -162,7 +162,7 @@ where { let degree = 1 << degree_bits; - let max_degree_bits = log2_ceil(stark.constraint_degree() - 1); + let max_degree_bits = log2_ceil(stark.quotient_degree_factor()); assert!( max_degree_bits <= rate_bits, "Having constraints of degree higher than the rate is not supported yet." diff --git a/starky/src/stark.rs b/starky/src/stark.rs index 8f112939..4b20553e 100644 --- a/starky/src/stark.rs +++ b/starky/src/stark.rs @@ -65,6 +65,11 @@ pub trait Stark, const D: usize>: Sync { /// The maximum constraint degree. fn constraint_degree(&self) -> usize; + /// The maximum constraint degree. + fn quotient_degree_factor(&self) -> usize { + 1.max(self.constraint_degree() - 1) + } + /// Computes the FRI instance used to prove this Stark. // TODO: Permutation polynomials. fn fri_instance( @@ -77,7 +82,7 @@ pub trait Stark, const D: usize>: Sync { let no_blinding_oracle = FriOracleInfo { blinding: false }; let trace_info = FriPolynomialInfo::from_range(0, 0..Self::COLUMNS); let quotient_info = - FriPolynomialInfo::from_range(1, 0..(self.constraint_degree() - 1) * num_challenges); + FriPolynomialInfo::from_range(1, 0..self.quotient_degree_factor() * num_challenges); let zeta_batch = FriBatchInfo { point: zeta, polynomials: [trace_info.clone(), quotient_info].concat(), diff --git a/starky/src/verifier.rs b/starky/src/verifier.rs index b04ec684..bb0634f5 100644 --- a/starky/src/verifier.rs +++ b/starky/src/verifier.rs @@ -98,7 +98,7 @@ where // So to reconstruct `t(zeta)` we can compute `reduce_with_powers(chunk, zeta^n)` for each // `quotient_degree_factor`-sized chunk of the original evaluations. for (i, chunk) in quotient_polys_zeta - .chunks(stark.constraint_degree() - 1) + .chunks(stark.quotient_degree_factor()) .enumerate() { ensure!(vanishing_polys_zeta[i] == z_h_zeta * reduce_with_powers(chunk, zeta_pow_deg));