Skip to content

Commit

Permalink
Intergrate SuperNova's PublicParams, benchmark NIVC, and Stablize P…
Browse files Browse the repository at this point in the history
…aram API (argumentcomputer#648)

* add circuit digest api, instances, CLI

* add suggestions, finalize instance API

* fix: depend on arecibo/dev

---------

Co-authored-by: porcuquine <porcuquine@users.noreply.github.com>
Co-authored-by: François Garillot <francois@garillot.net>
  • Loading branch information
3 people authored Oct 2, 2023
1 parent 3e1bc08 commit d65ca11
Show file tree
Hide file tree
Showing 20 changed files with 1,103 additions and 637 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ name = "synthesis"
harness = false

[[bench]]
name = "sha256_ivc"
name = "sha256"
harness = false

[[bench]]
Expand Down
105 changes: 63 additions & 42 deletions benches/end2end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ use lurk::{
proof::Prover,
proof::{nova::NovaProver, MultiFrameTrait},
ptr::Ptr,
public_parameters,
public_parameters::{
self,
instance::{Instance, Kind},
},
state::State,
store::Store,
};
Expand Down Expand Up @@ -66,10 +69,14 @@ fn end2end_benchmark(c: &mut Criterion) {
let prover = NovaProver::new(reduction_count, lang_pallas);

// use cached public params
let pp = public_parameters::public_params::<_, _, MultiFrame<'_, _, Coproc<pallas::Scalar>>>(
let instance = Instance::new(
reduction_count,
true,
lang_pallas_rc.clone(),
true,
Kind::NovaPublicParams,
);
let pp = public_parameters::public_params::<_, _, MultiFrame<'_, _, _>>(
&instance,
Utf8Path::new(PUBLIC_PARAMS_PATH),
)
.unwrap();
Expand Down Expand Up @@ -286,14 +293,17 @@ fn prove_benchmark(c: &mut Criterion) {
group.bench_with_input(benchmark_id, &size, |b, &s| {
let ptr = go_base::<pallas::Scalar>(&store, state.clone(), s.0, s.1);
let prover = NovaProver::new(reduction_count, lang_pallas.clone());
let pp =
public_parameters::public_params::<_, _, MultiFrame<'_, _, Coproc<pallas::Scalar>>>(
reduction_count,
true,
lang_pallas_rc.clone(),
Utf8Path::new(PUBLIC_PARAMS_PATH),
)
.unwrap();
let instance = Instance::new(
reduction_count,
lang_pallas_rc.clone(),
true,
Kind::NovaPublicParams,
);
let pp = public_parameters::public_params::<_, _, MultiFrame<'_, _, _>>(
&instance,
Utf8Path::new(PUBLIC_PARAMS_PATH),
)
.unwrap();
let frames = MultiFrame::get_evaluation_frames(
|count| prover.needs_frame_padding(count),
ptr,
Expand Down Expand Up @@ -335,27 +345,29 @@ fn prove_compressed_benchmark(c: &mut Criterion) {

let state = State::init_lurk_state().rccell();

let pp = public_parameters::public_params::<_, _, MultiFrame<'_, _, _>>(
reduction_count,
true,
lang_pallas_rc.clone(),
Utf8Path::new(PUBLIC_PARAMS_PATH),
)
.unwrap();

group.bench_with_input(benchmark_id, &size, |b, &s| {
let ptr = go_base::<pallas::Scalar>(&store, state.clone(), s.0, s.1);
let prover = NovaProver::new(reduction_count, lang_pallas.clone());

let frames = MultiFrame::get_evaluation_frames(
|count| prover.needs_frame_padding(count),
ptr,
empty_sym_env(&store),
&store,
limit,
&lang_pallas,
let instance = Instance::new(
reduction_count,
lang_pallas_rc.clone(),
true,
Kind::NovaPublicParams,
);
let pp = public_parameters::public_params::<_, _, MultiFrame<'_, _, _>>(
&instance,
Utf8Path::new(PUBLIC_PARAMS_PATH),
)
.unwrap();
let frames = prover
.get_evaluation_frames(
ptr,
empty_sym_env(&store),
&store,
limit,
lang_pallas_rc.clone(),
)
.unwrap();

b.iter(|| {
let (proof, _, _, _) = prover.prove(&pp, &frames, &store, &lang_pallas_rc).unwrap();
Expand Down Expand Up @@ -390,24 +402,29 @@ fn verify_benchmark(c: &mut Criterion) {
group.bench_with_input(benchmark_id, &size, |b, &s| {
let ptr = go_base(&store, state.clone(), s.0, s.1);
let prover = NovaProver::new(reduction_count, lang_pallas.clone());
let pp = public_parameters::public_params::<_, _, MultiFrame<'_, _, _>>(
let instance = Instance::new(
reduction_count,
true,
lang_pallas_rc.clone(),
true,
Kind::NovaPublicParams,
);
let pp = public_parameters::public_params::<_, _, MultiFrame<'_, _, _>>(
&instance,
Utf8Path::new(PUBLIC_PARAMS_PATH),
)
.unwrap();
let frames = MultiFrame::get_evaluation_frames(
|count| prover.needs_frame_padding(count),
ptr,
empty_sym_env(&store),
&store,
limit,
&lang_pallas,
)
.unwrap();
let (proof, z0, zi, num_steps) =
prover.prove(&pp, &frames, &store, &lang_pallas_rc).unwrap();
let frames = prover
.get_evaluation_frames(
ptr,
empty_sym_env(&store),
&store,
limit,
lang_pallas_rc.clone(),
)
.unwrap();
let (proof, z0, zi, num_steps) = prover
.prove(&pp, &frames, &store, &lang_pallas_rc.clone())
.unwrap();

b.iter_batched(
|| z0.clone(),
Expand Down Expand Up @@ -447,10 +464,14 @@ fn verify_compressed_benchmark(c: &mut Criterion) {
group.bench_with_input(benchmark_id, &size, |b, &s| {
let ptr = go_base(&store, state.clone(), s.0, s.1);
let prover = NovaProver::new(reduction_count, lang_pallas.clone());
let pp = public_parameters::public_params::<_, _, MultiFrame<'_, _, _>>(
let instance = Instance::new(
reduction_count,
true,
lang_pallas_rc.clone(),
true,
Kind::NovaPublicParams,
);
let pp = public_parameters::public_params::<_, _, MultiFrame<'_, _, _>>(
&instance,
Utf8Path::new(PUBLIC_PARAMS_PATH),
)
.unwrap();
Expand Down
19 changes: 12 additions & 7 deletions benches/fibonacci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ use lurk::{
proof::nova::NovaProver,
proof::Prover,
ptr::Ptr,
public_parameters::public_params,
public_parameters::{
instance::{Instance, Kind},
public_params,
},
state::State,
store::Store,
};
Expand Down Expand Up @@ -76,13 +79,15 @@ fn fibo_prove<M: measurement::Measurement>(
let lang_rc = Arc::new(lang_pallas.clone());

// use cached public params
let pp = public_params::<_, _, MultiFrame<'_, _, _>>(
prove_params.reduction_count,
true,
let instance = Instance::new(
reduction_count,
lang_rc.clone(),
Utf8Path::new(PUBLIC_PARAMS_PATH),
)
.unwrap();
true,
Kind::NovaPublicParams,
);
let pp =
public_params::<_, _, MultiFrame<'_, _, _>>(&instance, Utf8Path::new(PUBLIC_PARAMS_PATH))
.unwrap();

c.bench_with_input(
BenchmarkId::new(prove_params.name(), fib_n),
Expand Down
Loading

0 comments on commit d65ca11

Please sign in to comment.