diff --git a/librustzcash/include/librustzcash.h b/librustzcash/include/librustzcash.h index 6fa946912..4efb544d3 100644 --- a/librustzcash/include/librustzcash.h +++ b/librustzcash/include/librustzcash.h @@ -4,6 +4,12 @@ #include extern "C" { +#ifdef WIN32 + typedef uint16_t codeunit; +#else + typedef uint8_t codeunit; +#endif + void librustzcash_to_scalar(const unsigned char *input, unsigned char *result); void librustzcash_ask_to_ak(const unsigned char *ask, unsigned char *result); @@ -19,11 +25,14 @@ extern "C" { /// Loads the zk-SNARK parameters into memory and saves /// paths as necessary. Only called once. void librustzcash_init_zksnark_params( - const char* spend_path, + const codeunit* spend_path, + size_t spend_path_len, const char* spend_hash, - const char* output_path, + const codeunit* output_path, + size_t output_path_len, const char* output_hash, - const char* sprout_path, + const codeunit* sprout_path, + size_t sprout_path_len, const char* sprout_hash ); diff --git a/librustzcash/src/rustzcash.rs b/librustzcash/src/rustzcash.rs index 86cb65995..dd903bee2 100644 --- a/librustzcash/src/rustzcash.rs +++ b/librustzcash/src/rustzcash.rs @@ -48,8 +48,19 @@ use std::io::{self, BufReader}; use libc::{c_char, c_uchar, int64_t, size_t, uint32_t, uint64_t}; use std::ffi::CStr; use std::fs::File; +use std::path::{Path, PathBuf}; use std::slice; +#[cfg(not(target_os = "windows"))] +use std::ffi::OsStr; +#[cfg(not(target_os = "windows"))] +use std::os::unix::ffi::OsStrExt; + +#[cfg(target_os = "windows")] +use std::ffi::OsString; +#[cfg(target_os = "windows")] +use std::os::windows::ffi::OsStringExt; + use sapling_crypto::primitives::{ProofGenerationKey, ValueCommitment, ViewingKey}; pub mod equihash; @@ -67,7 +78,7 @@ static mut SPROUT_GROTH16_VK: Option> = None; static mut SAPLING_SPEND_PARAMS: Option> = None; static mut SAPLING_OUTPUT_PARAMS: Option> = None; -static mut SPROUT_GROTH16_PARAMS_PATH: Option = None; +static mut SPROUT_GROTH16_PARAMS_PATH: Option = None; fn is_small_order(p: &edwards::Point) -> bool { p.double(&JUBJUB).double(&JUBJUB).double(&JUBJUB) == edwards::Point::zero() @@ -114,13 +125,75 @@ fn fixed_scalar_mult(from: &[u8], p_g: FixedGenerators) -> edwards::Point