Skip to content

Commit

Permalink
0.1.6-rc -> 0.1.7-rc (#37)
Browse files Browse the repository at this point in the history
* chore: try pragma solidity 0.8.20 with CI

* chore: make `transcript_initial_state` public

So we can read transcript initial state from `VerifyingKey`

* test: edit range_check example to trigger selector compression

* [feat] add `aggregate_snarks` function (#34)

* feat: add `aggregate_snarks` function

- Previously you could only create a new `builder` pre-populated with
  the witnesses for snark aggregation.
- This is a bad design pattern if you want to make a circuit that
  aggregates and also does other stuff.
- This function will use whatever `SinglePhaseCoreManager` and
  `RangeChip` you provide to prove the snark aggregation.

* chore: add comment

* chore: fix comment

* [feat(sdk)] `aggregate_snarks` returns loaded proof witnesses (#36)

* feat(sdk): `aggregate_snarks` returns loaded proof witnesses

* feat: add `TranscriptObject` to track assigned proof transcript

* chore: Bump version to 0.1.7
  • Loading branch information
jonathanpwang authored Oct 16, 2023
1 parent d8400e6 commit c7d7a8f
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 102 deletions.
18 changes: 4 additions & 14 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.6"
version = "0.1.7"
edition = "2021"

[dependencies]
Expand All @@ -22,14 +22,10 @@ snark-verifier = { path = "../snark-verifier", default-features = false }
getset = "0.1.2"

# loader_evm
ethereum-types = { version = "0.14.1", default-features = false, features = [
"std",
], optional = true }
ethereum-types = { version = "0.14.1", default-features = false, features = ["std"], optional = true }

# zkevm benchmarks
zkevm-circuits = { git = "https://github.com/privacy-scaling-explorations/zkevm-circuits.git", rev = "f834e61", features = [
"test",
], 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 }
Expand All @@ -45,13 +41,7 @@ crossterm = { version = "0.25" }
tui = { version = "0.19", default-features = false, features = ["crossterm"] }

[features]
default = [
"loader_halo2",
"loader_evm",
"halo2-axiom",
"halo2-base/jemallocator",
"display",
]
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"]
Expand Down
27 changes: 21 additions & 6 deletions snark-verifier-sdk/examples/range_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use snark_verifier_sdk::{
Snark,
};

fn generate_circuit(k: u32) -> Snark {
fn generate_circuit(k: u32, fill: bool) -> Snark {
let lookup_bits = k as usize - 1;
let circuit_params = BaseCircuitParams {
k: k as usize,
Expand All @@ -30,20 +30,31 @@ fn generate_circuit(k: u32) -> Snark {
let ctx = builder.main(0);

let x = ctx.load_witness(Fr::from(14));
range.range_check(ctx, x, 2 * lookup_bits + 1);
range.gate().add(ctx, x, x);
if fill {
for _ in 0..2 << k {
range.gate().add(ctx, x, x);
}
}

let params = gen_srs(k);
// do not call calculate_params, we want to use fixed params
let pk = gen_pk(&params, &builder, None);
// std::fs::remove_file(Path::new("examples/app.pk")).ok();
// let _pk = gen_pk(&params, &builder, Some(Path::new("examples/app.pk")));
// let pk = read_pk::<BaseCircuitBuilder<_>>(
// Path::new("examples/app.pk"),
// builder.config_params.clone(),
// )
// .unwrap();
// std::fs::remove_file(Path::new("examples/app.pk")).ok();
// builder now has break_point set
gen_snark_shplonk(&params, &pk, builder, None::<&str>)
}

fn main() {
let dummy_snark = generate_circuit(9);
let dummy_snark = generate_circuit(9, false);

let k = 14u32;
let k = 16u32;
let lookup_bits = k as usize - 1;
let params = gen_srs(k);
let mut agg_circuit = AggregationCircuit::new::<SHPLONK>(
Expand All @@ -57,10 +68,14 @@ fn main() {

let start0 = start_timer!(|| "gen vk & pk");
let pk = gen_pk(&params, &agg_circuit, None);
// std::fs::remove_file(Path::new("examples/agg.pk")).ok();
// let _pk = gen_pk(&params, &agg_circuit, Some(Path::new("examples/agg.pk")));
end_timer!(start0);
// let pk = read_pk::<AggregationCircuit>(Path::new("examples/agg.pk"), agg_config).unwrap();
// std::fs::remove_file(Path::new("examples/agg.pk")).ok();
let break_points = agg_circuit.break_points();

let snarks = (10..16).map(generate_circuit).collect_vec();
let snarks = (10..16).map(|k| generate_circuit(k, true)).collect_vec();
for (i, snark) in snarks.into_iter().enumerate() {
let agg_circuit = AggregationCircuit::new::<SHPLONK>(
CircuitBuilderStage::Prover,
Expand Down
Loading

0 comments on commit c7d7a8f

Please sign in to comment.