Skip to content

Commit

Permalink
[Update] use ff v0.13 (privacy-scaling-explorations#28)
Browse files Browse the repository at this point in the history
* feat(snark-verifier): update to ff v0.13

* feat(snark-verifier): update examples

* feat(snark-verifier-sdk): update to ff v0.13

* fix: conversion from BaseConfigParams to AggregationConfigParams

* chore: pin poseidon rev

* refactor(sdk): add `AggregationCtxBuilder` for aggregation

Contains the populated builder after aggregating, without creating the
`AggregationCircuit`. Doesn't need config parameters and break points.

* chore: update cargo
  • Loading branch information
jonathanpwang authored Aug 15, 2023
1 parent 4aba23a commit 4eded17
Show file tree
Hide file tree
Showing 37 changed files with 587 additions and 587 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ members = [
"snark-verifier",
"snark-verifier-sdk",
]
resolver = "2"

[profile.dev]
opt-level = 3
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2022-10-28
nightly-2023-08-12
4 changes: 2 additions & 2 deletions snark-verifier-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "snark-verifier-sdk"
version = "0.1.1"
version = "0.1.2"
edition = "2021"

[dependencies]
Expand Down Expand Up @@ -53,7 +53,7 @@ parallel = ["snark-verifier/parallel"]
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"]
# zkevm = ["dep:zkevm-circuits", "dep:bus-mapping", "dep:mock", "dep:eth-types"]

[[bench]]
name = "standard_plonk"
Expand Down
29 changes: 18 additions & 11 deletions snark-verifier-sdk/benches/read_pk.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use ark_std::{end_timer, start_timer};
use criterion::Criterion;
use criterion::{criterion_group, criterion_main};
use halo2_base::gates::builder::BASE_CONFIG_PARAMS;
use halo2_base::gates::builder::CircuitBuilderStage;
use halo2_base::halo2_proofs;
use halo2_base::utils::fs::gen_srs;
use halo2_proofs::halo2curves as halo2_curves;
Expand Down Expand Up @@ -182,30 +182,37 @@ fn bench(c: &mut Criterion) {

let snarks = [(); 3].map(|_| gen_application_snark(&params_app));
let agg_config = AggregationConfigParams::from_path(path);
BASE_CONFIG_PARAMS.with(|params| *params.borrow_mut() = agg_config.into());
let params = gen_srs(agg_config.degree);

let agg_circuit = AggregationCircuit::keygen::<SHPLONK>(&params, snarks);
let agg_circuit = AggregationCircuit::new::<SHPLONK>(
CircuitBuilderStage::Keygen,
agg_config,
None,
&params,
snarks,
);

std::fs::remove_file("examples/agg.pk").ok();
let start0 = start_timer!(|| "gen vk & pk");
gen_pk(&params, &agg_circuit, Some(Path::new("examples/agg.pk")));
end_timer!(start0);

let mut group = c.benchmark_group("read-pk");
group.sample_size(10);
group.bench_with_input("1mb", &(1024 * 1024), |b, &c| {
b.iter(|| read_pk_with_capacity::<AggregationCircuit>(c, "examples/agg.pk"))
group.bench_with_input("buffer 1mb capacity", &(1024 * 1024), |b, &c| {
b.iter(|| read_pk_with_capacity::<AggregationCircuit>(c, "examples/agg.pk", agg_config))
});
group.bench_with_input("10mb", &(10 * 1024 * 1024), |b, &c| {
b.iter(|| read_pk_with_capacity::<AggregationCircuit>(c, "examples/agg.pk"))
group.bench_with_input("buffer 10mb capacity", &(10 * 1024 * 1024), |b, &c| {
b.iter(|| read_pk_with_capacity::<AggregationCircuit>(c, "examples/agg.pk", agg_config))
});
group.bench_with_input("100mb", &(100 * 1024 * 1024), |b, &c| {
b.iter(|| read_pk_with_capacity::<AggregationCircuit>(c, "examples/agg.pk"))
group.bench_with_input("buffer 100mb capacity", &(100 * 1024 * 1024), |b, &c| {
b.iter(|| read_pk_with_capacity::<AggregationCircuit>(c, "examples/agg.pk", agg_config))
});
group.bench_with_input("1gb", &(1024 * 1024 * 1024), |b, &c| {
b.iter(|| read_pk_with_capacity::<AggregationCircuit>(c, "examples/agg.pk"))
group.bench_with_input("buffer 1gb capacity", &(1024 * 1024 * 1024), |b, &c| {
b.iter(|| read_pk_with_capacity::<AggregationCircuit>(c, "examples/agg.pk", agg_config))
});
group.finish();
std::fs::remove_file("examples/agg.pk").unwrap();
}

criterion_group! {
Expand Down
16 changes: 10 additions & 6 deletions snark-verifier-sdk/benches/standard_plonk.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use ark_std::{end_timer, start_timer};
use criterion::{criterion_group, criterion_main};
use criterion::{BenchmarkId, Criterion};
use halo2_base::gates::builder::{CircuitBuilderStage, BASE_CONFIG_PARAMS};
use halo2_base::gates::builder::CircuitBuilderStage;
use halo2_base::halo2_proofs;
use halo2_base::utils::fs::gen_srs;
use halo2_proofs::halo2curves as halo2_curves;
Expand Down Expand Up @@ -185,11 +185,15 @@ fn bench(c: &mut Criterion) {

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

let agg_circuit = AggregationCircuit::keygen::<SHPLONK>(&params, snarks.clone());
let agg_circuit = AggregationCircuit::new::<SHPLONK>(
CircuitBuilderStage::Keygen,
agg_config,
None,
&params,
snarks.clone(),
);

let start0 = start_timer!(|| "gen vk & pk");
let pk = gen_pk(&params, &agg_circuit, Some(Path::new("agg.pk")));
Expand All @@ -205,8 +209,8 @@ fn bench(c: &mut Criterion) {
b.iter(|| {
let agg_circuit = AggregationCircuit::new::<SHPLONK>(
CircuitBuilderStage::Prover,
agg_config,
Some(break_points.clone()),
lookup_bits,
params,
snarks.clone(),
);
Expand All @@ -222,8 +226,8 @@ fn bench(c: &mut Criterion) {
// do one more time to verify
let agg_circuit = AggregationCircuit::new::<SHPLONK>(
CircuitBuilderStage::Prover,
agg_config,
Some(break_points),
lookup_bits,
&params,
snarks.clone(),
);
Expand Down
Loading

0 comments on commit 4eded17

Please sign in to comment.