Skip to content

Commit

Permalink
Restore digest computation and fix API inconsistency (lurk-lang#242)
Browse files Browse the repository at this point in the history
* Revert "Digest simplifications (lurk-lang#238)"

This reverts commit 71ecb66.

* upgrade neptune

* make the public interface uniform wrt refs vs. copies

* simplify prove_step
  • Loading branch information
srinathsetty authored Oct 27, 2023
1 parent 9c241f8 commit e79498b
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 167 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nova-snark"
version = "0.25.0"
version = "0.26.0"
authors = ["Srinath Setty <[email protected]>"]
edition = "2021"
description = "Recursive zkSNARKs without trusted setup"
Expand Down
38 changes: 14 additions & 24 deletions benches/compressed-snark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,13 @@ fn bench_compressed_snark(c: &mut Criterion) {
&pp,
&c_primary,
&c_secondary,
vec![<G1 as Group>::Scalar::from(2u64)],
vec![<G2 as Group>::Scalar::from(2u64)],
);
&[<G1 as Group>::Scalar::from(2u64)],
&[<G2 as Group>::Scalar::from(2u64)],
)
.unwrap();

for i in 0..num_steps {
let res = recursive_snark.prove_step(
&pp,
&c_primary,
&c_secondary,
vec![<G1 as Group>::Scalar::from(2u64)],
vec![<G2 as Group>::Scalar::from(2u64)],
);
let res = recursive_snark.prove_step(&pp, &c_primary, &c_secondary);
assert!(res.is_ok());

// verify the recursive snark at each step of recursion
Expand Down Expand Up @@ -122,8 +117,8 @@ fn bench_compressed_snark(c: &mut Criterion) {
.verify(
black_box(&vk),
black_box(num_steps),
black_box(vec![<G1 as Group>::Scalar::from(2u64)]),
black_box(vec![<G2 as Group>::Scalar::from(2u64)]),
black_box(&[<G1 as Group>::Scalar::from(2u64)]),
black_box(&[<G2 as Group>::Scalar::from(2u64)]),
)
.is_ok());
})
Expand Down Expand Up @@ -163,18 +158,13 @@ fn bench_compressed_snark_with_computational_commitments(c: &mut Criterion) {
&pp,
&c_primary,
&c_secondary,
vec![<G1 as Group>::Scalar::from(2u64)],
vec![<G2 as Group>::Scalar::from(2u64)],
);
&[<G1 as Group>::Scalar::from(2u64)],
&[<G2 as Group>::Scalar::from(2u64)],
)
.unwrap();

for i in 0..num_steps {
let res = recursive_snark.prove_step(
&pp,
&c_primary,
&c_secondary,
vec![<G1 as Group>::Scalar::from(2u64)],
vec![<G2 as Group>::Scalar::from(2u64)],
);
let res = recursive_snark.prove_step(&pp, &c_primary, &c_secondary);
assert!(res.is_ok());

// verify the recursive snark at each step of recursion
Expand Down Expand Up @@ -209,8 +199,8 @@ fn bench_compressed_snark_with_computational_commitments(c: &mut Criterion) {
.verify(
black_box(&vk),
black_box(num_steps),
black_box(vec![<G1 as Group>::Scalar::from(2u64)]),
black_box(vec![<G2 as Group>::Scalar::from(2u64)]),
black_box(&[<G1 as Group>::Scalar::from(2u64)]),
black_box(&[<G2 as Group>::Scalar::from(2u64)]),
)
.is_ok());
})
Expand Down
17 changes: 5 additions & 12 deletions benches/recursive-snark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,13 @@ fn bench_recursive_snark(c: &mut Criterion) {
&pp,
&c_primary,
&c_secondary,
vec![<G1 as Group>::Scalar::from(2u64)],
vec![<G2 as Group>::Scalar::from(2u64)],
);
&[<G1 as Group>::Scalar::from(2u64)],
&[<G2 as Group>::Scalar::from(2u64)],
)
.unwrap();

for i in 0..num_warmup_steps {
let res = recursive_snark.prove_step(
&pp,
&c_primary,
&c_secondary,
vec![<G1 as Group>::Scalar::from(2u64)],
vec![<G2 as Group>::Scalar::from(2u64)],
);
let res = recursive_snark.prove_step(&pp, &c_primary, &c_secondary);
assert!(res.is_ok());

// verify the recursive snark at each step of recursion
Expand All @@ -99,8 +94,6 @@ fn bench_recursive_snark(c: &mut Criterion) {
black_box(&pp),
black_box(&c_primary),
black_box(&c_secondary),
black_box(vec![<G1 as Group>::Scalar::from(2u64)]),
black_box(vec![<G2 as Group>::Scalar::from(2u64)]),
)
.is_ok());
})
Expand Down
10 changes: 5 additions & 5 deletions benches/sha256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,17 @@ fn bench_recursive_snark(c: &mut Criterion) {
black_box(&pp),
black_box(&circuit_primary),
black_box(&circuit_secondary),
black_box(z0_primary.clone()),
black_box(z0_secondary.clone()),
);
black_box(&z0_primary),
black_box(&z0_secondary),
)
.unwrap();

// produce a recursive SNARK for a step of the recursion
assert!(recursive_snark
.prove_step(
black_box(&pp),
black_box(&circuit_primary),
black_box(&circuit_secondary),
black_box(z0_primary.clone()),
black_box(z0_secondary.clone()),
)
.is_ok());
})
Expand Down
26 changes: 11 additions & 15 deletions examples/minroot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,23 +207,19 @@ fn main() {
type C2 = TrivialCircuit<<G2 as Group>::Scalar>;
// produce a recursive SNARK
println!("Generating a RecursiveSNARK...");
let mut recursive_snark: RecursiveSNARK<G1, G2, C1, C2> = RecursiveSNARK::<G1, G2, C1, C2>::new(
&pp,
&minroot_circuits[0],
&circuit_secondary,
z0_primary.clone(),
z0_secondary.clone(),
);
let mut recursive_snark: RecursiveSNARK<G1, G2, C1, C2> =
RecursiveSNARK::<G1, G2, C1, C2>::new(
&pp,
&minroot_circuits[0],
&circuit_secondary,
&z0_primary,
&z0_secondary,
)
.unwrap();

for (i, circuit_primary) in minroot_circuits.iter().take(num_steps).enumerate() {
let start = Instant::now();
let res = recursive_snark.prove_step(
&pp,
circuit_primary,
&circuit_secondary,
z0_primary.clone(),
z0_secondary.clone(),
);
let res = recursive_snark.prove_step(&pp, circuit_primary, &circuit_secondary);
assert!(res.is_ok());
println!(
"RecursiveSNARK::prove_step {}: {:?}, took {:?} ",
Expand Down Expand Up @@ -274,7 +270,7 @@ fn main() {
// verify the compressed SNARK
println!("Verifying a CompressedSNARK...");
let start = Instant::now();
let res = compressed_snark.verify(&vk, num_steps, z0_primary, z0_secondary);
let res = compressed_snark.verify(&vk, num_steps, &z0_primary, &z0_secondary);
println!(
"CompressedSNARK::verify: {:?}, took {:?}",
res.is_ok(),
Expand Down
Loading

0 comments on commit e79498b

Please sign in to comment.