Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interaction_element_ids to Component trait. #631

Merged
merged 1 commit into from
May 27, 2024
Merged
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
15 changes: 13 additions & 2 deletions crates/prover/src/core/air/air_ext.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
use std::collections::BTreeSet;
use std::iter::zip;

use itertools::Itertools;
use itertools::{zip_eq, Itertools};

use super::accumulation::{DomainEvaluationAccumulator, PointEvaluationAccumulator};
use super::{Air, AirProver, ComponentTrace};
use crate::core::backend::Backend;
use crate::core::channel::{Blake2sChannel, Channel};
use crate::core::circle::CirclePoint;
use crate::core::fields::m31::BaseField;
use crate::core::fields::qm31::SecureField;
use crate::core::poly::circle::{CanonicCoset, CircleEvaluation, CirclePoly, SecureCirclePoly};
use crate::core::poly::BitReversedOrder;
use crate::core::prover::LOG_BLOWUP_FACTOR;
use crate::core::ComponentVec;
use crate::core::{ComponentVec, InteractionElements};

pub trait AirExt: Air {
fn composition_log_degree_bound(&self) -> u32 {
Expand Down Expand Up @@ -41,6 +43,15 @@ pub trait AirExt: Air {
component_points
}

fn interaction_elements(&self, channel: &mut Blake2sChannel) -> InteractionElements {
let mut ids = BTreeSet::new();
for component in self.components() {
ids.extend(component.interaction_element_ids());
}
let elements = channel.draw_felts(ids.len()).into_iter().map(|e| e.0 .0);
InteractionElements(zip_eq(ids, elements).collect_vec())
}

fn eval_composition_polynomial_at_point(
&self,
point: CirclePoint<SecureField>,
Expand Down
3 changes: 3 additions & 0 deletions crates/prover/src/core/air/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ pub trait Component {
point: CirclePoint<SecureField>,
) -> ColumnVec<Vec<CirclePoint<SecureField>>>;

/// Returns the ids of the interaction elements used by the component.
fn interaction_element_ids(&self) -> Vec<String>;

/// Evaluates the constraint quotients combination of the component, given the mask values.
fn evaluate_constraint_quotients_at_point(
&self,
Expand Down
4 changes: 4 additions & 0 deletions crates/prover/src/core/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::ops::{Deref, DerefMut};

use self::fields::m31::BaseField;

pub mod air;
pub mod backend;
pub mod channel;
Expand Down Expand Up @@ -57,3 +59,5 @@ impl<T> DerefMut for ComponentVec<T> {
&mut self.0
}
}

pub struct InteractionElements(Vec<(String, BaseField)>);
4 changes: 4 additions & 0 deletions crates/prover/src/core/prover/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ mod tests {
vec![vec![point]]
}

fn interaction_element_ids(&self) -> Vec<String> {
vec![]
}

fn evaluate_constraint_quotients_at_point(
&self,
_point: CirclePoint<SecureField>,
Expand Down
4 changes: 4 additions & 0 deletions crates/prover/src/examples/fibonacci/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ impl Component for FibonacciComponent {
)
}

fn interaction_element_ids(&self) -> Vec<String> {
vec![]
}

fn evaluate_constraint_quotients_at_point(
&self,
point: CirclePoint<SecureField>,
Expand Down
7 changes: 7 additions & 0 deletions crates/prover/src/examples/wide_fibonacci/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ impl Component for WideFibComponent {
fixed_mask_points(&vec![vec![0_usize]; self.n_columns()], point)
}

fn interaction_element_ids(&self) -> Vec<String> {
vec![
"wide_fibonacci_alpha".to_string(),
"wide_fibonacci_z".to_string(),
]
}

fn evaluate_constraint_quotients_at_point(
&self,
point: CirclePoint<SecureField>,
Expand Down
Loading