Skip to content

Commit 62b6349

Browse files
noel2004lispc
andauthored
feat: poseidon circuit and poseidon bytecode circuit (scroll-tech#291)
* mpt_circuit: trival update (vk not compatible) update mpt-circuit Squashed commit of the following: commit f114ba575f10961cda1fa3b89d93d028305f3357 Author: Ho Vei <[email protected]> Date: Tue Jan 31 23:34:07 2023 +0800 fix issues, make circuit work commit 06412deafa68435c8c5d968add13d4aaf84549ca Author: Ho Vei <[email protected]> Date: Tue Jan 31 17:29:37 2023 +0800 include poseidon codehash extension commit 00d705b7cea50d2f4adcf9ce26e8aab0f444765a Author: Ho Vei <[email protected]> Date: Tue Jan 31 10:17:02 2023 +0800 add hash block unrolling entry commit f7bd7b298b1d775ede53f118f8d532e83ffcc329 Author: Ho Vei <[email protected]> Date: Tue Jan 31 00:28:58 2023 +0800 bytecode_hash_block extend refactor to fit the upstream for poseidon codehash feat * fmt induce poseidon circuit trivial fix issue in feature poseidon-codehash open an required method in supercircuit * update mpt circuit dep and trivial fixings * lint --------- Co-authored-by: Zhang Zhuo <[email protected]>
1 parent 4dd7b83 commit 62b6349

File tree

17 files changed

+1160
-215
lines changed

17 files changed

+1160
-215
lines changed

Cargo.lock

Lines changed: 5 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ members = [
1313
"mock",
1414
]
1515

16-
[patch.crates-io]
17-
# temporary solution to [email protected] being yanked, tracking issue: https://github.com/ferrilab/funty/issues/7
18-
funty = { git = "https://github.com/ferrilab/funty/", rev = "7ef0d890fbcd8b3def1635ac1a877fc298488446" }
19-
2016
[patch."https://github.com/privacy-scaling-explorations/halo2.git"]
2117
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "scroll-dev-0220" }
2218

eth-types/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ num = "0.4"
2424
num-bigint = { version = "0.4" }
2525
strum_macros = "0.24"
2626
strum = "0.24"
27-
mpt-circuits = { package = "halo2-mpt-circuits", git = "https://github.com/scroll-tech/mpt-circuit.git", branch = "scroll-dev-0111-halo2-upgrade" }
27+
mpt-circuits = { package = "halo2-mpt-circuits", git = "https://github.com/scroll-tech/mpt-circuit.git", branch = "scroll-dev-0129" }
2828
[features]
2929
default = ["warn-unimplemented"]
3030
warn-unimplemented = []

zkevm-circuits/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ zktrie = []
6161
enable-sign-verify = []
6262
codehash = []
6363
reject-eip2718 = []
64+
poseidon-codehash = []

zkevm-circuits/src/bytecode_circuit/bytecode_unroller.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,15 @@ pub fn unroll_with_codehash<F: Field>(code_hash: U256, bytes: Vec<u8>) -> Unroll
5858
}
5959
UnrolledBytecode { bytes, rows }
6060
}
61+
62+
/// re-export bytes wrapped in hash field
63+
pub use super::circuit::to_poseidon_hash::HASHBLOCK_BYTES_IN_FIELD;
64+
use crate::table::PoseidonTable;
65+
66+
/// Apply default constants in mod
67+
pub fn unroll_to_hash_input_default<F: Field>(
68+
code: impl ExactSizeIterator<Item = u8>,
69+
) -> Vec<[F; PoseidonTable::INPUT_WIDTH]> {
70+
use super::circuit::to_poseidon_hash::unroll_to_hash_input;
71+
unroll_to_hash_input::<F, HASHBLOCK_BYTES_IN_FIELD, { PoseidonTable::INPUT_WIDTH }>(code)
72+
}

zkevm-circuits/src/bytecode_circuit/circuit.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ use super::{
1919
param::PUSH_TABLE_WIDTH,
2020
};
2121

22+
/// An extended circuit for binding with poseidon
23+
pub mod to_poseidon_hash;
24+
2225
#[cfg(feature = "onephase")]
2326
use halo2_proofs::plonk::FirstPhase as SecondPhase;
2427
#[cfg(not(feature = "onephase"))]
@@ -755,6 +758,12 @@ impl<F: Field> BytecodeCircuit<F> {
755758
}
756759

757760
impl<F: Field> SubCircuit<F> for BytecodeCircuit<F> {
761+
#[cfg(feature = "poseidon-codehash")]
762+
type Config = to_poseidon_hash::ToHashBlockCircuitConfig<
763+
F,
764+
{ to_poseidon_hash::HASHBLOCK_BYTES_IN_FIELD },
765+
>;
766+
#[cfg(not(feature = "poseidon-codehash"))]
758767
type Config = BytecodeCircuitConfig<F>;
759768

760769
fn new_from_block(block: &witness::Block<F>) -> Self {

0 commit comments

Comments
 (0)