Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ incremental = false
[profile.flamegraph]
inherits = "release"
debug = true

[patch."https://github.com/axiom-crypto/halo2-lib.git"]
halo2-base = { path = "../halo2-lib/halo2-base" }
halo2-ecc = { path = "../halo2-lib/halo2-ecc" }
9 changes: 5 additions & 4 deletions hashes/zkevm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ halo2-base = { path = "../../halo2-base", default-features = false, features = [
] }
rayon = "1.7"
sha3 = "0.10.8"
pse-poseidon = { git = "https://github.com/axiom-crypto/pse-poseidon.git" }
# always included but without features to use Native poseidon
snark-verifier = { git = "https://github.com/axiom-crypto/snark-verifier.git", branch = "develop", default-features = false }
getset = "0.1.2"

[dev-dependencies]
Expand All @@ -34,9 +35,9 @@ test-case = "3.1.0"

[features]
default = ["halo2-axiom", "display"]
display = ["halo2-base/display"]
halo2-pse = ["halo2-base/halo2-pse"]
halo2-axiom = ["halo2-base/halo2-axiom"]
display = ["halo2-base/display", "snark-verifier/display"]
halo2-pse = ["halo2-base/halo2-pse", "snark-verifier/halo2-pse"]
halo2-axiom = ["halo2-base/halo2-axiom", "snark-verifier/halo2-axiom"]
jemallocator = ["halo2-base/jemallocator"]
mimalloc = ["halo2-base/mimalloc"]
asm = ["halo2-base/asm"]
7 changes: 6 additions & 1 deletion hashes/zkevm/src/keccak/coprocessor/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use halo2_base::{
};
use itertools::Itertools;
use num_bigint::BigUint;
use snark_verifier::loader::native::NativeLoader;

use crate::{
keccak::vanilla::{keccak_packed_multi::get_num_keccak_f, param::*},
Expand Down Expand Up @@ -69,7 +70,11 @@ pub fn encode_native_input<F: Field>(bytes: &[u8]) -> F {
.collect_vec();
// Absorb witnesses keccak_f by keccak_f.
let mut native_poseidon_sponge =
pse_poseidon::Poseidon::<F, POSEIDON_T, POSEIDON_RATE>::new(POSEIDON_R_F, POSEIDON_R_P);
snark_verifier::util::hash::Poseidon::<F, F, POSEIDON_T, POSEIDON_RATE>::new::<
POSEIDON_R_F,
POSEIDON_R_P,
POSEIDON_SECURE_MDS,
>(&NativeLoader);
for witnesses in witnesses_per_keccak_f {
for absorbing in witnesses.chunks(POSEIDON_RATE) {
// To avoid absorbing witnesses crossing keccak_fs together, pad 0s to make sure absorb.len() == RATE.
Expand Down
7 changes: 6 additions & 1 deletion hashes/zkevm/src/keccak/coprocessor/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use super::{encode::encode_native_input, param::*};
use crate::{keccak::vanilla::keccak_packed_multi::get_num_keccak_f, util::eth_types::Field};
use itertools::Itertools;
use sha3::{Digest, Keccak256};
use snark_verifier::loader::native::NativeLoader;

/// Witnesses to be exposed as circuit outputs.
#[derive(Clone, Copy, PartialEq, Debug)]
Expand Down Expand Up @@ -61,7 +62,11 @@ pub fn dummy_circuit_output<F: Field>() -> KeccakCircuitOutput<F> {
/// Calculate the commitment of circuit outputs.
pub fn calculate_circuit_outputs_commit<F: Field>(outputs: &[KeccakCircuitOutput<F>]) -> F {
let mut native_poseidon_sponge =
pse_poseidon::Poseidon::<F, POSEIDON_T, POSEIDON_RATE>::new(POSEIDON_R_F, POSEIDON_R_P);
snark_verifier::util::hash::Poseidon::<F, F, POSEIDON_T, POSEIDON_RATE>::new::<
POSEIDON_R_F,
POSEIDON_R_P,
POSEIDON_SECURE_MDS,
>(&NativeLoader);
native_poseidon_sponge.update(
&outputs
.iter()
Expand Down