diff --git a/README.md b/README.md index 7976d3c..a2e3ef5 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,19 @@ The example circuit is a simple adding circuit which is taken from the `nova-sco ``` ## Run Instructions + +### Native witness gen + +``` +> cabal run adder -- compile +> cargo run native +``` + +### WASM witness gen ``` > cabal run adder -- compile -> cargo run +> cd wasm-solver +> ./build-wash.sh +> cd .. +> cargo run wasm ``` \ No newline at end of file diff --git a/cabal.project b/cabal.project index 41c8184..07d520b 100644 --- a/cabal.project +++ b/cabal.project @@ -26,4 +26,4 @@ source-repository-package type: git location: https://github.com/l-adic/arithmetic-circuits.git tag: dd73d6557098956e8d83a02e8b669cc3372a3192 - --sha256: uW7yKNXRPks5EM/aaIwskCoxRf2maDLm/SKCeaATzWc= + --sha256: ngh2xhBSAu/2d4KlpCo5Aq8ezd6hX/MoNx26sLJzf0w= diff --git a/src/main.rs b/src/main.rs index f2c84df..75cf01b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, env::current_dir, time::Instant}; +use std::{collections::HashMap, env::current_dir, env, time::Instant}; use nova_scotia::{ circom::reader::load_r1cs, create_public_params, create_recursive_circuit, FileLocation, F, S, }; @@ -7,6 +7,8 @@ use nova_snark::{ }; use serde_json::json; + + fn run_test(circuit_filepath: String, witness_gen_filepath: String, circuit_bin_filepath: String) { type G1 = pasta_curves::pallas::Point; type G2 = pasta_curves::vesta::Point; @@ -111,10 +113,26 @@ fn run_test(circuit_filepath: String, witness_gen_filepath: String, circuit_bin_ assert!(res.is_ok()); } + fn main() { let circuit_filepath : String = "adder.r1cs".to_string(); - println!("Proving with native witness gen ..."); - run_test(circuit_filepath.clone(), "witness-generator.sh".to_string(), "./".to_string()); - println!("Proving with wasm witness gen..."); - run_test(circuit_filepath, "circuit.wasm".to_string(), "./".to_string()); + + let args: Vec = env::args().collect(); + + if args.len() != 2 { + panic!("Usage: {} ", args[0]); + } + + let mode = &args[1]; + + if mode == "wasm" { + println!("Proving with wasm witness gen..."); + run_test(circuit_filepath, "circuit.wasm".to_string(), "./".to_string()); + } else if mode == "native" { + println!("Proving with native witness gen ..."); + run_test(circuit_filepath.clone(), "witness-generator.sh".to_string(), "./".to_string()); + } else { + panic!("mode must be wasm or native. Got: {}", mode); + } + } diff --git a/wasm-solver/cabal.project b/wasm-solver/cabal.project index c499005..9e852e4 100644 --- a/wasm-solver/cabal.project +++ b/wasm-solver/cabal.project @@ -25,4 +25,4 @@ source-repository-package type: git location: https://github.com/l-adic/arithmetic-circuits.git tag: dd73d6557098956e8d83a02e8b669cc3372a3192 - --sha256: uW7yKNXRPks5EM/aaIwskCoxRf2maDLm/SKCeaATzWc= + --sha256: ngh2xhBSAu/2d4KlpCo5Aq8ezd6hX/MoNx26sLJzf0w=