mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-02-24 15:53:09 +00:00
Fix number of quotient polys
This commit is contained in:
parent
01f065b812
commit
431bde2c72
@ -82,7 +82,7 @@ impl<F: RichField + Extendable<D>, const D: usize> Stark<F, D> for FibonacciStar
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn degree(&self) -> usize {
|
||||
fn constraint_degree(&self) -> usize {
|
||||
2
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ where
|
||||
.flat_map(|mut quotient_poly| {
|
||||
quotient_poly.trim();
|
||||
quotient_poly
|
||||
.pad(degree << rate_bits)
|
||||
.pad(degree * (stark.constraint_degree() - 1))
|
||||
.expect("Quotient has failed, the vanishing polynomial is not divisible by `Z_H");
|
||||
// Split quotient into degree-n chunks.
|
||||
quotient_poly.chunks(degree)
|
||||
@ -123,7 +123,7 @@ where
|
||||
timing,
|
||||
"compute openings proof",
|
||||
PolynomialBatch::prove_openings(
|
||||
&S::fri_instance(zeta, g, rate_bits, config.num_challenges),
|
||||
&stark.fri_instance(zeta, g, rate_bits, config.num_challenges),
|
||||
initial_merkle_trees,
|
||||
&mut challenger,
|
||||
&fri_params,
|
||||
@ -162,7 +162,7 @@ where
|
||||
{
|
||||
let degree = 1 << degree_bits;
|
||||
|
||||
let max_degree_bits = log2_ceil(stark.degree() - 1);
|
||||
let max_degree_bits = log2_ceil(stark.constraint_degree() - 1);
|
||||
assert!(
|
||||
max_degree_bits <= rate_bits,
|
||||
"Having constraints of degree higher than the rate is not supported yet."
|
||||
|
||||
@ -63,11 +63,12 @@ pub trait Stark<F: RichField + Extendable<D>, const D: usize>: Sync {
|
||||
);
|
||||
|
||||
/// The maximum constraint degree.
|
||||
fn degree(&self) -> usize;
|
||||
fn constraint_degree(&self) -> usize;
|
||||
|
||||
/// Computes the FRI instance used to prove this Stark.
|
||||
// TODO: Permutation polynomials.
|
||||
fn fri_instance(
|
||||
&self,
|
||||
zeta: F::Extension,
|
||||
g: F::Extension,
|
||||
rate_bits: usize,
|
||||
@ -75,7 +76,8 @@ pub trait Stark<F: RichField + Extendable<D>, const D: usize>: Sync {
|
||||
) -> FriInstanceInfo<F, D> {
|
||||
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..(1 << rate_bits) * num_challenges);
|
||||
let quotient_info =
|
||||
FriPolynomialInfo::from_range(1, 0..(self.constraint_degree() - 1) * num_challenges);
|
||||
let zeta_batch = FriBatchInfo {
|
||||
point: zeta,
|
||||
polynomials: [trace_info.clone(), quotient_info].concat(),
|
||||
|
||||
@ -22,7 +22,7 @@ where
|
||||
[(); S::COLUMNS]:,
|
||||
[(); S::PUBLIC_INPUTS]:,
|
||||
{
|
||||
let rate_bits = log2_ceil(stark.degree() + 1);
|
||||
let rate_bits = log2_ceil(stark.constraint_degree() + 1);
|
||||
|
||||
let wire_ldes = random_low_degree_matrix::<F>(S::COLUMNS, rate_bits);
|
||||
let size = wire_ldes.len();
|
||||
@ -68,13 +68,13 @@ where
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let constraint_eval_degree = PolynomialValues::new(constraint_evals).degree();
|
||||
let maximum_degree = WITNESS_SIZE * stark.degree() - 1;
|
||||
let maximum_degree = WITNESS_SIZE * stark.constraint_degree() - 1;
|
||||
|
||||
ensure!(
|
||||
constraint_eval_degree <= maximum_degree,
|
||||
"Expected degrees at most {} * {} - 1 = {}, actual {:?}",
|
||||
WITNESS_SIZE,
|
||||
stark.degree(),
|
||||
stark.constraint_degree(),
|
||||
maximum_degree,
|
||||
constraint_eval_degree
|
||||
);
|
||||
|
||||
@ -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(1 << config.fri_config.rate_bits)
|
||||
.chunks(stark.constraint_degree() - 1)
|
||||
.enumerate()
|
||||
{
|
||||
ensure!(vanishing_polys_zeta[i] == z_h_zeta * reduce_with_powers(chunk, zeta_pow_deg));
|
||||
@ -108,7 +108,7 @@ where
|
||||
let merkle_caps = &[proof.trace_cap, proof.quotient_polys_cap];
|
||||
|
||||
verify_fri_proof::<F, C, D>(
|
||||
&S::fri_instance(
|
||||
&stark.fri_instance(
|
||||
challenges.stark_zeta,
|
||||
F::primitive_root_of_unity(degree_bits).into(),
|
||||
config.fri_config.rate_bits,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user