Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
916b29f
Rollback to pse halo2 and halo2wrong for first release (#5)
han0110 Oct 24, 2022
2cd8b9d
Generalized `Halo2Loader` (#12)
han0110 Oct 28, 2022
25dbaf5
General refactor for further integration (#13)
han0110 Nov 8, 2022
5c31088
feat: implement ipa pcs and accumulation (#14)
han0110 Nov 9, 2022
ba167b7
ci: add `svm-rs` and install `solc@0.8.17` in job `test` (#16)
han0110 Nov 14, 2022
c5645e7
Update `EvmLoader` to generate Yul code instead of bytecode (#15)
DoHoonKim8 Nov 17, 2022
5e5de91
fix: pin all `revm` dependencies (#18)
han0110 Nov 30, 2022
50d69c1
fix: looser trait bound on impl `CostEstimation` for `Plonk` (#20)
han0110 Dec 17, 2022
dda7423
Restructure for more kind of verifier (#21)
han0110 Dec 23, 2022
6a518c9
docs: add `#![deny(missing_docs)]` and simple documents
han0110 Jan 6, 2023
3f3da27
refactor: remove redudant check `validate_ec_point` (still doesn not …
han0110 Jan 6, 2023
5023293
feat: expand more things and fix typos
han0110 Jan 20, 2023
8cc0b15
fix: rustdoc warnings
han0110 Jan 20, 2023
e4e0a4d
Merge pull request #22 from han0110/feature/docs
CPerezz Jan 20, 2023
2d5ef6b
chore: update dependencies (#24)
alexander-camuto Feb 1, 2023
df03d89
chore: update `halo2` and `halo2wrong` version (#25)
han0110 Feb 3, 2023
f1265f5
fix: enable `util::hash::poseidon` only when `feature = loader_halo2`…
han0110 Feb 14, 2023
4ad803a
feat: working update to halo2-lib v0.3.0
jonathanpwang Feb 19, 2023
c9e2d2c
feat: update zkevm bench
jonathanpwang Feb 19, 2023
2db9f42
feat: update recursion example
jonathanpwang Feb 19, 2023
396aea6
feat: switch poseidon native implementation to Scroll's audited version
jonathanpwang Feb 20, 2023
53a30eb
fix: invert determinant only once in Cramer's rule
jonathanpwang Feb 20, 2023
8b09067
Merge remote-tracking branch 'upstream/main' into sync/halo2-lib-v0.3.0
jonathanpwang Feb 21, 2023
85c68b4
chore: fix doc
jonathanpwang Feb 21, 2023
efec13b
chore
jonathanpwang Feb 21, 2023
2fd73ab
chore: forgot to update halo2-base dependency in snark-verifier-sdk
jonathanpwang Feb 28, 2023
57aaba5
Minor update (#8)
jonathanpwang Apr 18, 2023
aecfd45
Moved `RangeWithInstanceCircuitBuilder` to halo2-lib (#9)
jonathanpwang May 5, 2023
95e6b4a
chore: fix halo2-base branch in sdk
jonathanpwang May 11, 2023
739c1f7
feat: update to halo2-lib new types (#10)
jonathanpwang May 22, 2023
b38400a
feat: add `assert` for non-empty accumulators in `decide_all` (#11)
jonathanpwang May 22, 2023
e24fa3c
feat: use `zip_eq` for `Polynomial` add/sub (#12)
jonathanpwang May 22, 2023
f510177
fix: git CI turn off all features
jonathanpwang May 22, 2023
9bbe6da
fix: `rotate_scalar` misbehaves on `i32::MIN` (#13)
jonathanpwang May 22, 2023
11e0ebc
fix: cleanup code quality (#14)
jonathanpwang May 22, 2023
1820e9c
fix: `split_by_ascii_whitespace` (#15)
jonathanpwang May 23, 2023
2641da5
fix: `batch_invert_and_mul` do not allow zeros (#16)
jonathanpwang May 23, 2023
1e64c30
feat: verify proof in release mode (#17)
jonathanpwang May 23, 2023
7041c6f
fix: add better error messages/docs for catching empty inputs (#18)
jonathanpwang May 23, 2023
eee5ec2
chore: add Cargo.lock
jonathanpwang May 23, 2023
9dbe913
chore: update Cargo dependencies
jonathanpwang May 23, 2023
5bf6a20
feat: fix versions and tags for dependencies
jonathanpwang Jun 20, 2023
e4532bc
Merge branch 'main' into release-0.1.1
jonathanpwang Jun 20, 2023
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
54 changes: 54 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI

on:
pull_request:
push:
branches:
- main

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: false

- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true

- name: Install solc
run: (hash svm 2>/dev/null || cargo install svm-rs) && svm install 0.8.17 && solc --version

- name: Run test
run: cargo test --all -- --nocapture


lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: false
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true

- name: Run fmt
run: cargo fmt --all -- --check

- name: Run clippy
run: cargo clippy --all --all-targets -- -D warnings
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
/target
testdata

Cargo.lock
4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,3 @@ incremental = false
[profile.flamegraph]
inherits = "release"
debug = true

# patch until PR https://github.com/privacy-scaling-explorations/halo2/pull/111 is merged
[patch."https://github.com/privacy-scaling-explorations/halo2.git"]
halo2_proofs = { git = "https://github.com/axiom-crypto/halo2.git", branch = "feat/serde-raw" }
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# PLONK Verifier
# SNARK Verifier

Generic PLONK verifier.
Generic (S)NARK verifier.
28 changes: 14 additions & 14 deletions snark-verifier-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "snark-verifier-sdk"
version = "0.0.1"
version = "0.1.1"
edition = "2021"

[dependencies]
itertools = "0.10.3"
itertools = "0.10.5"
lazy_static = "1.4.0"
num-bigint = "0.4.3"
num-integer = "0.1.45"
Expand All @@ -14,24 +14,24 @@ rand_chacha = "0.3.1"
hex = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_with = { version = "2.2", optional = true }
bincode = "1.3.3"
ark-std = { version = "0.3.0", features = ["print-trace"], optional = true }

halo2-base = { git = "https://github.com/axiom-crypto/halo2-lib.git", tag = "v0.2.2", default-features = false }
halo2-base = { git = "https://github.com/axiom-crypto/halo2-lib.git", tag = "v0.3.0", default-features = false }
snark-verifier = { path = "../snark-verifier", default-features = false }

# loader_evm
ethereum-types = { version = "0.14", default-features = false, features = ["std"], optional = true }
ethereum-types = { version = "=0.14.1", default-features = false, features = ["std"], optional = true }
# sha3 = { version = "0.10", optional = true }
# revm = { version = "2.3.1", optional = true }
# bytes = { version = "1.2", optional = true }
# rlp = { version = "0.5", default-features = false, features = ["std"], optional = true }

# zkevm benchmarks
zkevm-circuits = { git = "https://github.com/jonathanpwang/zkevm-circuits.git", branch = "bench-12-04", features = ["test"], optional = true }
bus-mapping = { git = "https://github.com/jonathanpwang/zkevm-circuits.git", branch = "bench-12-04", optional = true }
eth-types = { git = "https://github.com/jonathanpwang/zkevm-circuits.git", branch = "bench-12-04", optional = true }
mock = { git = "https://github.com/jonathanpwang/zkevm-circuits.git", branch = "bench-12-04", optional = true }
zkevm-circuits = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", features = ["test"], optional = true }
bus-mapping = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", optional = true }
eth-types = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", optional = true }
mock = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", optional = true }

[dev-dependencies]
ark-std = { version = "0.3.0", features = ["print-trace"] }
Expand All @@ -44,13 +44,13 @@ crossterm = { version = "0.25" }
tui = { version = "0.19", default-features = false, features = ["crossterm"] }

[features]
default = ["loader_halo2", "loader_evm", "halo2-axiom", "halo2-base/jemallocator"]
default = ["loader_halo2", "loader_evm", "halo2-axiom", "halo2-base/jemallocator", "display"]
display = ["snark-verifier/display", "dep:ark-std"]
loader_evm = ["snark-verifier/loader_evm", "dep:ethereum-types"]
loader_halo2 = ["snark-verifier/loader_halo2"]
parallel = ["snark-verifier/parallel"]
# EXACTLY one of halo2-pse / halo2-axiom should always be turned on; not sure how to enforce this with Cargo
halo2-pse = ["snark-verifier/halo2-pse"]
halo2-pse = ["snark-verifier/halo2-pse", "dep:serde_with"]
halo2-axiom = ["snark-verifier/halo2-axiom"]

zkevm = ["dep:zkevm-circuits", "dep:bus-mapping", "dep:mock", "dep:eth-types"]
Expand All @@ -62,10 +62,10 @@ harness = false

[[bench]]
name = "zkevm"
required-features = ["loader_halo2", "zkevm", "halo2-pse", "halo2-base/jemallocator"]
required-features = ["loader_halo2", "loader_evm", "zkevm", "halo2-pse"]
harness = false

[[bench]]
name = "zkevm_plus_state"
required-features = ["loader_halo2", "zkevm", "halo2-pse", "halo2-base/jemallocator"]
harness = false
required-features = ["loader_halo2", "loader_evm", "zkevm", "halo2-pse"]
harness = false
83 changes: 56 additions & 27 deletions snark-verifier-sdk/benches/standard_plonk.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
use criterion::{criterion_group, criterion_main};
use criterion::{BenchmarkId, Criterion};
use halo2_base::gates::builder::CircuitBuilderStage;
use halo2_base::utils::fs::gen_srs;
use pprof::criterion::{Output, PProfProfiler};

use rand::rngs::OsRng;
use std::path::Path;
use ark_std::{end_timer, start_timer};
use halo2_base::halo2_proofs;
use halo2_proofs::halo2curves as halo2_curves;
use halo2_proofs::{
halo2curves::bn256::Bn256,
poly::{commitment::Params, kzg::commitment::ParamsKZG},
};
use rand::rngs::OsRng;
use rand::SeedableRng;
use rand_chacha::ChaCha20Rng;
use snark_verifier_sdk::CircuitExt;
use snark_verifier_sdk::evm::{evm_verify, gen_evm_proof_shplonk, gen_evm_verifier_shplonk};
use snark_verifier_sdk::halo2::aggregation::AggregationConfigParams;
use snark_verifier_sdk::{
gen_pk,
halo2::{aggregation::AggregationCircuit, gen_proof_shplonk, gen_snark_shplonk},
Snark,
};
use snark_verifier_sdk::{CircuitExt, SHPLONK};

mod application {
use super::halo2_curves::bn256::Fr;
Expand Down Expand Up @@ -145,9 +147,9 @@ mod application {
}
#[cfg(feature = "halo2-axiom")]
{
region.assign_advice(config.a, 0, Value::known(self.0))?;
region.assign_advice(config.a, 0, Value::known(self.0));
region.assign_fixed(config.q_a, 0, -Fr::one());
region.assign_advice(config.a, 1, Value::known(-Fr::from(5u64)))?;
region.assign_advice(config.a, 1, Value::known(-Fr::from(5u64)));
for (idx, column) in (1..).zip([
config.q_a,
config.q_b,
Expand All @@ -158,7 +160,7 @@ mod application {
region.assign_fixed(column, 1, Fr::from(idx as u64));
}

let a = region.assign_advice(config.a, 2, Value::known(Fr::one()))?;
let a = region.assign_advice(config.a, 2, Value::known(Fr::one()));
a.copy_advice(&mut region, config.b, 3);
a.copy_advice(&mut region, config.c, 4);
}
Expand All @@ -173,42 +175,69 @@ mod application {
fn gen_application_snark(params: &ParamsKZG<Bn256>) -> Snark {
let circuit = application::StandardPlonk::rand(OsRng);

let pk = gen_pk(params, &circuit, None);
gen_snark_shplonk(params, &pk, circuit, &mut OsRng, None::<&str>)
let pk = gen_pk(params, &circuit, Some(Path::new("app.pk")));
gen_snark_shplonk(params, &pk, circuit, Some(Path::new("app.snark")))
}

fn bench(c: &mut Criterion) {
std::env::set_var("VERIFY_CONFIG", "./configs/example_evm_accumulator.config");
let k = 21;
let params = halo2_base::utils::fs::gen_srs(k);
let params_app = {
let mut params = params.clone();
params.downsize(8);
params
};
let path = "./configs/example_evm_accumulator.json";
let params_app = gen_srs(8);

let snarks = [(); 3].map(|_| gen_application_snark(&params_app));
let agg_config = AggregationConfigParams::from_path(path);
let params = gen_srs(agg_config.degree);
let lookup_bits = params.k() as usize - 1;

let start1 = start_timer!(|| "Create aggregation circuit");
let mut rng = ChaCha20Rng::from_entropy();
let agg_circuit = AggregationCircuit::new(&params, snarks, &mut rng);
end_timer!(start1);
let agg_circuit = AggregationCircuit::keygen::<SHPLONK>(&params, snarks.clone());

let pk = gen_pk(&params, &agg_circuit, None);
let start0 = start_timer!(|| "gen vk & pk");
let pk = gen_pk(&params, &agg_circuit, Some(Path::new("agg.pk")));
end_timer!(start0);
let break_points = agg_circuit.break_points();

let mut group = c.benchmark_group("plonk-prover");
group.sample_size(10);
group.bench_with_input(
BenchmarkId::new("standard-plonk-agg", k),
&(&params, &pk, &agg_circuit),
|b, &(params, pk, agg_circuit)| {
BenchmarkId::new("standard-plonk-agg", params.k()),
&(&params, &pk, &break_points, &snarks),
|b, &(params, pk, break_points, snarks)| {
b.iter(|| {
let agg_circuit = AggregationCircuit::new::<SHPLONK>(
CircuitBuilderStage::Prover,
Some(break_points.clone()),
lookup_bits,
params,
snarks.clone(),
);
let instances = agg_circuit.instances();
gen_proof_shplonk(params, pk, agg_circuit.clone(), instances, &mut rng, None)
gen_proof_shplonk(params, pk, agg_circuit, instances, None)
})
},
);
group.finish();

#[cfg(feature = "loader_evm")]
{
// do one more time to verify
let agg_circuit = AggregationCircuit::new::<SHPLONK>(
CircuitBuilderStage::Prover,
Some(break_points),
lookup_bits,
&params,
snarks.clone(),
);
let num_instances = agg_circuit.num_instance();
let instances = agg_circuit.instances();
let proof = gen_evm_proof_shplonk(&params, &pk, agg_circuit, instances.clone());

let deployment_code = gen_evm_verifier_shplonk::<AggregationCircuit>(
&params,
pk.get_vk(),
num_instances,
None,
);
evm_verify(deployment_code, instances, proof);
}
}

criterion_group! {
Expand Down
Loading