pub use super::KeccakCircuit;
use crate::{
keccak_circuit::{KeccakCircuitConfig, KeccakCircuitConfigArgs},
table::KeccakTable,
util::{Challenges, SubCircuit, SubCircuitConfig},
};
use eth_types::Field;
use halo2_proofs::{
circuit::{Layouter, SimpleFloorPlanner},
plonk::{Circuit, ConstraintSystem, Error},
};
impl<F: Field> Circuit<F> for KeccakCircuit<F> {
type Config = (KeccakCircuitConfig<F>, Challenges);
type FloorPlanner = SimpleFloorPlanner;
type Params = ();
fn without_witnesses(&self) -> Self {
Self::default()
}
fn configure(meta: &mut ConstraintSystem<F>) -> Self::Config {
let keccak_table = KeccakTable::construct(meta);
let challenges = Challenges::construct(meta);
let config = {
let challenges = challenges.exprs(meta);
KeccakCircuitConfig::new(
meta,
KeccakCircuitConfigArgs {
keccak_table,
challenges,
},
)
};
(config, challenges)
}
fn synthesize(
&self,
(config, challenges): Self::Config,
mut layouter: impl Layouter<F>,
) -> Result<(), Error> {
let challenges = challenges.values(&mut layouter);
self.synthesize_sub(&config, &challenges, &mut layouter)
}
}