diff --git a/zokrates_cli/tests/integration.rs b/zokrates_cli/tests/integration.rs index aff80b38..a6f7f4c6 100644 --- a/zokrates_cli/tests/integration.rs +++ b/zokrates_cli/tests/integration.rs @@ -67,7 +67,7 @@ mod integration { fs::create_dir(test_case_path).unwrap(); // prepare compile arguments - let mut compile = vec!["./target/debug/zokrates-cli", "compile", "-i", program_path.to_str().unwrap(), "-o", flattened_path.to_str().unwrap()]; + let mut compile = vec!["../target/debug/zokrates-cli", "compile", "-i", program_path.to_str().unwrap(), "-o", flattened_path.to_str().unwrap()]; if program_name.contains("sha_libsnark") { compile.push("--gadgets"); @@ -93,7 +93,7 @@ mod integration { assert_eq!(flattened_code, expected_flattened_code, "Flattening failed for {}\n\nExpected\n\n{}\n\nGot\n\n{}", program_path.to_str().unwrap(), expected_flattened_code.as_str(), flattened_code.as_str()); // SETUP - assert_cli::Assert::command(&["cargo", "run", "--", "setup", + assert_cli::Assert::command(&["../target/debug/zokrates-cli", "setup", "-i", flattened_path.to_str().unwrap(), "-p", proving_key_path.to_str().unwrap(), "-v", verification_key_path.to_str().unwrap(), @@ -102,7 +102,7 @@ mod integration { .unwrap(); // EXPORT-VERIFIER - assert_cli::Assert::command(&["cargo", "run", "--", "export-verifier", + assert_cli::Assert::command(&["../target/debug/zokrates-cli", "export-verifier", "-i", verification_key_path.to_str().unwrap(), "-o", verification_contract_path.to_str().unwrap()]) .succeeds() @@ -116,7 +116,7 @@ mod integration { _ => panic!(format!("Cannot read arguments. Check {}", arguments_path.to_str().unwrap())) }).collect(); - let mut compute = vec!["cargo", "run", "--", "compute-witness", + let mut compute = vec!["../target/debug/zokrates-cli", "compute-witness", "-i", flattened_path.to_str().unwrap(), "-o", witness_path.to_str().unwrap(), "-a"]; @@ -141,13 +141,14 @@ mod integration { for line in expected_witness.as_str().split("\n") { assert!(witness.contains(line), "Witness generation failed for {}\n\nLine \"{}\" not found in witness", program_path.to_str().unwrap(), line); - } + } // GENERATE-PROOF - assert_cli::Assert::command(&["cargo", "run", "--", "generate-proof", + assert_cli::Assert::command(&["../target/debug/zokrates-cli", "generate-proof", "-w", witness_path.to_str().unwrap(), "-p", proving_key_path.to_str().unwrap(), "-i", variable_information_path.to_str().unwrap()]) .succeeds() .unwrap(); + } } \ No newline at end of file diff --git a/zokrates_core/build.rs b/zokrates_core/build.rs index cc4ef681..332bf1eb 100644 --- a/zokrates_core/build.rs +++ b/zokrates_core/build.rs @@ -1,14 +1,11 @@ -#[cfg(feature = "libsnark")] -extern crate gcc; -#[cfg(feature = "libsnark")] -extern crate cmake; - -use std::path::Path; -use std::env; - fn main() { #[cfg(feature = "libsnark")] { + extern crate gcc; + extern crate cmake; + use std::path::Path; + use std::env; + let libsnark_source_path_string = env::var_os("LIBSNARK_SOURCE_PATH").expect("$LIBSNARK_SOURCE_PATH not set"); let libsnark_source_path = Path::new(&libsnark_source_path_string); diff --git a/zokrates_core/src/compile.rs b/zokrates_core/src/compile.rs index 4278436d..3b421dbe 100644 --- a/zokrates_core/src/compile.rs +++ b/zokrates_core/src/compile.rs @@ -15,10 +15,6 @@ use semantics::{self, Checker}; use optimizer::{Optimizer}; use flatten::Flattener; use std::io::{self}; - -#[cfg(feature = "libsnark")] -use libsnark::{get_sha256_constraints}; - use serde_json; use standard; @@ -109,6 +105,8 @@ fn compile_aux>(reader #[cfg(feature = "libsnark")] { + use libsnark::{get_sha256_constraints}; + if should_include_gadgets { // inject globals let r1cs: standard::R1CS = serde_json::from_str(&get_sha256_constraints()).unwrap(); diff --git a/zokrates_core/src/helpers.rs b/zokrates_core/src/helpers.rs index 6d1e1f58..cf367b5b 100644 --- a/zokrates_core/src/helpers.rs +++ b/zokrates_core/src/helpers.rs @@ -1,9 +1,5 @@ use std::fmt; use field::{Field}; - -#[cfg(feature = "libsnark")] -use libsnark::*; - use serde_json; use standard; @@ -83,6 +79,8 @@ impl Executable for LibsnarkGadgetHelper { #[cfg(feature = "libsnark")] { + use libsnark::*; + let witness_result: Result = serde_json::from_str(&get_sha256_witness(inputs)); if let Err(e) = witness_result {