Skip to content

Commit

Permalink
Update versions
Browse files Browse the repository at this point in the history
  • Loading branch information
varunthakore committed Jun 9, 2024
1 parent de33db1 commit 6bf0316
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bellpepper-core = { version="0.3.0", default-features = false }
bellpepper = { version="0.3.0", default-features = false }
bellpepper-core = { version="0.4.0", default-features = false }
bellpepper = { version="0.4.0", default-features = false }
bellpepper-sha512 = { git = "https://github.com/lurk-lab/bellpepper-gadgets.git" }
bellpepper-uint64 = { git = "https://github.com/lurk-lab/bellpepper-gadgets.git" }
ff = "0.13.0"
generic-array = "0.14.6"
nova-snark = "0.27.0"
nova-snark = { version="0.36.0", default-features = false }

[dev-dependencies]
pasta_curves = { version = "0.5", features = ["repr-c", "serde"] }
Expand Down
30 changes: 17 additions & 13 deletions examples/sha512.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
type G1 = pasta_curves::pallas::Point;
type G2 = pasta_curves::vesta::Point;
use std::time::Instant;

use clap::{Arg, Command};
use flate2::{write::ZlibEncoder, Compression};
use nova_sha512::circuit::SHA512CompressionCircuit;
use nova_sha512::util::{scalars_to_digest, sha512_initial_digest_scalars, DIGEST_LENGTH_BYTES};
use nova_snark::traits::Engine;
use nova_snark::{
traits::{circuit::TrivialCircuit, Group},
traits::circuit::TrivialCircuit,
traits::snark::RelaxedR1CSSNARKTrait,
CompressedSNARK, PublicParams, RecursiveSNARK,
provider::{PallasEngine, VestaEngine},
};
use sha2::{Digest, Sha512};

type E1 = PallasEngine;
type E2 = VestaEngine;
type EE1 = nova_snark::provider::ipa_pc::EvaluationEngine<E1>;
type EE2 = nova_snark::provider::ipa_pc::EvaluationEngine<E2>;
type S1 = nova_snark::spartan::snark::RelaxedR1CSSNARK<E1, EE1>;
type S2 = nova_snark::spartan::snark::RelaxedR1CSSNARK<E2, EE2>;

fn main() {
let cmd = Command::new("Nova-based SHA512 circuit proof generation and verification")
.bin_name("sha512")
Expand All @@ -31,14 +39,14 @@ fn main() {
println!("Nova-based SHA512 compression function iterations");
println!("=========================================================");

type C1 = SHA512CompressionCircuit<<G1 as Group>::Scalar>;
type C2 = TrivialCircuit<<G2 as Group>::Scalar>;
type C1 = SHA512CompressionCircuit<<E1 as Engine>::Scalar>;
type C2 = TrivialCircuit<<E2 as Engine>::Scalar>;
let circuit_primary: C1 = SHA512CompressionCircuit::default();
let circuit_secondary: C2 = TrivialCircuit::default();

let param_gen_timer = Instant::now();
println!("Producing public parameters...");
let pp = PublicParams::<G1, G2, C1, C2>::setup(&circuit_primary, &circuit_secondary.clone());
let pp = PublicParams::<E1, E2, C1, C2>::setup(&circuit_primary, &circuit_secondary.clone(), &*S1::ck_floor(), &*S2::ck_floor()).unwrap();

let param_gen_time = param_gen_timer.elapsed();
println!("PublicParams::setup, took {:?} ", param_gen_time);
Expand All @@ -63,13 +71,13 @@ fn main() {
let input: Vec<u8> = vec![0u8; input_len]; // All the input bytes are zero
let primary_circuit_sequence = C1::new_state_sequence(input.clone());

let z0_primary = sha512_initial_digest_scalars::<<G1 as Group>::Scalar>();
let z0_secondary = vec![<G2 as Group>::Scalar::zero()];
let z0_primary = sha512_initial_digest_scalars::<<E1 as Engine>::Scalar>();
let z0_secondary = vec![<E2 as Engine>::Scalar::zero()];

let proof_gen_timer = Instant::now();
// produce a recursive SNARK
println!("Generating a RecursiveSNARK...");
let mut recursive_snark: RecursiveSNARK<G1, G2, C1, C2> = RecursiveSNARK::<G1, G2, C1, C2>::new(
let mut recursive_snark: RecursiveSNARK<E1, E2, C1, C2> = RecursiveSNARK::<E1, E2, C1, C2>::new(
&pp,
&primary_circuit_sequence[0],
&circuit_secondary,
Expand Down Expand Up @@ -114,10 +122,6 @@ fn main() {
let (pk, vk) = CompressedSNARK::<_, _, _, _, S1, S2>::setup(&pp).unwrap();

let start = Instant::now();
type EE1 = nova_snark::provider::ipa_pc::EvaluationEngine<G1>;
type EE2 = nova_snark::provider::ipa_pc::EvaluationEngine<G2>;
type S1 = nova_snark::spartan::snark::RelaxedR1CSSNARK<G1, EE1>;
type S2 = nova_snark::spartan::snark::RelaxedR1CSSNARK<G2, EE2>;

let res = CompressedSNARK::<_, _, _, _, S1, S2>::prove(&pp, &pk, &recursive_snark);
println!(
Expand Down
2 changes: 1 addition & 1 deletion src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use bellpepper_core::{
};

use bellpepper_sha512::sha512::sha512_compression_function;
use bellpepper_sha512::uint64::UInt64;
use bellpepper_uint64::UInt64;
use ff::{PrimeField, PrimeFieldBits};
use nova_snark::traits::circuit::StepCircuit;

Expand Down

0 comments on commit 6bf0316

Please sign in to comment.