Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] make KeccakComponentShardCircuit inputs into RefCell #231

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions hashes/zkevm/src/keccak/component/circuit/shard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ use snark_verifier_sdk::CircuitExt;
pub struct KeccakComponentShardCircuit<F: Field> {
/// The multiple inputs to be hashed.
#[getset(get = "pub")]
inputs: Vec<Vec<u8>>,
inputs: RefCell<Vec<Vec<u8>>>,

/// Parameters of this circuit. The same parameters always construct the same circuit.
#[getset(get_mut = "pub")]
params: KeccakComponentShardCircuitParams,
#[getset(get = "pub")]
base_circuit_builder: RefCell<BaseCircuitBuilder<F>>,
/// Poseidon hasher. Stateless once initialized.
#[getset(get = "pub")]
Expand Down Expand Up @@ -168,7 +169,7 @@ impl<F: Field> Circuit<F> for KeccakComponentShardCircuit<F> {
|| "keccak circuit",
|mut region| {
let (keccak_rows, _) = multi_keccak::<F>(
&self.inputs,
&self.inputs.borrow(),
Some(self.params.capacity),
self.params.keccak_circuit_params,
);
Expand Down Expand Up @@ -235,7 +236,7 @@ impl<F: Field> KeccakComponentShardCircuit<F> {
let mut base_circuit_builder = BaseCircuitBuilder::new(witness_gen_only);
base_circuit_builder.set_params(params.base_circuit_params.clone());
Self {
inputs,
inputs: RefCell::new(inputs),
params,
base_circuit_builder: RefCell::new(base_circuit_builder),
hasher: RefCell::new(create_hasher()),
Expand Down Expand Up @@ -525,7 +526,8 @@ pub fn transmute_keccak_assigned_to_virtual<F: Field>(

impl<F: Field> CircuitExt<F> for KeccakComponentShardCircuit<F> {
fn instances(&self) -> Vec<Vec<F>> {
let circuit_outputs = multi_inputs_to_circuit_outputs(&self.inputs, self.params.capacity);
let circuit_outputs =
multi_inputs_to_circuit_outputs(&self.inputs.borrow(), self.params.capacity);
if self.params.publish_raw_outputs {
vec![
circuit_outputs.iter().map(|o| o.key).collect(),
Expand Down
Loading