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

fix current_dir() call when using wasm generation #37

Merged
merged 3 commits into from
Sep 7, 2023
Merged
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 browser-test/test-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js",
"build:wasm": "cd ../circuits && wasm-pack build --target web --out-dir ../client/public/pkg"
"build:wasm": "cd ../ && wasm-pack build --target web --out-dir ./test-client/public/pkg"
},
"eslintConfig": {
"extends": [
Expand Down
2 changes: 0 additions & 2 deletions src/circom/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use ff::PrimeField;
use js_sys::Uint8Array;
use nova_snark::traits::Group;
use std::io::Cursor;
use std::path::Path;
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::JsFuture;

Expand Down Expand Up @@ -61,7 +60,6 @@ where
pub async fn generate_witness_from_wasm<Fr: PrimeField>(
witness_wasm: &FileLocation,
witness_input_json: &String,
_witness_output: &Path, // note: this is unused
) -> Vec<Fr> {
let witness_wasm = match witness_wasm {
FileLocation::PathBuf(_) => panic!("unreachable"),
Expand Down
10 changes: 2 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ async fn compute_witness<G1, G2>(
current_public_input: Vec<String>,
private_input: HashMap<String, Value>,
witness_generator_file: FileLocation,
witness_generator_output: &Path,
) -> Vec<<G1 as Group>::Scalar>
where
G1: Group<Base = <G2 as Group>::Scalar>,
Expand All @@ -136,10 +135,11 @@ where
generate_witness_from_wasm::<F<G1>>(
&witness_generator_file,
&input_json,
&witness_generator_output,
)
.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");
let witness_generator_file = match &witness_generator_file {
FileLocation::PathBuf(path) => path,
FileLocation::URL(_) => panic!("unreachable"),
Expand Down Expand Up @@ -242,8 +242,6 @@ where
G1: Group<Base = <G2 as Group>::Scalar>,
G2: Group<Base = <G1 as Group>::Scalar>,
{
let root = current_dir().unwrap();
let witness_generator_output = root.join("circom_witness.wtns");

let iteration_count = private_inputs.len();

Expand All @@ -257,7 +255,6 @@ where
current_public_input.clone(),
private_inputs[0].clone(),
witness_generator_file.clone(),
&witness_generator_output,
)
.await;

Expand All @@ -281,7 +278,6 @@ where
current_public_input.clone(),
private_inputs[i].clone(),
witness_generator_file.clone(),
&witness_generator_output,
)
.await;

Expand All @@ -305,7 +301,6 @@ where
);
assert!(res.is_ok());
}
fs::remove_file(witness_generator_output)?;

Ok(recursive_snark)
}
Expand Down Expand Up @@ -404,7 +399,6 @@ where
current_public_input.clone(),
private_inputs[i].clone(),
witness_generator_file.clone(),
&witness_generator_output,
)
.await;

Expand Down
Loading