Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions air/src/air.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use alloc::vec;
use alloc::vec::Vec;
use core::ops::{Add, Mul, Sub};

use p3_field::{Algebra, ExtensionField, Field, PrimeCharacteristicRing};
Expand All @@ -8,10 +10,22 @@ use p3_matrix::dense::RowMajorMatrix;
pub trait BaseAir<F>: Sync {
/// The number of columns (a.k.a. registers) in this AIR.
fn width(&self) -> usize;

/// Return an optional preprocessed trace matrix to be included in the prover's trace.
fn preprocessed_trace(&self) -> Option<RowMajorMatrix<F>> {
None
}

/// Return the periodic table data.
///
/// Periodic columns are columns whose values repeat with a period that divides the trace
/// length. Each inner `Vec<F>` represents one periodic column. The length of the inner
/// vector is the period of that column (must be a power of 2 that divides the trace length).
///
/// By default returns an empty table (no periodic columns).
fn periodic_table(&self) -> Vec<Vec<F>> {
vec![]
}
}

/// An extension of `BaseAir` that includes support for public values.
Expand Down Expand Up @@ -232,6 +246,20 @@ pub trait PermutationAirBuilder: ExtensionBuilder {
fn permutation_randomness(&self) -> &[Self::RandomVar];
}

/// Trait for builders supporting periodic columns.
///
/// Periodic columns are columns whose values repeat with a period dividing the trace length.
/// They are never committed to the proof - instead, both prover and verifier compute them
/// from the periodic table data provided by the AIR.
pub trait PeriodicAirBuilder: AirBuilder {
/// Variable type for periodic column values.
/// For the prover, this is base field; for the verifier, this is extension field.
type PeriodicVar: Into<Self::Expr> + Copy;

/// Return the evaluations of periodic columns at the current row.
fn periodic_values(&self) -> &[Self::PeriodicVar];
}

/// A wrapper around an [`AirBuilder`] that enforces constraints only when a specified condition is met.
///
/// This struct allows selectively applying constraints to certain rows or under certain conditions in the AIR,
Expand Down Expand Up @@ -287,6 +315,14 @@ impl<AB: PairBuilder> PairBuilder for FilteredAirBuilder<'_, AB> {
}
}

impl<AB: AirBuilderWithPublicValues> AirBuilderWithPublicValues for FilteredAirBuilder<'_, AB> {
type PublicVar = AB::PublicVar;

fn public_values(&self) -> &[Self::PublicVar] {
self.inner.public_values()
}
}

impl<AB: ExtensionBuilder> ExtensionBuilder for FilteredAirBuilder<'_, AB> {
type EF = AB::EF;
type ExprEF = AB::ExprEF;
Expand Down Expand Up @@ -316,3 +352,11 @@ impl<AB: PermutationAirBuilder> PermutationAirBuilder for FilteredAirBuilder<'_,
self.inner.permutation_randomness()
}
}

impl<AB: PeriodicAirBuilder> PeriodicAirBuilder for FilteredAirBuilder<'_, AB> {
type PeriodicVar = AB::PeriodicVar;

fn periodic_values(&self) -> &[Self::PeriodicVar] {
self.inner.periodic_values()
}
}
1 change: 1 addition & 0 deletions batch-stark/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ where
decomposed_alpha_powers: &decomposed_alpha_powers,
accumulator,
constraint_index: 0,
periodic_values: vec![], // batch-stark doesn't support periodic columns yet
};
let packed_perm_challenges = permutation_challenges
.iter()
Expand Down
1 change: 1 addition & 0 deletions batch-stark/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ where
is_transition: sels.is_transition,
alpha: *alpha,
accumulator: SC::Challenge::ZERO,
periodic_values: vec![], // batch-stark doesn't support periodic columns yet
};
let mut folder = VerifierConstraintFolderWithLookups {
inner: inner_folder,
Expand Down
1 change: 1 addition & 0 deletions circle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ keywords.workspace = true
categories.workspace = true

[dependencies]
p3-air.workspace = true
p3-challenger.workspace = true
p3-commit.workspace = true
p3-dft.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions circle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod domain;
mod folding;
mod ordering;
mod pcs;
mod periodic;
mod point;
mod proof;
mod prover;
Expand All @@ -20,4 +21,5 @@ pub use cfft::*;
pub use domain::*;
pub use ordering::*;
pub use pcs::*;
pub use periodic::*;
pub use proof::*;
Loading
Loading