Skip to content

Commit

Permalink
Use zkevm-sha256 gates for Sha256Wide chip (#33)
Browse files Browse the repository at this point in the history
* WIP

* update version in circuits crate

* fix step circuit

* fix sha wide chip gate

* fix prover

* fix proofgen

* fix instance gen & refactor

* fix prover rpc

* fix some tests

* switch to remote deps

* rename circuit files

* refactor

* rename circuit files back (to merge main)

* post merge fixes

* fixes

* fmt

* wip

* remove redundant

* fix endianness

* remove redundant tests

* cargo fix + fmt

* rename config files

* cargo fix
  • Loading branch information
nulltea authored Nov 29, 2023
1 parent f536a83 commit 222f0b5
Show file tree
Hide file tree
Showing 37 changed files with 365 additions and 2,784 deletions.
21 changes: 11 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ halo2-base = { git = "https://github.com/axiom-crypto/halo2-lib", branch = "comm
"jemallocator"
] }
halo2-ecc = { git = "https://github.com/axiom-crypto/halo2-lib", branch = "community-edition", default-features = false }
halo2curves = { git = "https://github.com/axiom-crypto/halo2curves", version = "0.4.0" }
zkevm-hashes = { git = "https://github.com/axiom-crypto/halo2-lib", branch = "community-edition", default-features = false }

halo2curves = { package = "halo2curves-axiom", version = "0.4.2" }


# verifier SDK
Expand Down Expand Up @@ -73,7 +75,6 @@ ff = "0.12"
sha2 = { version = "0.10.6", features = ["compress"] }
uint = "0.9.1"
ark-std = { version = "0.4.0", features = ["print-trace"] }
poseidon_native = { git = "https://github.com/axiom-crypto/halo2.git", branch = "axiom/dev", package = "poseidon" }

# misc
itertools = "0.11.0"
Expand All @@ -82,34 +83,34 @@ serde_json = "1.0.78"
log = "0.4.14"
hex = "0.4"

[patch."https://github.com/axiom-crypto/halo2curves"]
halo2curves = { git = "https://github.com/timoftime/halo2curves", branch = "support_bls12-381" }
# halo2curves = { path = "../halo2curves" }
[patch.crates-io]
halo2curves = { git = "https://github.com/timoftime/halo2curves", package = "halo2curves-axiom", rev = "f3bb3f5a7d3a8ca806368f185c112283a73a94cb" }
ssz_rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "5f1ec833718efa07bbbff427ab28a1eeaa706164" }


[patch."https://github.com/axiom-crypto/halo2-lib"]
halo2-base = { git = "https://github.com/timoftime/halo2-lib", branch = "feat/bls12-381-hash2curve", default-features = false, features = [
halo2-base = { git = "https://github.com/timoftime/halo2-lib", branch = "feat/zkevm-sha256-builder", default-features = false, features = [
"halo2-pse",
"display",
"jemallocator"
] }
halo2-ecc = { git = "https://github.com/timoftime/halo2-lib", branch = "feat/bls12-381-hash2curve", default-features = false, features = [
halo2-ecc = { git = "https://github.com/timoftime/halo2-lib", branch = "feat/zkevm-sha256-builder", default-features = false, features = [
"halo2-pse",
"jemallocator"
] }
zkevm-hashes = { git = "https://github.com/timoftime/halo2-lib", branch = "feat/zkevm-sha256-builder", default-features = false }
# halo2-base = { path = "../halo2-lib/halo2-base", default-features = false, features = [
# "halo2-pse",
# "display",
# ] }
# halo2-ecc = { path = "../halo2-lib/halo2-ecc", default-features = false, features = [
# "halo2-pse",
# ] }
# zkevm-hashes = { path = "../halo2-lib/hashes/zkevm", default-features = false }


[patch."https://github.com/axiom-crypto/snark-verifier.git"]
snark-verifier = { git = "https://github.com/timoftime/snark-verifier", branch = "halo2-pse-fix", default-features = false }
snark-verifier-sdk = { git = "https://github.com/timoftime/snark-verifier", branch = "halo2-pse-fix", default-features = false }
# snark-verifier = { path = "../snark-verifier/snark-verifier" }
# snark-verifier-sdk = { path = "../snark-verifier/snark-verifier-sdk" }

[patch.crates-io]
ssz_rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "5f1ec833718efa07bbbff427ab28a1eeaa706164" }
6 changes: 3 additions & 3 deletions contract-tests/tests/rotation_input_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use eth_types::LIMB_BITS;
use ethers::contract::abigen;
use itertools::Itertools;
use lightclient_circuits::committee_update_circuit::CommitteeUpdateCircuit;
use lightclient_circuits::halo2_proofs::halo2curves::bn256::{self, Fr};
use lightclient_circuits::halo2_proofs::halo2curves::bn256;
use lightclient_circuits::poseidon::poseidon_committee_commitment_from_compressed;
use lightclient_circuits::witness::CommitteeRotationArgs;
use rstest::rstest;
Expand All @@ -24,11 +24,11 @@ abigen!(
);

// CommitteeRotationArgs type produced by abigen macro matches the solidity struct type
impl<Spec: eth_types::Spec> From<CommitteeRotationArgs<Spec, Fr>> for RotateInput
impl<Spec: eth_types::Spec> From<CommitteeRotationArgs<Spec>> for RotateInput
where
[(); Spec::SYNC_COMMITTEE_SIZE]:,
{
fn from(args: CommitteeRotationArgs<Spec, Fr>) -> Self {
fn from(args: CommitteeRotationArgs<Spec>) -> Self {
let poseidon_commitment_le = poseidon_committee_commitment_from_compressed(
&args.pubkeys_compressed.iter().cloned().collect_vec(),
)
Expand Down
5 changes: 2 additions & 3 deletions contracts/rust-abi/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
use ethers::contract::abigen;
use halo2curves::bn256::Fr;
use itertools::Itertools;
use lightclient_circuits::{
poseidon::poseidon_committee_commitment_from_compressed,
Expand Down Expand Up @@ -57,11 +56,11 @@ impl<Spec: eth_types::Spec> From<SyncStepArgs<Spec>> for SyncStepInput {
}

// CommitteeRotationArgs type produced by abigen macro matches the solidity struct type
impl<Spec: eth_types::Spec> From<CommitteeRotationArgs<Spec, Fr>> for RotateInput
impl<Spec: eth_types::Spec> From<CommitteeRotationArgs<Spec>> for RotateInput
where
[(); Spec::SYNC_COMMITTEE_SIZE]:,
{
fn from(args: CommitteeRotationArgs<Spec, Fr>) -> Self {
fn from(args: CommitteeRotationArgs<Spec>) -> Self {
let poseidon_commitment_le = poseidon_committee_commitment_from_compressed(
&args.pubkeys_compressed.iter().cloned().collect_vec(),
)
Expand Down
3 changes: 2 additions & 1 deletion eth-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#![feature(trait_alias)]
mod spec;
use halo2_base::utils::BigPrimeField;
use halo2curves::ff::PrimeField;
pub use spec::{Mainnet, Minimal, Spec, Testnet};

pub const NUM_LIMBS: usize = 4;
pub const LIMB_BITS: usize = 112;

pub trait Field = BigPrimeField;
pub trait Field = BigPrimeField + PrimeField<Repr = [u8; 32]>;
2 changes: 1 addition & 1 deletion lightclient-circuits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license = "MIT OR Apache-2.0"
halo2curves.workspace = true
halo2-base.workspace = true
halo2-ecc.workspace = true
zkevm-hashes.workspace = true

# verifier SDK
snark-verifier.workspace = true
Expand Down Expand Up @@ -37,7 +38,6 @@ serde_json.workspace = true
itertools.workspace = true
log.workspace = true
hex.workspace = true
poseidon_native.workspace = true
rayon = "1.7.0"
array-init = "2.0.0"
strum = "0.25"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"params": {
"k": 20,
"k": 18,
"num_advice_per_phase": [
4
12
],
"num_fixed": 1,
"num_lookup_advice_per_phase": [
Expand All @@ -15,9 +15,17 @@
},
"break_points": [
[
1048564,
1048566,
1048565
262134,
262132,
262134,
262132,
262133,
262132,
262132,
262133,
262132,
262134,
262133
]
]
}
}
23 changes: 0 additions & 23 deletions lightclient-circuits/config/committee_update_20.json

This file was deleted.

21 changes: 0 additions & 21 deletions lightclient-circuits/config/committee_update_aggregation.json

This file was deleted.

12 changes: 12 additions & 0 deletions lightclient-circuits/config/committee_update_verifier_25.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"params": {
"degree": 25,
"num_advice": 1,
"num_lookup_advice": 1,
"num_fixed": 1,
"lookup_bits": 8
},
"break_points": [
[]
]
}
File renamed without changes.
Loading

0 comments on commit 222f0b5

Please sign in to comment.