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

bump Nova to 0.24 #39

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
54 changes: 27 additions & 27 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
[package]
name = "nova-scotia"
version = "0.5.0"
edition = "2021"
authors = ["Nalin <novascotia@nibnalin.me>"]
description = "Middleware to compile Circom circuits to Nova zkSNARK scheme"
name = "nova-scotia"
version = "0.5.0"
edition = "2021"
authors = ["Nalin <novascotia@nibnalin.me>"]
description = "Middleware to compile Circom circuits to Nova zkSNARK scheme"
documentation = "https://github.com/nalinbhardwaj/Nova-Scotia/blob/main/README.md"
readme = "README.md"
repository = "https://github.com/nalinbhardwaj/Nova-Scotia"
license-file = "LICENSE"
keywords = ["zkSNARKs", "cryptography", "proofs"]
readme = "README.md"
repository = "https://github.com/nalinbhardwaj/Nova-Scotia"
license-file = "LICENSE"
keywords = ["zkSNARKs", "cryptography", "proofs"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
anyhow = "1.0.65"
bellperson = { version = "0.25", default-features = false }
byteorder = "1.4.3"
ff = { version = "0.13", features = ["derive"]}
hex-literal = "0.3.4"
itertools = "0.9.0"
nova-snark = "0.23.0"
num-bigint = { version = "0.4", features = ["serde", "rand"] }
num-traits = "0.2.15"
pasta_curves = "0.5"
serde = "1.0"
serde_json = "1.0.85"
anyhow = "1.0.65"
bellpepper-core = "0.2.0"
byteorder = "1.4.3"
ff = { version = "0.13", features = ["derive"] }
hex-literal = "0.3.4"
itertools = "0.9.0"
nova-snark = "0.24.0"
num-bigint = { version = "0.4", features = ["serde", "rand"] }
num-traits = "0.2.15"
pasta_curves = "0.5"
serde = "1.0"
serde_json = "1.0.85"

[target.'cfg(target_family = "wasm")'.dependencies]
wasm-bindgen = { version = "0.2.81", features = ["serde-serialize"]}
rayon = "1.5"
wasm-bindgen-rayon = { version = "1.0"}
wasm-bindgen = { version = "0.2.81", features = ["serde-serialize"] }
rayon = "1.5"
wasm-bindgen-rayon = { version = "1.0" }
wasm-bindgen-futures = "0.4"
js-sys = "0.3"
js-sys = "0.3"

[features]
default = []
cuda = ["nova-snark/cuda"]
opencl = ["nova-snark/opencl"]
cuda = ["nova-snark/cuda"]
opencl = ["nova-snark/opencl"]
29 changes: 14 additions & 15 deletions browser-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
[package]
name = "nova-scotia-browser"
name = "nova-scotia-browser"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
nova-scotia = { path = "../" }
nova-snark = "0.23.0"
num-bigint = { version = "0.4", features = ["serde", "rand"] }
num-traits = "0.2.15"
serde = "1.0"
serde_json = "1.0.85"
nova-scotia = { path = "../" }
nova-snark = "0.24.0"
num-bigint = { version = "0.4", features = ["serde", "rand"] }
num-traits = "0.2.15"
serde = "1.0"
serde_json = "1.0.85"
pasta_curves = "0.5"

[target.'cfg(target_family = "wasm")'.dependencies]
getrandom = { version = "0.2", features = ["js"]}
wasm-bindgen = { version = "0.2.81", features = ["serde-serialize"]}
getrandom = { version = "0.2", features = ["js"] }
wasm-bindgen = { version = "0.2.81", features = ["serde-serialize"] }
console_error_panic_hook = "0.1.7"
rayon = "1.5"
wasm-bindgen-rayon = { version = "1.0"}
web-sys = { version = "0.3", features = ["Request", "Window", "Response"] }
wasm-bindgen-futures = "0.4"
js-sys = "0.3"
rayon = "1.5"
wasm-bindgen-rayon = { version = "1.0" }
web-sys = { version = "0.3", features = ["Request", "Window", "Response"] }
wasm-bindgen-futures = "0.4"
js-sys = "0.3"

[lib]
crate-type = ["cdylib", "rlib"]

8 changes: 4 additions & 4 deletions browser-test/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use nova_scotia::{
create_public_params, create_recursive_circuit, FileLocation, F, S,
};
use nova_snark::{
traits::{circuit::TrivialTestCircuit, Group},
traits::{circuit::TrivialCircuit, Group},
CompressedSNARK, PublicParams,
};
use serde_json::json;
Expand Down Expand Up @@ -81,7 +81,7 @@ pub async fn generate_proof(pp_str: String) -> String {
let start_public_input = [F::<G1>::from(10), F::<G1>::from(10)];

let pp = serde_json::from_str::<
PublicParams<G1, G2, CircomCircuit<F<G1>>, TrivialTestCircuit<F<G2>>>,
PublicParams<G1, G2, CircomCircuit<F<G1>>, TrivialCircuit<F<G2>>>,
>(&pp_str)
.unwrap();

Expand Down Expand Up @@ -134,7 +134,7 @@ pub async fn generate_proof(pp_str: String) -> String {
#[wasm_bindgen]
pub async fn verify_compressed_proof(pp_str: String, proof_str: String) -> bool {
let pp = serde_json::from_str::<
PublicParams<G1, G2, CircomCircuit<F<G1>>, TrivialTestCircuit<F<G2>>>,
PublicParams<G1, G2, CircomCircuit<F<G1>>, TrivialCircuit<F<G2>>>,
>(&pp_str)
.unwrap();
let (_pk, vk) = CompressedSNARK::<_, _, _, _, S<G1>, S<G2>>::setup(&pp).unwrap();
Expand All @@ -143,7 +143,7 @@ pub async fn verify_compressed_proof(pp_str: String, proof_str: String) -> bool
let z0_secondary = vec![F::<G2>::zero()];

let compressed_proof = serde_json::from_str::<
CompressedSNARK<G1, G2, CircomCircuit<F<G1>>, TrivialTestCircuit<F<G2>>, S<G1>, S<G2>>,
CompressedSNARK<G1, G2, CircomCircuit<F<G1>>, TrivialCircuit<F<G2>>, S<G1>, S<G2>>,
>(&proof_str)
.unwrap();
let res = compressed_proof.verify(
Expand Down
7 changes: 1 addition & 6 deletions src/circom/circuit.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use bellperson::gadgets::num::AllocatedNum;
use bellpepper_core::{num::AllocatedNum, ConstraintSystem, LinearCombination, SynthesisError};
use nova_snark::traits::circuit::StepCircuit;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::str;

use bellperson::{ConstraintSystem, LinearCombination, SynthesisError};
use ff::PrimeField;

#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -160,8 +159,4 @@ impl<'a, Fr: PrimeField> StepCircuit<Fr> for CircomCircuit<Fr> {

z_out
}

fn output(&self, _z: &[Fr]) -> Vec<Fr> {
self.get_public_outputs()
}
}
1 change: 0 additions & 1 deletion src/circom/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use crate::circom::circuit::Constraint;
use byteorder::{LittleEndian, ReadBytesExt};
use ff::PrimeField;
use hex_literal::hex;
use nova_snark::traits::Group;
use std::{
collections::HashMap,
Expand Down
23 changes: 9 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::circom::reader::generate_witness_from_bin;
use circom::circuit::{CircomCircuit, R1CS};
use ff::Field;
use nova_snark::{
traits::{circuit::TrivialTestCircuit, Group},
traits::{circuit::TrivialCircuit, Group},
PublicParams, RecursiveSNARK,
};
use num_bigint::BigInt;
Expand All @@ -29,7 +29,7 @@ pub type F<G> = <G as Group>::Scalar;
pub type EE<G> = nova_snark::provider::ipa_pc::EvaluationEngine<G>;
pub type S<G> = nova_snark::spartan::snark::RelaxedR1CSSNARK<G, EE<G>>;
pub type C1<G> = CircomCircuit<<G as Group>::Scalar>;
pub type C2<G> = TrivialTestCircuit<<G as Group>::Scalar>;
pub type C2<G> = TrivialCircuit<<G as Group>::Scalar>;

#[derive(Clone)]
pub enum FileLocation {
Expand All @@ -46,9 +46,9 @@ where
r1cs,
witness: None,
};
let circuit_secondary = TrivialTestCircuit::default();
let circuit_secondary = TrivialCircuit::default();

PublicParams::setup(circuit_primary.clone(), circuit_secondary.clone())
PublicParams::setup(&circuit_primary, &circuit_secondary)
}

#[derive(Serialize, Deserialize)]
Expand Down Expand Up @@ -132,11 +132,7 @@ where
let input_json = serde_json::to_string(&input).unwrap();

if is_wasm {
generate_witness_from_wasm::<F<G1>>(
&witness_generator_file,
&input_json,
)
.await
generate_witness_from_wasm::<F<G1>>(&witness_generator_file, &input_json).await
} else {
let root = current_dir().unwrap(); // compute path only when generating witness from a binary
let witness_generator_output = root.join("circom_witness.wtns");
Expand Down Expand Up @@ -186,7 +182,7 @@ where
r1cs: r1cs.clone(),
witness: Some(witness_0),
};
let circuit_secondary = TrivialTestCircuit::default();
let circuit_secondary = TrivialCircuit::default();
let z0_secondary = vec![G2::Scalar::ZERO];

let mut recursive_snark = RecursiveSNARK::<G1, G2, C1<G1>, C2<G2>>::new(
Expand Down Expand Up @@ -242,7 +238,6 @@ where
G1: Group<Base = <G2 as Group>::Scalar>,
G2: Group<Base = <G1 as Group>::Scalar>,
{

let iteration_count = private_inputs.len();

let start_public_input_hex = start_public_input
Expand All @@ -262,7 +257,7 @@ where
r1cs: r1cs.clone(),
witness: Some(witness_0),
};
let circuit_secondary = TrivialTestCircuit::default();
let circuit_secondary = TrivialCircuit::default();
let z0_secondary = vec![G2::Scalar::ZERO];

let mut recursive_snark = RecursiveSNARK::<G1, G2, C1<G1>, C2<G2>>::new(
Expand Down Expand Up @@ -329,7 +324,7 @@ where
.map(|&x| format!("{:?}", x).strip_prefix("0x").unwrap().to_string())
.collect::<Vec<String>>();

let circuit_secondary = TrivialTestCircuit::default();
let circuit_secondary = TrivialCircuit::default();
let z0_secondary = vec![G2::Scalar::ZERO];

for i in 0..iteration_count {
Expand Down Expand Up @@ -391,7 +386,7 @@ where
.map(|&x| format!("{:?}", x).strip_prefix("0x").unwrap().to_string())
.collect::<Vec<String>>();

let circuit_secondary = TrivialTestCircuit::default();
let circuit_secondary = TrivialCircuit::default();
let z0_secondary = vec![G2::Scalar::ZERO];

for i in 0..iteration_count {
Expand Down
Loading