Skip to content

Commit

Permalink
max_constraint_log_degree_bound in Air trait.
Browse files Browse the repository at this point in the history
  • Loading branch information
alonh5 committed Feb 21, 2024
1 parent 0434d45 commit 2c715a7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/core/air/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ pub mod evaluation;
// TODO(spapini): consider renaming this struct.
pub trait Air {
fn visit_components<V: ComponentVisitor>(&self, v: &mut V);

fn max_constraint_log_degree_bound(&self) -> u32;
}

pub trait ComponentVisitor {
Expand Down
6 changes: 5 additions & 1 deletion src/fibonacci/air.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::component::FibonacciComponent;
use crate::core::air::{Air, ComponentVisitor};
use crate::core::air::{Air, Component, ComponentVisitor};

pub struct FibonacciAir {
pub component: FibonacciComponent,
Expand All @@ -15,4 +15,8 @@ impl Air for FibonacciAir {
fn visit_components<V: ComponentVisitor>(&self, v: &mut V) {
v.visit(&self.component);
}

fn max_constraint_log_degree_bound(&self) -> u32 {
self.component.max_constraint_log_degree_bound()
}
}
18 changes: 8 additions & 10 deletions src/fibonacci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Fibonacci {
let component_traces = vec![component_trace];
let evaluator = ConstraintEvaluator::new(
&component_traces,
self.air.component.max_constraint_log_degree_bound(),
self.air.max_constraint_log_degree_bound(),
random_coeff,
);
let composition_polynomial_poly = self.compute_composition_polynomial(evaluator);
Expand Down Expand Up @@ -223,10 +223,8 @@ pub fn verify_proof<const N_BITS: u32>(proof: FibonacciProof) -> bool {
.mask()
.to_points(vec![trace_domain], oods_point);

let mut evaluation_accumulator = PointEvaluationAccumulator::new(
random_coeff,
fib.air.component.max_constraint_log_degree_bound(),
);
let mut evaluation_accumulator =
PointEvaluationAccumulator::new(random_coeff, fib.air.max_constraint_log_degree_bound());
fib.air.component.evaluate_quotients_by_mask(
oods_point,
&proof.trace_oods_values[0],
Expand All @@ -236,7 +234,7 @@ pub fn verify_proof<const N_BITS: u32>(proof: FibonacciProof) -> bool {

// TODO(AlonH): Get bounds from air.
let mut bounds = vec![CirclePolyDegreeBound::new(
fib.air.component.max_constraint_log_degree_bound(),
fib.air.max_constraint_log_degree_bound(),
)];
bounds.append(&mut quotient_log_bounds(fib.air.component));
let fri_config = FriConfig::new(LOG_LAST_LAYER_DEGREE_BOUND, LOG_BLOWUP_FACTOR, N_QUERIES);
Expand Down Expand Up @@ -313,7 +311,7 @@ mod tests {
use super::Fibonacci;
use crate::commitment_scheme::utils::tests::generate_test_queries;
use crate::core::air::evaluation::{ConstraintEvaluator, PointEvaluationAccumulator};
use crate::core::air::{Component, ComponentTrace};
use crate::core::air::{Air, Component, ComponentTrace};
use crate::core::circle::CirclePoint;
use crate::core::fields::m31::{BaseField, M31};
use crate::core::fields::qm31::SecureField;
Expand All @@ -336,7 +334,7 @@ mod tests {
let component_traces = [trace];
let evaluator = ConstraintEvaluator::new(
&component_traces,
fib.air.component.max_constraint_log_degree_bound(),
fib.air.max_constraint_log_degree_bound(),
random_coeff,
);
let composition_polynomial_poly = fib.compute_composition_polynomial(evaluator);
Expand All @@ -351,7 +349,7 @@ mod tests {
.mask_points_and_values(point, &component_traces[0]);
let mut evaluation_accumulator = PointEvaluationAccumulator::new(
random_coeff,
fib.air.component.max_constraint_log_degree_bound(),
fib.air.max_constraint_log_degree_bound(),
);
fib.air.component.evaluate_quotients_by_mask(
point,
Expand Down Expand Up @@ -437,7 +435,7 @@ mod tests {
proof
.additional_proof_data
.composition_polynomial_random_coeff,
fib.air.component.max_constraint_log_degree_bound(),
fib.air.max_constraint_log_degree_bound(),
);
fib.air.component.evaluate_quotients_by_mask(
oods_point,
Expand Down

0 comments on commit 2c715a7

Please sign in to comment.