use crate::{
folding::{Challenge, DecomposedFoldingEnvironment, FoldingInstance, FoldingWitness},
keccak::{
column::{N_ZKVM_KECCAK_COLS, N_ZKVM_KECCAK_REL_COLS, N_ZKVM_KECCAK_SEL_COLS},
KeccakColumn, Steps,
},
Curve, Fp,
};
use ark_poly::{Evaluations, Radix2EvaluationDomain};
use folding::{
checker::{Checker, ExtendedProvider, Provider},
expressions::FoldingColumnTrait,
FoldingConfig,
};
use kimchi_msm::columns::Column;
use poly_commitment::srs::SRS;
use std::ops::Index;
pub type KeccakFoldingEnvironment = DecomposedFoldingEnvironment<
N_ZKVM_KECCAK_COLS,
N_ZKVM_KECCAK_REL_COLS,
N_ZKVM_KECCAK_SEL_COLS,
KeccakConfig,
(),
>;
pub type KeccakFoldingWitness = FoldingWitness<N_ZKVM_KECCAK_COLS, Fp>;
pub type KeccakFoldingInstance = FoldingInstance<N_ZKVM_KECCAK_COLS, Curve>;
impl Index<KeccakColumn> for KeccakFoldingWitness {
type Output = Evaluations<Fp, Radix2EvaluationDomain<Fp>>;
fn index(&self, index: KeccakColumn) -> &Self::Output {
&self.witness.cols[usize::from(index)]
}
}
impl Index<Steps> for KeccakFoldingWitness {
type Output = Evaluations<Fp, Radix2EvaluationDomain<Fp>>;
fn index(&self, index: Steps) -> &Self::Output {
&self.witness.cols[usize::from(index)]
}
}
impl Index<Column> for KeccakFoldingWitness {
type Output = Evaluations<Fp, Radix2EvaluationDomain<Fp>>;
fn index(&self, index: Column) -> &Self::Output {
match index {
Column::Relation(ix) => &self.witness.cols[ix],
_ => panic!("Undesired column type inside expressions"),
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct KeccakConfig;
impl FoldingColumnTrait for KeccakColumn {
fn is_witness(&self) -> bool {
true
}
}
impl FoldingConfig for KeccakConfig {
type Column = Column;
type Selector = Steps;
type Challenge = Challenge;
type Curve = Curve;
type Srs = SRS<Curve>;
type Instance = KeccakFoldingInstance;
type Witness = KeccakFoldingWitness;
type Structure = ();
type Env = KeccakFoldingEnvironment;
}
impl Checker<KeccakConfig> for ExtendedProvider<KeccakConfig> {}
impl Checker<KeccakConfig> for Provider<KeccakConfig> {}