Skip to content

Commit

Permalink
chore: fix naming based on privacy-scaling-explorations#650 (privacy-…
Browse files Browse the repository at this point in the history
  • Loading branch information
roynalnaruto authored Nov 14, 2022
1 parent 1c3c9a4 commit 18b4f57
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 51 deletions.
85 changes: 37 additions & 48 deletions zkevm-circuits/src/exp_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use gadgets::{
util::{and, not, Expr},
};
use halo2_proofs::{
circuit::{Layouter, Region, Value},
plonk::{ConstraintSystem, Error, Selector},
circuit::{Layouter, Region, SimpleFloorPlanner, Value},
plonk::{Circuit, ConstraintSystem, Error, Selector},
poly::Rotation,
};

Expand All @@ -24,7 +24,7 @@ pub const ROWS_PER_STEP: usize = 4usize;

/// Layout for the Exponentiation circuit.
#[derive(Clone, Debug)]
pub struct ExpCircuit<F> {
pub struct ExpCircuitConfig<F> {
/// Whether the row is enabled.
pub q_usable: Selector,
/// The Exponentiation circuit's table.
Expand All @@ -35,7 +35,7 @@ pub struct ExpCircuit<F> {
pub parity_check: MulAddConfig<F>,
}

impl<F: Field> ExpCircuit<F> {
impl<F: Field> ExpCircuitConfig<F> {
/// Configure the exponentiation circuit.
pub fn configure(meta: &mut ConstraintSystem<F>, exp_table: ExpTable) -> Self {
let q_usable = meta.complex_selector();
Expand Down Expand Up @@ -378,62 +378,51 @@ impl<F: Field> ExpCircuit<F> {
}
}

#[cfg(any(feature = "test", test))]
/// Dev helpers
pub mod dev {
use super::*;
use eth_types::Field;
use halo2_proofs::{
circuit::{Layouter, SimpleFloorPlanner},
dev::{MockProver, VerifyFailure},
plonk::{Circuit, ConstraintSystem},
};

use crate::evm_circuit::witness::Block;
#[derive(Default)]
struct ExpCircuit<F> {
block: Block<F>,
}

#[derive(Clone)]
struct ExpCircuitTesterConfig<F> {
exp_circuit: ExpCircuit<F>,
impl<F: Field> ExpCircuit<F> {
pub fn new(block: Block<F>) -> Self {
Self { block }
}
}

#[derive(Default)]
struct ExpCircuitTester<F> {
block: Block<F>,
}
impl<F: Field> Circuit<F> for ExpCircuit<F> {
type Config = ExpCircuitConfig<F>;
type FloorPlanner = SimpleFloorPlanner;

impl<F: Field> ExpCircuitTester<F> {
pub fn new(block: Block<F>) -> Self {
Self { block }
}
fn without_witnesses(&self) -> Self {
Self::default()
}

impl<F: Field> Circuit<F> for ExpCircuitTester<F> {
type Config = ExpCircuitTesterConfig<F>;
type FloorPlanner = SimpleFloorPlanner;

fn without_witnesses(&self) -> Self {
Self::default()
}
fn configure(meta: &mut ConstraintSystem<F>) -> Self::Config {
let exp_table = ExpTable::construct(meta);
ExpCircuitConfig::configure(meta, exp_table)
}

fn configure(meta: &mut ConstraintSystem<F>) -> Self::Config {
let exp_table = ExpTable::construct(meta);
let exp_circuit = ExpCircuit::configure(meta, exp_table);
fn synthesize(
&self,
config: Self::Config,
mut layouter: impl Layouter<F>,
) -> Result<(), halo2_proofs::plonk::Error> {
config.assign_block(&mut layouter, &self.block)
}
}

ExpCircuitTesterConfig { exp_circuit }
}
#[cfg(any(feature = "test", test))]
/// Dev helpers
pub mod dev {
use super::*;
use eth_types::Field;
use halo2_proofs::dev::{MockProver, VerifyFailure};

fn synthesize(
&self,
config: Self::Config,
mut layouter: impl Layouter<F>,
) -> Result<(), halo2_proofs::plonk::Error> {
config.exp_circuit.assign_block(&mut layouter, &self.block)
}
}
use crate::evm_circuit::witness::Block;

/// Test exponentiation circuit with the provided block witness
pub fn test_exp_circuit<F: Field>(k: u32, block: Block<F>) -> Result<(), Vec<VerifyFailure>> {
let circuit = ExpCircuitTester::<F>::new(block);
let circuit = ExpCircuit::<F>::new(block);
let prover = MockProver::<F>::run(k, &circuit, vec![]).unwrap();
prover.verify()
}
Expand Down
6 changes: 3 additions & 3 deletions zkevm-circuits/src/super_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use crate::bytecode_circuit::bytecode_unroller::{
};
use crate::copy_circuit::CopyCircuit;
use crate::evm_circuit::{table::FixedTableTag, EvmCircuit};
use crate::exp_circuit::ExpCircuit;
use crate::exp_circuit::ExpCircuitConfig;
use crate::keccak_circuit::keccak_packed_multi::KeccakPackedConfig as KeccakConfig;
use crate::pi_circuit::{PiCircuit, PiCircuitConfig, PublicData};
use crate::state_circuit::StateCircuitConfig;
Expand Down Expand Up @@ -112,7 +112,7 @@ pub struct SuperCircuitConfig<
copy_circuit: CopyCircuit<F>,
keccak_circuit: KeccakConfig<F>,
pi_circuit: PiCircuitConfig<F, MAX_TXS, MAX_CALLDATA>,
exp_circuit: ExpCircuit<F>,
exp_circuit: ExpCircuitConfig<F>,
}

/// The Super Circuit contains all the zkEVM circuits
Expand Down Expand Up @@ -235,7 +235,7 @@ impl<F: Field, const MAX_TXS: usize, const MAX_CALLDATA: usize, const MAX_RWS: u
),
keccak_circuit,
pi_circuit,
exp_circuit: ExpCircuit::configure(meta, exp_table),
exp_circuit: ExpCircuitConfig::configure(meta, exp_table),
}
}

Expand Down

0 comments on commit 18b4f57

Please sign in to comment.