Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organize public param creation with assorted structs #288

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ generic-array = "1.0.0"
num-bigint = { version = "0.4", features = ["serde", "rand"] }
num-traits = "0.2"
num-integer = "0.1"
serde = { version = "1.0", features = ["derive"] }
serde = { version = "1.0", features = ["derive", "rc"] }
bincode = "1.3"
bitvec = "1.0"
byteorder = "1.4.3"
Expand Down
6 changes: 4 additions & 2 deletions benches/pcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use halo2curves::bn256::Bn256;
use rand::rngs::StdRng;
use rand_core::{CryptoRng, RngCore, SeedableRng};
use std::any::type_name;
use std::sync::Arc;
use std::time::Duration;

// To run these benchmarks, first download `criterion` with `cargo install cargo-criterion`.
Expand Down Expand Up @@ -44,7 +45,7 @@ struct BenchAssests<E: Engine, EE: EvaluationEngineTrait<E>> {
poly: MultilinearPolynomial<<E as Engine>::Scalar>,
point: Vec<<E as Engine>::Scalar>,
eval: <E as Engine>::Scalar,
ck: <<E as Engine>::CE as CommitmentEngineTrait<E>>::CommitmentKey,
ck: Arc<<<E as Engine>::CE as CommitmentEngineTrait<E>>::CommitmentKey>,
commitment: <<E as Engine>::CE as CommitmentEngineTrait<E>>::Commitment,
prover_key: <EE as EvaluationEngineTrait<E>>::ProverKey,
verifier_key: <EE as EvaluationEngineTrait<E>>::VerifierKey,
Expand Down Expand Up @@ -78,10 +79,11 @@ impl<E: Engine, EE: EvaluationEngineTrait<E>> BenchAssests<E, EE> {

// Mock commitment key.
let ck = E::CE::setup(b"test", 1 << num_vars);
let ck = Arc::new(ck);
// Commits to the provided vector using the provided generators.
let commitment = E::CE::commit(&ck, poly.evaluations());

let (prover_key, verifier_key) = EE::setup(&ck);
let (prover_key, verifier_key) = EE::setup(ck.clone());

// Generate proof so that we can bench verification.
let proof = EE::prove(
Expand Down
20 changes: 13 additions & 7 deletions examples/minroot.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! Demonstrates how to use Nova to produce a recursive proof of the correct execution of
//! iterations of the `MinRoot` function, thereby realizing a Nova-based verifiable delay function (VDF).
//! We execute a configurable number of iterations of the `MinRoot` function per step of Nova's recursion.
#[cfg(feature = "abomonate")]
use arecibo::FlatPublicParams;
use arecibo::{
provider::{Bn256EngineKZG, GrumpkinEngine},
traits::{
Expand Down Expand Up @@ -232,14 +234,16 @@ fn main() {
);
println!("PublicParams::setup, took {:?} ", start.elapsed());
#[cfg(feature = "abomonate")]
{
let pp = {
use abomonation::encode;
let mut file = std::fs::File::create(utils::FILEPATH).unwrap();
let flat_params = FlatPublicParams::try_from(pp).expect("error encoding pps!");
unsafe {
encode(&pp, &mut file).unwrap();
encode(&flat_params, &mut file).unwrap();
}
println!("Encoded!");
}
PublicParams::from(flat_params)
};

println!(
"Number of constraints per step (primary circuit): {}",
Expand Down Expand Up @@ -270,16 +274,18 @@ fn main() {
reader.read_to_end(&mut bytes).unwrap();
if let Some((result, remaining)) = unsafe {
decode::<
PublicParams<
FlatPublicParams<
E1,
E2,
MinRootCircuit<<E1 as Engine>::GE>,
TrivialCircuit<<E2 as Engine>::Scalar>,
>,
>(&mut bytes)
} {
assert!(*result == pp, "decoded parameters not equal to original!");
let result_pp = PublicParams::from(result.clone());
assert!(result_pp == pp, "decoded parameters not equal to original!");
assert!(remaining.is_empty());
println!("Decoded!");
} else {
println!("Decoding failure!");
}
Expand Down Expand Up @@ -352,8 +358,8 @@ fn main() {
type E2 = GrumpkinEngine;
type EE1 = arecibo::provider::hyperkzg::EvaluationEngine<Bn256, E1>;
type EE2 = arecibo::provider::ipa_pc::EvaluationEngine<E2>;
type S1 = arecibo::spartan::snark::RelaxedR1CSSNARK<E1, EE1>; // non-preprocessing SNARK
type S2 = arecibo::spartan::snark::RelaxedR1CSSNARK<E2, EE2>; // non-preprocessing SNARK
type S1 = arecibo::spartan::ppsnark::RelaxedR1CSSNARK<E1, EE1>; // non-preprocessing SNARK
type S2 = arecibo::spartan::ppsnark::RelaxedR1CSSNARK<E2, EE2>; // non-preprocessing SNARK

let res = CompressedSNARK::<_, _, _, _, S1, S2>::prove(&pp, &pk, &recursive_snark);
println!(
Expand Down
Loading