mod aux_register;
mod binding;
mod bus_balance;
mod byte_pair_lut;
mod chunk;
mod deferred_session;
mod deferred_state;
mod ec;
mod ec_add;
mod ec_dag;
mod ec_msm;
mod eval;
mod keccak;
mod keccak_node;
mod keccak_sponge;
mod poseidon2;
mod uint;
mod uint_add;
mod uint_dag;
mod uint_mul;
mod utils;
mod vm_uint;
use std::{vec, vec::Vec};
use miden_core::{Felt, field::QuadFelt, utils::RowMajorMatrix};
use miden_lifted_air::{BaseAir, LiftedAir, MultiAir, ProverStatement, ReductionError, Statement};
use miden_lifted_stark::check_constraints;
use crate::stark_config::test_challenger;
struct LocalAir<A>(Vec<A>);
impl<A> MultiAir<Felt, QuadFelt> for LocalAir<A>
where
A: LiftedAir<Felt, QuadFelt>,
{
type Air = A;
fn airs(&self) -> &[A] {
&self.0
}
fn eval_external(
&self,
_challenges: &[QuadFelt],
_air_inputs: &[Felt],
_aux_inputs: &[Felt],
_aux_values: &[&[QuadFelt]],
_log_trace_heights: &[u8],
) -> Result<Vec<QuadFelt>, ReductionError> {
Ok(Vec::new())
}
}
pub(crate) fn check_local_inputs<A>(air: A, main: &RowMajorMatrix<Felt>, air_inputs: Vec<Felt>)
where
A: LiftedAir<Felt, QuadFelt>,
{
let statement = Statement::new(LocalAir(vec![air]), air_inputs, Vec::new())
.expect("local check statement inputs are valid");
let ps = ProverStatement::new(statement, vec![main.clone()])
.expect("local check trace shape is valid");
check_constraints(&ps, test_challenger());
}
pub(crate) fn check_local<A>(air: A, main: &RowMajorMatrix<Felt>)
where
A: LiftedAir<Felt, QuadFelt>,
{
let n = air.num_public_values();
check_local_inputs(air, main, vec![Felt::ZERO; n]);
}
pub(crate) fn log_quotient_degree<A>(air: &A) -> u8
where
A: LiftedAir<Felt, QuadFelt>,
{
let d = air.constraint_degree().max();
miden_lifted_air::log2_ceil_u8(d.saturating_sub(1).max(1))
}
pub(crate) fn combined_lookup_main<A>(
air: &A,
main: &RowMajorMatrix<Felt>,
) -> Option<RowMajorMatrix<Felt>>
where
A: BaseAir<Felt>,
{
let pre = air.preprocessed_trace()?;
let (pre_w, main_w) = (pre.width, main.width);
let height = main.values.len() / main_w;
let mut values = Vec::with_capacity(height * (pre_w + main_w));
for r in 0..height {
values.extend_from_slice(&pre.values[r * pre_w..(r + 1) * pre_w]);
values.extend_from_slice(&main.values[r * main_w..(r + 1) * main_w]);
}
Some(RowMajorMatrix::new(values, pre_w + main_w))
}