Skip to content

Commit

Permalink
cli opts
Browse files Browse the repository at this point in the history
  • Loading branch information
martyall committed May 30, 2024
1 parent c3df7a9 commit f166cd6
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -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=
28 changes: 23 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -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,
};
Expand All @@ -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;
Expand Down Expand Up @@ -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<String> = env::args().collect();

if args.len() != 2 {
panic!("Usage: {} <mode>", 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);
}

}
2 changes: 1 addition & 1 deletion wasm-solver/cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -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=

0 comments on commit f166cd6

Please sign in to comment.