Skip to content

Commit

Permalink
Create ColumnDomainsVisitor.
Browse files Browse the repository at this point in the history
  • Loading branch information
alonh5 committed Feb 22, 2024
1 parent 77bbcff commit 28f8287
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 9 deletions.
42 changes: 39 additions & 3 deletions src/core/air/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use core::slice;
use std::iter::zip;
use std::ops::Deref;

use itertools::Itertools;

use self::evaluation::{
ConstraintEvaluator, DomainEvaluationAccumulator, PointEvaluationAccumulator,
};
Expand Down Expand Up @@ -57,6 +59,12 @@ pub trait AirExt: Air<CPUBackend> {
self.visit_components(&mut visitor);
visitor.finalize()
}

fn column_domains(&self) -> ComponentVec<CanonicCoset> {
let mut visitor = ColumnDomainsVisitor::new();
self.visit_components(&mut visitor);
visitor.finalize()
}
}

impl<A: Air<CPUBackend>> AirExt for A {}
Expand Down Expand Up @@ -122,6 +130,34 @@ impl<'a, B: Backend> ComponentVisitor<B> for MaskEvaluator<'a, B> {
}
}

struct ColumnDomainsVisitor {
domains: ComponentVec<CanonicCoset>,
}

impl ColumnDomainsVisitor {
pub fn new() -> Self {
Self {
domains: Vec::new(),
}
}

pub fn finalize(self) -> ComponentVec<CanonicCoset> {
self.domains
}
}

impl<B: Backend> ComponentVisitor<B> for ColumnDomainsVisitor {
fn visit<C: Component<B>>(&mut self, component: &C) {
self.domains.push(
component
.trace_log_degree_bounds()
.iter()
.map(|&log_size| CanonicCoset::new(log_size))
.collect(),
);
}
}

/// Holds the mask offsets at each column.
/// Holds a vector with an entry for each column. Each entry holds the offsets
/// of the mask at that column.
Expand All @@ -130,7 +166,7 @@ pub struct Mask(pub ColumnVec<Vec<usize>>);
impl Mask {
pub fn to_points(
&self,
domains: Vec<CanonicCoset>,
domains: &[CanonicCoset],
point: CirclePoint<SecureField>,
) -> ColumnVec<Vec<CirclePoint<SecureField>>> {
self.iter()
Expand Down Expand Up @@ -188,8 +224,8 @@ pub trait Component<B: Backend> {
.columns
.iter()
.map(|col| CanonicCoset::new(col.log_size()))
.collect();
let points = self.mask().to_points(domains, point);
.collect_vec();
let points = self.mask().to_points(&domains, point);
let values = zip(&points, &trace.columns)
.map(|(col_points, col)| {
col_points
Expand Down
8 changes: 2 additions & 6 deletions src/fibonacci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,8 @@ pub fn verify_proof<const N_BITS: u32>(proof: FibonacciProof) -> bool {
let composition_polynomial_commitment_scheme =
CommitmentSchemeVerifier::new(proof.composition_polynomial_commitment, channel);
let oods_point = CirclePoint::<SecureField>::get_random_point(channel);
let trace_domain = CanonicCoset::new(fib.air.component.log_size);
let trace_oods_points = fib
.air
.component
.mask()
.to_points(vec![trace_domain], oods_point);
let trace_domain = &fib.air.column_domains()[0];
let trace_oods_points = fib.air.component.mask().to_points(trace_domain, oods_point);

let mut evaluation_accumulator =
PointEvaluationAccumulator::new(random_coeff, fib.air.max_constraint_log_degree_bound());
Expand Down

0 comments on commit 28f8287

Please sign in to comment.