Skip to content

Commit

Permalink
chore: fix post merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-Kindi-0 committed Sep 3, 2024
1 parent 8617308 commit ed781d8
Show file tree
Hide file tree
Showing 26 changed files with 269 additions and 1,026 deletions.
215 changes: 0 additions & 215 deletions air/src/air/logup_gkr.rs

This file was deleted.

87 changes: 87 additions & 0 deletions air/src/air/logup_gkr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,27 @@ pub trait LogUpGkrEvaluator: Clone + Sync {
) -> SColumnConstraint<E> {
SColumnConstraint::new(gkr_data, composition_coefficient)
}

/// Returns the periodic values used in the LogUp-GKR statement, either as base field element
/// during circuit evaluation or as extension field element during the run of sum-check for
/// the input layer.
fn build_periodic_values<F, E>(&self) -> PeriodicTable<F>
where
F: FieldElement<BaseField = Self::BaseField>,
E: FieldElement<BaseField = Self::BaseField> + ExtensionOf<F>,
{
let mut table = Vec::new();

let oracles = self.get_oracles();

for oracle in oracles {
if let LogUpGkrOracle::PeriodicValue(values) = oracle {
let values = embed_in_extension(values.to_vec());
table.push(values)
}
}
PeriodicTable { table }
}
}

#[derive(Clone, Default)]
Expand Down Expand Up @@ -229,3 +250,69 @@ pub enum LogUpGkrOracle<B: StarkField> {
/// must be a power of 2.
PeriodicValue(Vec<B>),
}

// PERIODIC COLUMNS FOR LOGUP
// =================================================================================================

#[derive(Clone, Debug, Default, PartialEq, PartialOrd, Eq, Ord)]
pub struct PeriodicTable<E: FieldElement> {
pub table: Vec<Vec<E>>,
}

impl<E> PeriodicTable<E>
where
E: FieldElement,
{
pub fn new<B>(table: Vec<Vec<B>>) -> Self
where
E: FieldElement + ExtensionOf<B>,
B: StarkField,
{
let mut result = vec![];
for col in table.iter() {
let mut res = vec![];
for v in col {
res.push(E::from(*v))
}
result.push(res)
}

Self { table: result }
}

pub fn num_columns(&self) -> usize {
self.table.len()
}

pub fn table(&self) -> &[Vec<E>] {
&self.table
}

pub fn get_periodic_values_at(&self, row: usize) -> Vec<E> {
self.table.iter().map(|col| col[row % col.len()]).collect()
}

pub fn bind_least_significant_variable(&mut self, round_challenge: E) {
for col in self.table.iter_mut() {
if col.len() > 1 {
let num_evals = col.len() >> 1;
for i in 0..num_evals {
col[i] = col[i << 1] + round_challenge * (col[(i << 1) + 1] - col[i << 1]);
}
col.truncate(num_evals)
}
}
}
}

// HELPER
// =================================================================================================

fn embed_in_extension<E: FieldElement>(values: Vec<E::BaseField>) -> Vec<E> {
let mut res = vec![];
for v in values {
res.push(E::from(v))
}

res
}
5 changes: 1 addition & 4 deletions air/src/air/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ use logup_gkr::PhantomLogUpGkrEval;
pub use logup_gkr::{
LagrangeKernelBoundaryConstraint, LagrangeKernelConstraints, LagrangeKernelEvaluationFrame,
LagrangeKernelRandElements, LagrangeKernelTransitionConstraints, LogUpGkrEvaluator,
LogUpGkrOracle,
LogUpGkrOracle, PeriodicTable,
};

mod logup_gkr;
pub use logup_gkr::{LogUpGkrEvaluator, LogUpGkrOracle, PeriodicTable};

mod coefficients;
pub use coefficients::{
ConstraintCompositionCoefficients, DeepCompositionCoefficients,
Expand Down
6 changes: 3 additions & 3 deletions air/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ mod air;
pub use air::{
Air, AirContext, Assertion, AuxRandElements, BoundaryConstraint, BoundaryConstraintGroup,
BoundaryConstraints, ConstraintCompositionCoefficients, ConstraintDivisor,
DeepCompositionCoefficients, EvaluationFrame, GkrData, PeriodicTable,
DeepCompositionCoefficients, EvaluationFrame, GkrData,
LagrangeConstraintsCompositionCoefficients, LagrangeKernelBoundaryConstraint,
LagrangeKernelConstraints, LagrangeKernelEvaluationFrame, LagrangeKernelRandElements,
LagrangeKernelTransitionConstraints, LogUpGkrEvaluator, LogUpGkrOracle, TraceInfo,
TransitionConstraintDegree, TransitionConstraints,
LagrangeKernelTransitionConstraints, LogUpGkrEvaluator, LogUpGkrOracle, PeriodicTable,
TraceInfo, TransitionConstraintDegree, TransitionConstraints,
};
54 changes: 0 additions & 54 deletions examples/src/fibonacci/fib2/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,57 +67,3 @@ impl Air for FibAir {
]
}
}

#[derive(Clone, Default)]
pub struct PlainLogUpGkrEval<B: FieldElement> {
_field: std::marker::PhantomData<B>,
}

impl air::LogUpGkrEvaluator for PlainLogUpGkrEval<BaseElement> {
type BaseField = BaseElement;

type PublicInputs = BaseElement;

fn get_oracles(&self) -> Vec<air::LogUpGkrOracle<Self::BaseField>> {
unimplemented!()
}

fn get_num_rand_values(&self) -> usize {
unimplemented!()
}

fn get_num_fractions(&self) -> usize {
unimplemented!()
}

fn max_degree(&self) -> usize {
unimplemented!()
}

fn build_query<E>(&self, _frame: &EvaluationFrame<E>, _periodic_values: &[E]) -> Vec<E>
where
E: FieldElement<BaseField = Self::BaseField>,
{
unimplemented!()
}

fn evaluate_query<F, E>(
&self,
_query: &[F],
_rand_values: &[E],
_numerator: &mut [E],
_denominator: &mut [E],
) where
F: FieldElement<BaseField = Self::BaseField>,
E: FieldElement<BaseField = Self::BaseField> + winterfell::math::ExtensionOf<F>,
{
unimplemented!()
}

fn compute_claim<E>(&self, _inputs: &Self::PublicInputs, _rand_values: &[E]) -> E
where
E: FieldElement<BaseField = Self::BaseField>,
{
unimplemented!()
}
}
Loading

0 comments on commit ed781d8

Please sign in to comment.