Skip to content

Commit

Permalink
add ctl lookup traits
Browse files Browse the repository at this point in the history
  • Loading branch information
bytetang committed Jul 23, 2024
1 parent 400e1d2 commit 9ca8fdc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions starky/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,5 +355,6 @@ pub mod verifier;
pub mod fibonacci_stark;
#[cfg(test)]
pub mod permutation_stark;

#[cfg(test)]
pub mod unconstrained_stark;
4 changes: 3 additions & 1 deletion starky/src/lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ impl<F: Field> Column<F> {
} else {
vs.extend(v);
}
assert_eq!(vs.len(), self.linear_combination.len());
// assert_eq!(vs.len(), self.linear_combination.len());
let pairs = self
.linear_combination
.iter()
Expand Down Expand Up @@ -878,6 +878,8 @@ pub(crate) fn eval_packed_lookups_generic<F, FE, P, S, const D: usize, const D2:
let p2_local_values = p2_vars.is_some().then(|| p2_vars.unwrap().get_local_values());
let p2_next_values = p2_local_values.is_some().then(||p2_vars.unwrap().get_next_values());

println!("local_values: {:?}, p2_local_values: {:?}", local_values, p2_local_values);

let degree = stark.constraint_degree();
let mut start = 0;
for lookup in lookups {
Expand Down
8 changes: 5 additions & 3 deletions starky/src/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,12 +724,14 @@ fn check_constraints<'a, F, C, S, const D: usize>(

// Assert that all constraints evaluate to 0 over our subgroup.
for (row, v) in constraint_values.iter().enumerate() {
for x in v.iter() {
println!("constraits {}", v.iter().len());
for (c, x) in v.iter().enumerate() {
assert!(
x.is_zero(),
"Constraint failed in {} at row {}",
"Constraint failed in {} at row {}, position {}",
type_name::<S>(),
row
row,
c,
)
}
}
Expand Down
13 changes: 12 additions & 1 deletion starky/src/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use plonky2::plonk::circuit_builder::CircuitBuilder;
use crate::config::StarkConfig;
use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer};
use crate::evaluation_frame::{StarkEvaluationFrame};
use crate::lookup::Lookup;
use crate::lookup::{Column, Filter, Lookup};


/// Represents a STARK system.
Expand Down Expand Up @@ -269,6 +269,17 @@ pub trait Stark<F: RichField + Extendable<D>, const D: usize>: Sync {
vec![]
}

/// Outputs all Cross LookUp Columns this table needs to perform
fn ctl_columns(&self) -> Vec<Column<F>> {
vec![]
}

/// CTL filter for the final block rows of the table.
fn clt_filter(&self) -> Filter<F> {
Filter::default()
}


/// Outputs the number of total lookup helper columns, based on this STARK's vector
/// of [`Lookup`] and the number of challenges used by this [`StarkConfig`].
fn num_lookup_helper_columns(&self, config: &StarkConfig) -> usize {
Expand Down

0 comments on commit 9ca8fdc

Please sign in to comment.