From 443fe7d092a58ed83084854f647569fb1261ab03 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 3 Feb 2020 19:35:31 +0000 Subject: [PATCH 1/9] Bring in librustzcash crate Source: https://github.com/zcash/librustzcash.git Revision: a57dc7f47807ea50cb0a5deec9b84b3e7da11bc0 --- src/rust/Cargo.toml | 36 + src/rust/README.md | 25 + src/rust/include/librustzcash.h | 312 +++++++ src/rust/src/rustzcash.rs | 1223 ++++++++++++++++++++++++++ src/rust/src/tests/key_agreement.rs | 76 ++ src/rust/src/tests/key_components.rs | 731 +++++++++++++++ src/rust/src/tests/mod.rs | 96 ++ src/rust/src/tests/notes.rs | 673 ++++++++++++++ src/rust/src/tests/signatures.rs | 514 +++++++++++ 9 files changed, 3686 insertions(+) create mode 100644 src/rust/Cargo.toml create mode 100644 src/rust/README.md create mode 100644 src/rust/include/librustzcash.h create mode 100644 src/rust/src/rustzcash.rs create mode 100644 src/rust/src/tests/key_agreement.rs create mode 100644 src/rust/src/tests/key_components.rs create mode 100644 src/rust/src/tests/mod.rs create mode 100644 src/rust/src/tests/notes.rs create mode 100644 src/rust/src/tests/signatures.rs diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml new file mode 100644 index 000000000..432222b00 --- /dev/null +++ b/src/rust/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "librustzcash" +description = "Rust FFI used by the zcashd binary. Not an official API." +version = "0.2.0" +authors = [ + "Sean Bowe ", + "Jack Grigg ", + "Jay Graber ", + "Simon Liu " +] +homepage = "https://github.com/zcash/librustzcash" +repository = "https://github.com/zcash/librustzcash" +readme = "README.md" +license = "MIT OR Apache-2.0" +edition = "2018" + +[lib] +name = "rustzcash" +path = "src/rustzcash.rs" +crate-type = ["staticlib"] + +[dependencies] +bellman = { version = "0.2.0", path = "../bellman" } +blake2b_simd = "0.5" +blake2s_simd = "0.5" +ff = { version = "0.5.0", path = "../ff" } +libc = "0.2" +pairing = { version = "0.15.0", path = "../pairing" } +lazy_static = "1" +byteorder = "1" +rand_core = "0.5.1" +zcash_primitives = { version = "0.1.0", path = "../zcash_primitives" } +zcash_proofs = { version = "0.1.0", path = "../zcash_proofs" } + +[badges] +maintenance = { status = "deprecated" } diff --git a/src/rust/README.md b/src/rust/README.md new file mode 100644 index 000000000..0d6eeaed0 --- /dev/null +++ b/src/rust/README.md @@ -0,0 +1,25 @@ +# librustzcash + +`librustzcash` is an FFI library crate that exposes the Zcash Rust components to +the `zcashd` full node. + +The FFI API does not have any stability guarantees, and will change as required +by `zcashd`. + +## License + +Licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](../LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](../LICENSE-MIT) or http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally +submitted for inclusion in the work by you, as defined in the Apache-2.0 +license, shall be dual licensed as above, without any additional terms or +conditions. + diff --git a/src/rust/include/librustzcash.h b/src/rust/include/librustzcash.h new file mode 100644 index 000000000..a3ca5e8d3 --- /dev/null +++ b/src/rust/include/librustzcash.h @@ -0,0 +1,312 @@ +#ifndef LIBRUSTZCASH_INCLUDE_H_ +#define LIBRUSTZCASH_INCLUDE_H_ + +#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); + + void librustzcash_nsk_to_nk(const unsigned char *nsk, unsigned char *result); + + void librustzcash_crh_ivk(const unsigned char *ak, const unsigned char *nk, unsigned char *result); + + bool librustzcash_check_diversifier(const unsigned char *diversifier); + + bool librustzcash_ivk_to_pkd(const unsigned char *ivk, const unsigned char *diversifier, unsigned char *result); + + /// Loads the zk-SNARK parameters into memory and saves + /// paths as necessary. Only called once. + void librustzcash_init_zksnark_params( + const codeunit* spend_path, + size_t spend_path_len, + const char* spend_hash, + const codeunit* output_path, + size_t output_path_len, + const char* output_hash, + const codeunit* sprout_path, + size_t sprout_path_len, + const char* sprout_hash + ); + + /// Validates the provided Equihash solution against + /// the given parameters, input and nonce. + bool librustzcash_eh_isvalid( + uint32_t n, + uint32_t k, + const unsigned char* input, + size_t input_len, + const unsigned char* nonce, + size_t nonce_len, + const unsigned char* soln, + size_t soln_len + ); + + /// Writes the "uncommitted" note value for empty leaves + /// of the merkle tree. `result` must be a valid pointer + /// to 32 bytes which will be written. + void librustzcash_tree_uncommitted( + unsigned char *result + ); + + /// Computes a merkle tree hash for a given depth. + /// The `depth` parameter should not be larger than + /// 62. + /// + /// `a` and `b` each must be of length 32, and must each + /// be scalars of BLS12-381. + /// + /// The result of the merkle tree hash is placed in + /// `result`, which must also be of length 32. + void librustzcash_merkle_hash( + size_t depth, + const unsigned char *a, + const unsigned char *b, + unsigned char *result + ); + + /// Computes the signature for each Spend description, given the key + /// `ask`, the re-randomization `ar`, the 32-byte sighash `sighash`, + /// and an output `result` buffer of 64-bytes for the signature. + /// + /// This function will fail if the provided `ask` or `ar` are invalid. + bool librustzcash_sapling_spend_sig( + const unsigned char *ask, + const unsigned char *ar, + const unsigned char *sighash, + unsigned char *result + ); + + /// Creates a Sapling proving context. Please free this when you're done. + void * librustzcash_sapling_proving_ctx_init(); + + /// This function (using the proving context) constructs a Spend proof + /// given the necessary witness information. It outputs `cv` (the value + /// commitment) and `rk` (so that you don't have to compute it) along + /// with the proof. + bool librustzcash_sapling_spend_proof( + void *ctx, + const unsigned char *ak, + const unsigned char *nsk, + const unsigned char *diversifier, + const unsigned char *rcm, + const unsigned char *ar, + const uint64_t value, + const unsigned char *anchor, + const unsigned char *witness, + unsigned char *cv, + unsigned char *rk, + unsigned char *zkproof + ); + + /// This function (using the proving context) constructs an Output + /// proof given the necessary witness information. It outputs `cv` + /// and the `zkproof`. + bool librustzcash_sapling_output_proof( + void *ctx, + const unsigned char *esk, + const unsigned char *payment_address, + const unsigned char *rcm, + const uint64_t value, + unsigned char *cv, + unsigned char *zkproof + ); + + /// This function (using the proving context) constructs a binding + /// signature. You must provide the intended valueBalance so that + /// we can internally check consistency. + bool librustzcash_sapling_binding_sig( + const void *ctx, + int64_t valueBalance, + const unsigned char *sighash, + unsigned char *result + ); + + /// Frees a Sapling proving context returned from + /// `librustzcash_sapling_proving_ctx_init`. + void librustzcash_sapling_proving_ctx_free(void *); + + /// Creates a Sapling verification context. Please free this + /// when you're done. + void * librustzcash_sapling_verification_ctx_init(); + + /// Check the validity of a Sapling Spend description, + /// accumulating the value commitment into the context. + bool librustzcash_sapling_check_spend( + void *ctx, + const unsigned char *cv, + const unsigned char *anchor, + const unsigned char *nullifier, + const unsigned char *rk, + const unsigned char *zkproof, + const unsigned char *spendAuthSig, + const unsigned char *sighashValue + ); + + /// Check the validity of a Sapling Output description, + /// accumulating the value commitment into the context. + bool librustzcash_sapling_check_output( + void *ctx, + const unsigned char *cv, + const unsigned char *cm, + const unsigned char *ephemeralKey, + const unsigned char *zkproof + ); + + /// Finally checks the validity of the entire Sapling + /// transaction given valueBalance and the binding signature. + bool librustzcash_sapling_final_check( + void *ctx, + int64_t valueBalance, + const unsigned char *bindingSig, + const unsigned char *sighashValue + ); + + /// Frees a Sapling verification context returned from + /// `librustzcash_sapling_verification_ctx_init`. + void librustzcash_sapling_verification_ctx_free(void *); + + /// Compute a Sapling nullifier. + /// + /// The `diversifier` parameter must be 11 bytes in length. + /// The `pk_d`, `r`, `ak` and `nk` parameters must be of length 32. + /// The result is also of length 32 and placed in `result`. + /// Returns false if the diversifier or pk_d is not valid + bool librustzcash_sapling_compute_nf( + const unsigned char *diversifier, + const unsigned char *pk_d, + const uint64_t value, + const unsigned char *r, + const unsigned char *ak, + const unsigned char *nk, + const uint64_t position, + unsigned char *result + ); + + /// Compute a Sapling commitment. + /// + /// The `diversifier` parameter must be 11 bytes in length. + /// The `pk_d` and `r` parameters must be of length 32. + /// The result is also of length 32 and placed in `result`. + /// Returns false if the diversifier or pk_d is not valid + bool librustzcash_sapling_compute_cm( + const unsigned char *diversifier, + const unsigned char *pk_d, + const uint64_t value, + const unsigned char *r, + unsigned char *result + ); + + /// Compute [sk] [8] P for some 32-byte + /// point P, and 32-byte Fs. If P or sk + /// are invalid, returns false. Otherwise, + /// the result is written to the 32-byte + /// `result` buffer. + bool librustzcash_sapling_ka_agree( + const unsigned char *p, + const unsigned char *sk, + unsigned char *result + ); + + /// Compute g_d = GH(diversifier) and returns + /// false if the diversifier is invalid. + /// Computes [esk] g_d and writes the result + /// to the 32-byte `result` buffer. Returns + /// false if `esk` is not a valid scalar. + bool librustzcash_sapling_ka_derivepublic( + const unsigned char *diversifier, + const unsigned char *esk, + unsigned char *result + ); + + /// Generate uniformly random scalar in Jubjub. + /// The result is of length 32. + void librustzcash_sapling_generate_r( + unsigned char *result + ); + + /// Sprout JoinSplit proof generation. + void librustzcash_sprout_prove( + unsigned char *proof_out, + + const unsigned char *phi, + const unsigned char *rt, + const unsigned char *h_sig, + + const unsigned char *in_sk1, + uint64_t in_value1, + const unsigned char *in_rho1, + const unsigned char *in_r1, + const unsigned char *in_auth1, + + const unsigned char *in_sk2, + uint64_t in_value2, + const unsigned char *in_rho2, + const unsigned char *in_r2, + const unsigned char *in_auth2, + + const unsigned char *out_pk1, + uint64_t out_value1, + const unsigned char *out_r1, + + const unsigned char *out_pk2, + uint64_t out_value2, + const unsigned char *out_r2, + + uint64_t vpub_old, + uint64_t vpub_new + ); + + /// Sprout JoinSplit proof verification. + bool librustzcash_sprout_verify( + const unsigned char *proof, + const unsigned char *rt, + const unsigned char *h_sig, + const unsigned char *mac1, + const unsigned char *mac2, + const unsigned char *nf1, + const unsigned char *nf2, + const unsigned char *cm1, + const unsigned char *cm2, + uint64_t vpub_old, + uint64_t vpub_new + ); + + /// Derive the master ExtendedSpendingKey from a seed. + void librustzcash_zip32_xsk_master( + const unsigned char *seed, + size_t seedlen, + unsigned char *xsk_master + ); + + /// Derive a child ExtendedSpendingKey from a parent. + void librustzcash_zip32_xsk_derive( + const unsigned char *xsk_parent, + uint32_t i, + unsigned char *xsk_i + ); + + /// Derive a child ExtendedFullViewingKey from a parent. + bool librustzcash_zip32_xfvk_derive( + const unsigned char *xfvk_parent, + uint32_t i, + unsigned char *xfvk_i + ); + + /// Derive a PaymentAddress from an ExtendedFullViewingKey. + bool librustzcash_zip32_xfvk_address( + const unsigned char *xfvk, + const unsigned char *j, + unsigned char *j_ret, + unsigned char *addr_ret + ); +} + +#endif // LIBRUSTZCASH_INCLUDE_H_ diff --git a/src/rust/src/rustzcash.rs b/src/rust/src/rustzcash.rs new file mode 100644 index 000000000..fc8d3ef90 --- /dev/null +++ b/src/rust/src/rustzcash.rs @@ -0,0 +1,1223 @@ +// Catch documentation errors caused by code changes. +#![deny(intra_doc_link_resolution_failure)] + +use lazy_static; + +use ff::{PrimeField, PrimeFieldRepr}; +use pairing::bls12_381::{Bls12, Fr, FrRepr}; + +use zcash_primitives::{ + constants::CRH_IVK_PERSONALIZATION, + jubjub::{ + edwards, + fs::{Fs, FsRepr}, + FixedGenerators, JubjubEngine, JubjubParams, PrimeOrder, ToUniform, Unknown, + }, +}; + +use zcash_proofs::circuit::sapling::TREE_DEPTH as SAPLING_TREE_DEPTH; +use zcash_proofs::circuit::sprout::{self, TREE_DEPTH as SPROUT_TREE_DEPTH}; + +use bellman::gadgets::multipack; +use bellman::groth16::{ + create_random_proof, verify_proof, Parameters, PreparedVerifyingKey, Proof, +}; + +use blake2s_simd::Params as Blake2sParams; + +use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; + +use rand_core::{OsRng, RngCore}; +use std::io::BufReader; + +use libc::{c_char, c_uchar, size_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 zcash_primitives::{ + block::equihash, + merkle_tree::CommitmentTreeWitness, + note_encryption::sapling_ka_agree, + primitives::{Diversifier, Note, PaymentAddress, ProofGenerationKey, ViewingKey}, + redjubjub::{self, Signature}, + sapling::{merkle_hash, spend_sig}, + transaction::components::Amount, + zip32, JUBJUB, +}; +use zcash_proofs::{ + load_parameters, + sapling::{SaplingProvingContext, SaplingVerificationContext}, +}; + +#[cfg(test)] +mod tests; + +static mut SAPLING_SPEND_VK: Option> = None; +static mut SAPLING_OUTPUT_VK: Option> = None; +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; + +/// Writes an FrRepr to [u8] of length 32 +fn write_le(f: FrRepr, to: &mut [u8]) { + assert_eq!(to.len(), 32); + + f.write_le(to).expect("length is 32 bytes"); +} + +/// Reads an FrRepr from a [u8] of length 32. +/// This will panic (abort) if length provided is +/// not correct. +fn read_le(from: &[u8]) -> FrRepr { + assert_eq!(from.len(), 32); + + let mut f = FrRepr::default(); + f.read_le(from).expect("length is 32 bytes"); + + f +} + +/// Reads an FsRepr from [u8] of length 32 +/// This will panic (abort) if length provided is +/// not correct +fn read_fs(from: &[u8]) -> FsRepr { + assert_eq!(from.len(), 32); + + let mut f = <::Fs as PrimeField>::Repr::default(); + f.read_le(from).expect("length is 32 bytes"); + + f +} + +/// Reads an FsRepr from [u8] of length 32 +/// and multiplies it by the given base. +/// This will panic (abort) if length provided is +/// not correct +fn fixed_scalar_mult(from: &[u8], p_g: FixedGenerators) -> edwards::Point { + let f = read_fs(from); + + JUBJUB.generator(p_g).mul(f, &JUBJUB) +} + +#[cfg(not(target_os = "windows"))] +#[no_mangle] +pub extern "system" fn librustzcash_init_zksnark_params( + spend_path: *const u8, + spend_path_len: usize, + spend_hash: *const c_char, + output_path: *const u8, + output_path_len: usize, + output_hash: *const c_char, + sprout_path: *const u8, + sprout_path_len: usize, + sprout_hash: *const c_char, +) { + let spend_path = Path::new(OsStr::from_bytes(unsafe { + slice::from_raw_parts(spend_path, spend_path_len) + })); + let output_path = Path::new(OsStr::from_bytes(unsafe { + slice::from_raw_parts(output_path, output_path_len) + })); + let sprout_path = if sprout_path.is_null() { + None + } else { + Some(Path::new(OsStr::from_bytes(unsafe { + slice::from_raw_parts(sprout_path, sprout_path_len) + }))) + }; + + init_zksnark_params( + spend_path, + spend_hash, + output_path, + output_hash, + sprout_path, + sprout_hash, + ) +} + +#[cfg(target_os = "windows")] +#[no_mangle] +pub extern "system" fn librustzcash_init_zksnark_params( + spend_path: *const u16, + spend_path_len: usize, + spend_hash: *const c_char, + output_path: *const u16, + output_path_len: usize, + output_hash: *const c_char, + sprout_path: *const u16, + sprout_path_len: usize, + sprout_hash: *const c_char, +) { + let spend_path = + OsString::from_wide(unsafe { slice::from_raw_parts(spend_path, spend_path_len) }); + let output_path = + OsString::from_wide(unsafe { slice::from_raw_parts(output_path, output_path_len) }); + let sprout_path = if sprout_path.is_null() { + None + } else { + Some(OsString::from_wide(unsafe { + slice::from_raw_parts(sprout_path, sprout_path_len) + })) + }; + + init_zksnark_params( + Path::new(&spend_path), + spend_hash, + Path::new(&output_path), + output_hash, + sprout_path.as_ref().map(|p| Path::new(p)), + sprout_hash, + ) +} + +fn init_zksnark_params( + spend_path: &Path, + spend_hash: *const c_char, + output_path: &Path, + output_hash: *const c_char, + sprout_path: Option<&Path>, + sprout_hash: *const c_char, +) { + // Initialize jubjub parameters here + lazy_static::initialize(&JUBJUB); + + let spend_hash = unsafe { CStr::from_ptr(spend_hash) } + .to_str() + .expect("hash should be a valid string"); + + let output_hash = unsafe { CStr::from_ptr(output_hash) } + .to_str() + .expect("hash should be a valid string"); + + let sprout_hash = if sprout_path.is_none() { + None + } else { + Some( + unsafe { CStr::from_ptr(sprout_hash) } + .to_str() + .expect("hash should be a valid string"), + ) + }; + + // Load params + let (spend_params, spend_vk, output_params, output_vk, sprout_vk) = load_parameters( + spend_path, + spend_hash, + output_path, + output_hash, + sprout_path, + sprout_hash, + ); + + // Caller is responsible for calling this function once, so + // these global mutations are safe. + unsafe { + SAPLING_SPEND_PARAMS = Some(spend_params); + SAPLING_OUTPUT_PARAMS = Some(output_params); + SPROUT_GROTH16_PARAMS_PATH = sprout_path.map(|p| p.to_owned()); + + SAPLING_SPEND_VK = Some(spend_vk); + SAPLING_OUTPUT_VK = Some(output_vk); + SPROUT_GROTH16_VK = sprout_vk; + } +} + +#[no_mangle] +pub extern "system" fn librustzcash_tree_uncommitted(result: *mut [c_uchar; 32]) { + let tmp = Note::::uncommitted().into_repr(); + + // Should be okay, caller is responsible for ensuring the pointer + // is a valid pointer to 32 bytes that can be mutated. + let result = unsafe { &mut *result }; + + write_le(tmp, &mut result[..]); +} + +#[no_mangle] +pub extern "system" fn librustzcash_merkle_hash( + depth: size_t, + a: *const [c_uchar; 32], + b: *const [c_uchar; 32], + result: *mut [c_uchar; 32], +) { + // Should be okay, because caller is responsible for ensuring + // the pointer is a valid pointer to 32 bytes, and that is the + // size of the representation + let a_repr = read_le(unsafe { &(&*a)[..] }); + + // Should be okay, because caller is responsible for ensuring + // the pointer is a valid pointer to 32 bytes, and that is the + // size of the representation + let b_repr = read_le(unsafe { &(&*b)[..] }); + + let tmp = merkle_hash(depth, &a_repr, &b_repr); + + // Should be okay, caller is responsible for ensuring the pointer + // is a valid pointer to 32 bytes that can be mutated. + let result = unsafe { &mut *result }; + + write_le(tmp, &mut result[..]); +} + +#[no_mangle] // ToScalar +pub extern "system" fn librustzcash_to_scalar( + input: *const [c_uchar; 64], + result: *mut [c_uchar; 32], +) { + // Should be okay, because caller is responsible for ensuring + // the pointer is a valid pointer to 32 bytes, and that is the + // size of the representation + let scalar = ::Fs::to_uniform(unsafe { &(&*input)[..] }).into_repr(); + + let result = unsafe { &mut *result }; + + scalar + .write_le(&mut result[..]) + .expect("length is 32 bytes"); +} + +#[no_mangle] +pub extern "system" fn librustzcash_ask_to_ak( + ask: *const [c_uchar; 32], + result: *mut [c_uchar; 32], +) { + let ask = unsafe { &*ask }; + let ak = fixed_scalar_mult(ask, FixedGenerators::SpendingKeyGenerator); + + let result = unsafe { &mut *result }; + + ak.write(&mut result[..]).expect("length is 32 bytes"); +} + +#[no_mangle] +pub extern "system" fn librustzcash_nsk_to_nk( + nsk: *const [c_uchar; 32], + result: *mut [c_uchar; 32], +) { + let nsk = unsafe { &*nsk }; + let nk = fixed_scalar_mult(nsk, FixedGenerators::ProofGenerationKey); + + let result = unsafe { &mut *result }; + + nk.write(&mut result[..]).expect("length is 32 bytes"); +} + +#[no_mangle] +pub extern "system" fn librustzcash_crh_ivk( + ak: *const [c_uchar; 32], + nk: *const [c_uchar; 32], + result: *mut [c_uchar; 32], +) { + let ak = unsafe { &*ak }; + let nk = unsafe { &*nk }; + + let mut h = Blake2sParams::new() + .hash_length(32) + .personal(CRH_IVK_PERSONALIZATION) + .to_state(); + h.update(ak); + h.update(nk); + let mut h = h.finalize().as_ref().to_vec(); + + // Drop the last five bits, so it can be interpreted as a scalar. + h[31] &= 0b0000_0111; + + let result = unsafe { &mut *result }; + + result.copy_from_slice(&h); +} + +#[no_mangle] +pub extern "system" fn librustzcash_check_diversifier(diversifier: *const [c_uchar; 11]) -> bool { + let diversifier = Diversifier(unsafe { *diversifier }); + diversifier.g_d::(&JUBJUB).is_some() +} + +#[no_mangle] +pub extern "system" fn librustzcash_ivk_to_pkd( + ivk: *const [c_uchar; 32], + diversifier: *const [c_uchar; 11], + result: *mut [c_uchar; 32], +) -> bool { + let ivk = read_fs(unsafe { &*ivk }); + let diversifier = Diversifier(unsafe { *diversifier }); + if let Some(g_d) = diversifier.g_d::(&JUBJUB) { + let pk_d = g_d.mul(ivk, &JUBJUB); + + let result = unsafe { &mut *result }; + + pk_d.write(&mut result[..]).expect("length is 32 bytes"); + + true + } else { + false + } +} + +/// Test generation of commitment randomness +#[test] +fn test_gen_r() { + let mut r1 = [0u8; 32]; + let mut r2 = [0u8; 32]; + + // Verify different r values are generated + librustzcash_sapling_generate_r(&mut r1); + librustzcash_sapling_generate_r(&mut r2); + assert_ne!(r1, r2); + + // Verify r values are valid in the field + let mut repr = FsRepr::default(); + repr.read_le(&r1[..]).expect("length is not 32 bytes"); + let _ = Fs::from_repr(repr).unwrap(); + repr.read_le(&r2[..]).expect("length is not 32 bytes"); + let _ = Fs::from_repr(repr).unwrap(); +} + +/// Return 32 byte random scalar, uniformly. +#[no_mangle] +pub extern "system" fn librustzcash_sapling_generate_r(result: *mut [c_uchar; 32]) { + // create random 64 byte buffer + let mut rng = OsRng; + let mut buffer = [0u8; 64]; + rng.fill_bytes(&mut buffer); + + // reduce to uniform value + let r = ::Fs::to_uniform(&buffer[..]); + let result = unsafe { &mut *result }; + r.into_repr() + .write_le(&mut result[..]) + .expect("result must be 32 bytes"); +} + +// Private utility function to get Note from C parameters +fn priv_get_note( + diversifier: *const [c_uchar; 11], + pk_d: *const [c_uchar; 32], + value: u64, + r: *const [c_uchar; 32], +) -> Result, ()> { + let diversifier = Diversifier(unsafe { *diversifier }); + let g_d = match diversifier.g_d::(&JUBJUB) { + Some(g_d) => g_d, + None => return Err(()), + }; + + let pk_d = match edwards::Point::::read(&(unsafe { &*pk_d })[..], &JUBJUB) { + Ok(p) => p, + Err(_) => return Err(()), + }; + + let pk_d = match pk_d.as_prime_order(&JUBJUB) { + Some(pk_d) => pk_d, + None => return Err(()), + }; + + // Deserialize randomness + let r = match Fs::from_repr(read_fs(&(unsafe { &*r })[..])) { + Ok(r) => r, + Err(_) => return Err(()), + }; + + let note = Note { + value, + g_d, + pk_d, + r, + }; + + Ok(note) +} + +/// Compute Sapling note nullifier. +#[no_mangle] +pub extern "system" fn librustzcash_sapling_compute_nf( + diversifier: *const [c_uchar; 11], + pk_d: *const [c_uchar; 32], + value: u64, + r: *const [c_uchar; 32], + ak: *const [c_uchar; 32], + nk: *const [c_uchar; 32], + position: u64, + result: *mut [c_uchar; 32], +) -> bool { + let note = match priv_get_note(diversifier, pk_d, value, r) { + Ok(p) => p, + Err(_) => return false, + }; + + let ak = match edwards::Point::::read(&(unsafe { &*ak })[..], &JUBJUB) { + Ok(p) => p, + Err(_) => return false, + }; + + let ak = match ak.as_prime_order(&JUBJUB) { + Some(ak) => ak, + None => return false, + }; + + let nk = match edwards::Point::::read(&(unsafe { &*nk })[..], &JUBJUB) { + Ok(p) => p, + Err(_) => return false, + }; + + let nk = match nk.as_prime_order(&JUBJUB) { + Some(nk) => nk, + None => return false, + }; + + let vk = ViewingKey { ak, nk }; + let nf = note.nf(&vk, position, &JUBJUB); + let result = unsafe { &mut *result }; + result.copy_from_slice(&nf); + + true +} + +/// Compute Sapling note commitment. +#[no_mangle] +pub extern "system" fn librustzcash_sapling_compute_cm( + diversifier: *const [c_uchar; 11], + pk_d: *const [c_uchar; 32], + value: u64, + r: *const [c_uchar; 32], + result: *mut [c_uchar; 32], +) -> bool { + let note = match priv_get_note(diversifier, pk_d, value, r) { + Ok(p) => p, + Err(_) => return false, + }; + + let result = unsafe { &mut *result }; + write_le(note.cm(&JUBJUB).into_repr(), &mut result[..]); + + true +} + +#[no_mangle] +pub extern "system" fn librustzcash_sapling_ka_agree( + p: *const [c_uchar; 32], + sk: *const [c_uchar; 32], + result: *mut [c_uchar; 32], +) -> bool { + // Deserialize p + let p = match edwards::Point::::read(&(unsafe { &*p })[..], &JUBJUB) { + Ok(p) => p, + Err(_) => return false, + }; + + // Deserialize sk + let sk = match Fs::from_repr(read_fs(&(unsafe { &*sk })[..])) { + Ok(p) => p, + Err(_) => return false, + }; + + // Compute key agreement + let ka = sapling_ka_agree(&sk, &p); + + // Produce result + let result = unsafe { &mut *result }; + ka.write(&mut result[..]).expect("length is not 32 bytes"); + + true +} + +#[no_mangle] +pub extern "system" fn librustzcash_sapling_ka_derivepublic( + diversifier: *const [c_uchar; 11], + esk: *const [c_uchar; 32], + result: *mut [c_uchar; 32], +) -> bool { + let diversifier = Diversifier(unsafe { *diversifier }); + + // Compute g_d from the diversifier + let g_d = match diversifier.g_d::(&JUBJUB) { + Some(g) => g, + None => return false, + }; + + // Deserialize esk + let esk = match Fs::from_repr(read_fs(&(unsafe { &*esk })[..])) { + Ok(p) => p, + Err(_) => return false, + }; + + let p = g_d.mul(esk, &JUBJUB); + + let result = unsafe { &mut *result }; + p.write(&mut result[..]).expect("length is not 32 bytes"); + + true +} + +#[no_mangle] +pub extern "system" fn librustzcash_eh_isvalid( + n: u32, + k: u32, + input: *const c_uchar, + input_len: size_t, + nonce: *const c_uchar, + nonce_len: size_t, + soln: *const c_uchar, + soln_len: size_t, +) -> bool { + if (k >= n) || (n % 8 != 0) || (soln_len != (1 << k) * ((n / (k + 1)) as usize + 1) / 8) { + return false; + } + let rs_input = unsafe { slice::from_raw_parts(input, input_len) }; + let rs_nonce = unsafe { slice::from_raw_parts(nonce, nonce_len) }; + let rs_soln = unsafe { slice::from_raw_parts(soln, soln_len) }; + equihash::is_valid_solution(n, k, rs_input, rs_nonce, rs_soln) +} + +#[no_mangle] +pub extern "system" fn librustzcash_sapling_verification_ctx_init( +) -> *mut SaplingVerificationContext { + let ctx = Box::new(SaplingVerificationContext::new()); + + Box::into_raw(ctx) +} + +#[no_mangle] +pub extern "system" fn librustzcash_sapling_verification_ctx_free( + ctx: *mut SaplingVerificationContext, +) { + drop(unsafe { Box::from_raw(ctx) }); +} + +const GROTH_PROOF_SIZE: usize = 48 // π_A + + 96 // π_B + + 48; // π_C + +#[no_mangle] +pub extern "system" fn librustzcash_sapling_check_spend( + ctx: *mut SaplingVerificationContext, + cv: *const [c_uchar; 32], + anchor: *const [c_uchar; 32], + nullifier: *const [c_uchar; 32], + rk: *const [c_uchar; 32], + zkproof: *const [c_uchar; GROTH_PROOF_SIZE], + spend_auth_sig: *const [c_uchar; 64], + sighash_value: *const [c_uchar; 32], +) -> bool { + // Deserialize the value commitment + let cv = match edwards::Point::::read(&(unsafe { &*cv })[..], &JUBJUB) { + Ok(p) => p, + Err(_) => return false, + }; + + // Deserialize the anchor, which should be an element + // of Fr. + let anchor = match Fr::from_repr(read_le(&(unsafe { &*anchor })[..])) { + Ok(a) => a, + Err(_) => return false, + }; + + // Deserialize rk + let rk = match redjubjub::PublicKey::::read(&(unsafe { &*rk })[..], &JUBJUB) { + Ok(p) => p, + Err(_) => return false, + }; + + // Deserialize the signature + let spend_auth_sig = match Signature::read(&(unsafe { &*spend_auth_sig })[..]) { + Ok(sig) => sig, + Err(_) => return false, + }; + + // Deserialize the proof + let zkproof = match Proof::::read(&(unsafe { &*zkproof })[..]) { + Ok(p) => p, + Err(_) => return false, + }; + + unsafe { &mut *ctx }.check_spend( + cv, + anchor, + unsafe { &*nullifier }, + rk, + unsafe { &*sighash_value }, + spend_auth_sig, + zkproof, + unsafe { SAPLING_SPEND_VK.as_ref() }.unwrap(), + &JUBJUB, + ) +} + +#[no_mangle] +pub extern "system" fn librustzcash_sapling_check_output( + ctx: *mut SaplingVerificationContext, + cv: *const [c_uchar; 32], + cm: *const [c_uchar; 32], + epk: *const [c_uchar; 32], + zkproof: *const [c_uchar; GROTH_PROOF_SIZE], +) -> bool { + // Deserialize the value commitment + let cv = match edwards::Point::::read(&(unsafe { &*cv })[..], &JUBJUB) { + Ok(p) => p, + Err(_) => return false, + }; + + // Deserialize the commitment, which should be an element + // of Fr. + let cm = match Fr::from_repr(read_le(&(unsafe { &*cm })[..])) { + Ok(a) => a, + Err(_) => return false, + }; + + // Deserialize the ephemeral key + let epk = match edwards::Point::::read(&(unsafe { &*epk })[..], &JUBJUB) { + Ok(p) => p, + Err(_) => return false, + }; + + // Deserialize the proof + let zkproof = match Proof::::read(&(unsafe { &*zkproof })[..]) { + Ok(p) => p, + Err(_) => return false, + }; + + unsafe { &mut *ctx }.check_output( + cv, + cm, + epk, + zkproof, + unsafe { SAPLING_OUTPUT_VK.as_ref() }.unwrap(), + &JUBJUB, + ) +} + +#[no_mangle] +pub extern "system" fn librustzcash_sapling_final_check( + ctx: *mut SaplingVerificationContext, + value_balance: i64, + binding_sig: *const [c_uchar; 64], + sighash_value: *const [c_uchar; 32], +) -> bool { + let value_balance = match Amount::from_i64(value_balance) { + Ok(vb) => vb, + Err(()) => return false, + }; + + // Deserialize the signature + let binding_sig = match Signature::read(&(unsafe { &*binding_sig })[..]) { + Ok(sig) => sig, + Err(_) => return false, + }; + + unsafe { &*ctx }.final_check( + value_balance, + unsafe { &*sighash_value }, + binding_sig, + &JUBJUB, + ) +} + +#[no_mangle] +pub extern "system" fn librustzcash_sprout_prove( + proof_out: *mut [c_uchar; GROTH_PROOF_SIZE], + + phi: *const [c_uchar; 32], + rt: *const [c_uchar; 32], + h_sig: *const [c_uchar; 32], + + // First input + in_sk1: *const [c_uchar; 32], + in_value1: u64, + in_rho1: *const [c_uchar; 32], + in_r1: *const [c_uchar; 32], + in_auth1: *const [c_uchar; 1 + 33 * SPROUT_TREE_DEPTH + 8], + + // Second input + in_sk2: *const [c_uchar; 32], + in_value2: u64, + in_rho2: *const [c_uchar; 32], + in_r2: *const [c_uchar; 32], + in_auth2: *const [c_uchar; 1 + 33 * SPROUT_TREE_DEPTH + 8], + + // First output + out_pk1: *const [c_uchar; 32], + out_value1: u64, + out_r1: *const [c_uchar; 32], + + // Second output + out_pk2: *const [c_uchar; 32], + out_value2: u64, + out_r2: *const [c_uchar; 32], + + // Public value + vpub_old: u64, + vpub_new: u64, +) { + let phi = unsafe { *phi }; + let rt = unsafe { *rt }; + let h_sig = unsafe { *h_sig }; + let in_sk1 = unsafe { *in_sk1 }; + let in_rho1 = unsafe { *in_rho1 }; + let in_r1 = unsafe { *in_r1 }; + let in_auth1 = unsafe { *in_auth1 }; + let in_sk2 = unsafe { *in_sk2 }; + let in_rho2 = unsafe { *in_rho2 }; + let in_r2 = unsafe { *in_r2 }; + let in_auth2 = unsafe { *in_auth2 }; + let out_pk1 = unsafe { *out_pk1 }; + let out_r1 = unsafe { *out_r1 }; + let out_pk2 = unsafe { *out_pk2 }; + let out_r2 = unsafe { *out_r2 }; + + let mut inputs = Vec::with_capacity(2); + { + let mut handle_input = |sk, value, rho, r, mut auth: &[u8]| { + let value = Some(value); + let rho = Some(sprout::UniqueRandomness(rho)); + let r = Some(sprout::CommitmentRandomness(r)); + let a_sk = Some(sprout::SpendingKey(sk)); + + // skip the first byte + assert_eq!(auth[0], SPROUT_TREE_DEPTH as u8); + auth = &auth[1..]; + + let mut auth_path = [None; SPROUT_TREE_DEPTH]; + for i in (0..SPROUT_TREE_DEPTH).rev() { + // skip length of inner vector + assert_eq!(auth[0], 32); + auth = &auth[1..]; + + let mut sibling = [0u8; 32]; + sibling.copy_from_slice(&auth[0..32]); + auth = &auth[32..]; + + auth_path[i] = Some((sibling, false)); + } + + let mut position = auth + .read_u64::() + .expect("should have had index at the end"); + + for i in 0..SPROUT_TREE_DEPTH { + auth_path[i].as_mut().map(|p| p.1 = (position & 1) == 1); + + position >>= 1; + } + + inputs.push(sprout::JSInput { + value: value, + a_sk: a_sk, + rho: rho, + r: r, + auth_path: auth_path, + }); + }; + + handle_input(in_sk1, in_value1, in_rho1, in_r1, &in_auth1[..]); + handle_input(in_sk2, in_value2, in_rho2, in_r2, &in_auth2[..]); + } + + let mut outputs = Vec::with_capacity(2); + { + let mut handle_output = |a_pk, value, r| { + outputs.push(sprout::JSOutput { + value: Some(value), + a_pk: Some(sprout::PayingKey(a_pk)), + r: Some(sprout::CommitmentRandomness(r)), + }); + }; + + handle_output(out_pk1, out_value1, out_r1); + handle_output(out_pk2, out_value2, out_r2); + } + + let js = sprout::JoinSplit { + vpub_old: Some(vpub_old), + vpub_new: Some(vpub_new), + h_sig: Some(h_sig), + phi: Some(phi), + inputs: inputs, + outputs: outputs, + rt: Some(rt), + }; + + // Load parameters from disk + let sprout_fs = File::open( + unsafe { &SPROUT_GROTH16_PARAMS_PATH } + .as_ref() + .expect("parameters should have been initialized"), + ) + .expect("couldn't load Sprout groth16 parameters file"); + + let mut sprout_fs = BufReader::with_capacity(1024 * 1024, sprout_fs); + + let params = Parameters::::read(&mut sprout_fs, false) + .expect("couldn't deserialize Sprout JoinSplit parameters file"); + + drop(sprout_fs); + + // Initialize secure RNG + let mut rng = OsRng; + + let proof = create_random_proof(js, ¶ms, &mut rng).expect("proving should not fail"); + + proof + .write(&mut (unsafe { &mut *proof_out })[..]) + .expect("should be able to serialize a proof"); +} + +#[no_mangle] +pub extern "system" fn librustzcash_sprout_verify( + proof: *const [c_uchar; GROTH_PROOF_SIZE], + rt: *const [c_uchar; 32], + h_sig: *const [c_uchar; 32], + mac1: *const [c_uchar; 32], + mac2: *const [c_uchar; 32], + nf1: *const [c_uchar; 32], + nf2: *const [c_uchar; 32], + cm1: *const [c_uchar; 32], + cm2: *const [c_uchar; 32], + vpub_old: u64, + vpub_new: u64, +) -> bool { + // Prepare the public input for the verifier + let mut public_input = Vec::with_capacity((32 * 8) + (8 * 2)); + public_input.extend(unsafe { &(&*rt)[..] }); + public_input.extend(unsafe { &(&*h_sig)[..] }); + public_input.extend(unsafe { &(&*nf1)[..] }); + public_input.extend(unsafe { &(&*mac1)[..] }); + public_input.extend(unsafe { &(&*nf2)[..] }); + public_input.extend(unsafe { &(&*mac2)[..] }); + public_input.extend(unsafe { &(&*cm1)[..] }); + public_input.extend(unsafe { &(&*cm2)[..] }); + public_input.write_u64::(vpub_old).unwrap(); + public_input.write_u64::(vpub_new).unwrap(); + + let public_input = multipack::bytes_to_bits(&public_input); + let public_input = multipack::compute_multipacking::(&public_input); + + let proof = match Proof::read(unsafe { &(&*proof)[..] }) { + Ok(p) => p, + Err(_) => return false, + }; + + // Verify the proof + match verify_proof( + unsafe { SPROUT_GROTH16_VK.as_ref() }.expect("parameters should have been initialized"), + &proof, + &public_input[..], + ) { + // No error, and proof verification successful + Ok(true) => true, + + // Any other case + _ => false, + } +} + +#[no_mangle] +pub extern "system" fn librustzcash_sapling_output_proof( + ctx: *mut SaplingProvingContext, + esk: *const [c_uchar; 32], + payment_address: *const [c_uchar; 43], + rcm: *const [c_uchar; 32], + value: u64, + cv: *mut [c_uchar; 32], + zkproof: *mut [c_uchar; GROTH_PROOF_SIZE], +) -> bool { + // Grab `esk`, which the caller should have constructed for the DH key exchange. + let esk = match Fs::from_repr(read_fs(&(unsafe { &*esk })[..])) { + Ok(p) => p, + Err(_) => return false, + }; + + // Grab the payment address from the caller + let payment_address = + match PaymentAddress::::from_bytes(unsafe { &*payment_address }, &JUBJUB) { + Some(pa) => pa, + None => return false, + }; + + // The caller provides the commitment randomness for the output note + let rcm = match Fs::from_repr(read_fs(&(unsafe { &*rcm })[..])) { + Ok(p) => p, + Err(_) => return false, + }; + + // Create proof + let (proof, value_commitment) = unsafe { &mut *ctx }.output_proof( + esk, + payment_address, + rcm, + value, + unsafe { SAPLING_OUTPUT_PARAMS.as_ref() }.unwrap(), + &JUBJUB, + ); + + // Write the proof out to the caller + proof + .write(&mut (unsafe { &mut *zkproof })[..]) + .expect("should be able to serialize a proof"); + + // Write the value commitment to the caller + value_commitment + .write(&mut (unsafe { &mut *cv })[..]) + .expect("should be able to serialize rcv"); + + true +} + +#[no_mangle] +pub extern "system" fn librustzcash_sapling_spend_sig( + ask: *const [c_uchar; 32], + ar: *const [c_uchar; 32], + sighash: *const [c_uchar; 32], + result: *mut [c_uchar; 64], +) -> bool { + // The caller provides the re-randomization of `ak`. + let ar = match Fs::from_repr(read_fs(&(unsafe { &*ar })[..])) { + Ok(p) => p, + Err(_) => return false, + }; + + // The caller provides `ask`, the spend authorizing key. + let ask = match redjubjub::PrivateKey::::read(&(unsafe { &*ask })[..]) { + Ok(p) => p, + Err(_) => return false, + }; + + // Initialize secure RNG + let mut rng = OsRng; + + // Do the signing + let sig = spend_sig(ask, ar, unsafe { &*sighash }, &mut rng, &JUBJUB); + + // Write out the signature + sig.write(&mut (unsafe { &mut *result })[..]) + .expect("result should be 64 bytes"); + + true +} + +#[no_mangle] +pub extern "system" fn librustzcash_sapling_binding_sig( + ctx: *const SaplingProvingContext, + value_balance: i64, + sighash: *const [c_uchar; 32], + result: *mut [c_uchar; 64], +) -> bool { + let value_balance = match Amount::from_i64(value_balance) { + Ok(vb) => vb, + Err(()) => return false, + }; + + // Sign + let sig = match unsafe { &*ctx }.binding_sig(value_balance, unsafe { &*sighash }, &JUBJUB) { + Ok(s) => s, + Err(_) => return false, + }; + + // Write out signature + sig.write(&mut (unsafe { &mut *result })[..]) + .expect("result should be 64 bytes"); + + true +} + +#[no_mangle] +pub extern "system" fn librustzcash_sapling_spend_proof( + ctx: *mut SaplingProvingContext, + ak: *const [c_uchar; 32], + nsk: *const [c_uchar; 32], + diversifier: *const [c_uchar; 11], + rcm: *const [c_uchar; 32], + ar: *const [c_uchar; 32], + value: u64, + anchor: *const [c_uchar; 32], + witness: *const [c_uchar; 1 + 33 * SAPLING_TREE_DEPTH + 8], + cv: *mut [c_uchar; 32], + rk_out: *mut [c_uchar; 32], + zkproof: *mut [c_uchar; GROTH_PROOF_SIZE], +) -> bool { + // Grab `ak` from the caller, which should be a point. + let ak = match edwards::Point::::read(&(unsafe { &*ak })[..], &JUBJUB) { + Ok(p) => p, + Err(_) => return false, + }; + + // `ak` should be prime order. + let ak = match ak.as_prime_order(&JUBJUB) { + Some(p) => p, + None => return false, + }; + + // Grab `nsk` from the caller + let nsk = match Fs::from_repr(read_fs(&(unsafe { &*nsk })[..])) { + Ok(p) => p, + Err(_) => return false, + }; + + // Construct the proof generation key + let proof_generation_key = ProofGenerationKey { + ak: ak.clone(), + nsk, + }; + + // Grab the diversifier from the caller + let diversifier = Diversifier(unsafe { *diversifier }); + + // The caller chooses the note randomness + let rcm = match Fs::from_repr(read_fs(&(unsafe { &*rcm })[..])) { + Ok(p) => p, + Err(_) => return false, + }; + + // The caller also chooses the re-randomization of ak + let ar = match Fs::from_repr(read_fs(&(unsafe { &*ar })[..])) { + Ok(p) => p, + Err(_) => return false, + }; + + // We need to compute the anchor of the Spend. + let anchor = match Fr::from_repr(read_le(unsafe { &(&*anchor)[..] })) { + Ok(p) => p, + Err(_) => return false, + }; + + // The witness contains the incremental tree witness information, in a + // weird serialized format. + let witness = match CommitmentTreeWitness::from_slice(unsafe { &(&*witness)[..] }) { + Ok(w) => w, + Err(_) => return false, + }; + + // Create proof + let (proof, value_commitment, rk) = unsafe { &mut *ctx } + .spend_proof( + proof_generation_key, + diversifier, + rcm, + ar, + value, + anchor, + witness, + unsafe { SAPLING_SPEND_PARAMS.as_ref() }.unwrap(), + unsafe { SAPLING_SPEND_VK.as_ref() }.unwrap(), + &JUBJUB, + ) + .expect("proving should not fail"); + + // Write value commitment to caller + value_commitment + .write(&mut unsafe { &mut *cv }[..]) + .expect("should be able to serialize cv"); + + // Write proof out to caller + proof + .write(&mut (unsafe { &mut *zkproof })[..]) + .expect("should be able to serialize a proof"); + + // Write out `rk` to the caller + rk.write(&mut unsafe { &mut *rk_out }[..]) + .expect("should be able to write to rk_out"); + + true +} + +#[no_mangle] +pub extern "system" fn librustzcash_sapling_proving_ctx_init() -> *mut SaplingProvingContext { + let ctx = Box::new(SaplingProvingContext::new()); + + Box::into_raw(ctx) +} + +#[no_mangle] +pub extern "system" fn librustzcash_sapling_proving_ctx_free(ctx: *mut SaplingProvingContext) { + drop(unsafe { Box::from_raw(ctx) }); +} + +#[no_mangle] +pub extern "system" fn librustzcash_zip32_xsk_master( + seed: *const c_uchar, + seedlen: size_t, + xsk_master: *mut [c_uchar; 169], +) { + let seed = unsafe { std::slice::from_raw_parts(seed, seedlen) }; + + let xsk = zip32::ExtendedSpendingKey::master(seed); + + xsk.write(&mut (unsafe { &mut *xsk_master })[..]) + .expect("should be able to serialize an ExtendedSpendingKey"); +} + +#[no_mangle] +pub extern "system" fn librustzcash_zip32_xsk_derive( + xsk_parent: *const [c_uchar; 169], + i: u32, + xsk_i: *mut [c_uchar; 169], +) { + let xsk_parent = zip32::ExtendedSpendingKey::read(&unsafe { *xsk_parent }[..]) + .expect("valid ExtendedSpendingKey"); + let i = zip32::ChildIndex::from_index(i); + + let xsk = xsk_parent.derive_child(i); + + xsk.write(&mut (unsafe { &mut *xsk_i })[..]) + .expect("should be able to serialize an ExtendedSpendingKey"); +} + +#[no_mangle] +pub extern "system" fn librustzcash_zip32_xfvk_derive( + xfvk_parent: *const [c_uchar; 169], + i: u32, + xfvk_i: *mut [c_uchar; 169], +) -> bool { + let xfvk_parent = zip32::ExtendedFullViewingKey::read(&unsafe { *xfvk_parent }[..]) + .expect("valid ExtendedFullViewingKey"); + let i = zip32::ChildIndex::from_index(i); + + let xfvk = match xfvk_parent.derive_child(i) { + Ok(xfvk) => xfvk, + Err(_) => return false, + }; + + xfvk.write(&mut (unsafe { &mut *xfvk_i })[..]) + .expect("should be able to serialize an ExtendedFullViewingKey"); + + true +} + +#[no_mangle] +pub extern "system" fn librustzcash_zip32_xfvk_address( + xfvk: *const [c_uchar; 169], + j: *const [c_uchar; 11], + j_ret: *mut [c_uchar; 11], + addr_ret: *mut [c_uchar; 43], +) -> bool { + let xfvk = zip32::ExtendedFullViewingKey::read(&unsafe { *xfvk }[..]) + .expect("valid ExtendedFullViewingKey"); + let j = zip32::DiversifierIndex(unsafe { *j }); + + let addr = match xfvk.address(j) { + Ok(addr) => addr, + Err(_) => return false, + }; + + let j_ret = unsafe { &mut *j_ret }; + let addr_ret = unsafe { &mut *addr_ret }; + + j_ret.copy_from_slice(&(addr.0).0); + addr_ret.copy_from_slice(&addr.1.to_bytes()); + + true +} diff --git a/src/rust/src/tests/key_agreement.rs b/src/rust/src/tests/key_agreement.rs new file mode 100644 index 000000000..c4f56a139 --- /dev/null +++ b/src/rust/src/tests/key_agreement.rs @@ -0,0 +1,76 @@ +use ff::{PrimeField, PrimeFieldRepr}; +use pairing::bls12_381::Bls12; +use rand_core::{OsRng, RngCore}; +use zcash_primitives::jubjub::{edwards, JubjubBls12}; +use zcash_primitives::primitives::{Diversifier, ViewingKey}; + +use crate::{ + librustzcash_sapling_generate_r, librustzcash_sapling_ka_agree, + librustzcash_sapling_ka_derivepublic, +}; + +#[test] +fn test_key_agreement() { + let params = JubjubBls12::new(); + let mut rng = OsRng; + + // Create random viewing key + let vk = ViewingKey:: { + ak: edwards::Point::rand(&mut rng, ¶ms).mul_by_cofactor(¶ms), + nk: edwards::Point::rand(&mut rng, ¶ms).mul_by_cofactor(¶ms), + }; + + // Create a random address with the viewing key + let addr = loop { + let mut d = [0; 11]; + rng.fill_bytes(&mut d); + match vk.to_payment_address(Diversifier(d), ¶ms) { + Some(a) => break a, + None => {} + } + }; + + // Grab ivk from our viewing key in serialized form + let ivk = vk.ivk(); + let mut ivk_serialized = [0u8; 32]; + ivk.into_repr().write_le(&mut ivk_serialized[..]).unwrap(); + + // Create random esk + let mut esk = [0u8; 32]; + librustzcash_sapling_generate_r(&mut esk); + + // The sender will create a shared secret with the recipient + // by multiplying the pk_d from their address with the esk + // we randomly generated + let mut shared_secret_sender = [0u8; 32]; + + // Serialize pk_d for the call to librustzcash_sapling_ka_agree + let mut addr_pk_d = [0u8; 32]; + addr.pk_d().write(&mut addr_pk_d[..]).unwrap(); + + assert!(librustzcash_sapling_ka_agree( + &addr_pk_d, + &esk, + &mut shared_secret_sender + )); + + // Create epk for the recipient, placed in the transaction. Computed + // using the diversifier and esk. + let mut epk = [0u8; 32]; + assert!(librustzcash_sapling_ka_derivepublic( + &addr.diversifier().0, + &esk, + &mut epk + )); + + // Create sharedSecret with ephemeral key + let mut shared_secret_recipient = [0u8; 32]; + assert!(librustzcash_sapling_ka_agree( + &epk, + &ivk_serialized, + &mut shared_secret_recipient + )); + + assert!(!shared_secret_sender.iter().all(|&v| v == 0)); + assert_eq!(shared_secret_sender, shared_secret_recipient); +} diff --git a/src/rust/src/tests/key_components.rs b/src/rust/src/tests/key_components.rs new file mode 100644 index 000000000..5975e5eb1 --- /dev/null +++ b/src/rust/src/tests/key_components.rs @@ -0,0 +1,731 @@ +use ff::{PrimeField, PrimeFieldRepr}; +use pairing::bls12_381::Bls12; +use zcash_primitives::{ + jubjub::{fs::FsRepr, FixedGenerators, JubjubEngine, JubjubParams}, + primitives::{Diversifier, ProofGenerationKey}, +}; + +use super::JUBJUB; + +use crate::{ + librustzcash_ask_to_ak, librustzcash_check_diversifier, librustzcash_crh_ivk, + librustzcash_ivk_to_pkd, librustzcash_nsk_to_nk, +}; + +#[test] +fn key_components() { + #![allow(dead_code)] + struct TestVector { + sk: [u8; 32], + ask: [u8; 32], + nsk: [u8; 32], + ovk: [u8; 32], + ak: [u8; 32], + nk: [u8; 32], + ivk: [u8; 32], + default_d: [u8; 11], + default_pk_d: [u8; 32], + note_v: u64, + note_r: [u8; 32], + note_cm: [u8; 32], + note_pos: u64, + note_nf: [u8; 32], + }; + + // From https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/sapling_key_components.py + let test_vectors = vec![ + TestVector { + sk: [ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + ], + ask: [ + 0x85, 0x48, 0xa1, 0x4a, 0x47, 0x3e, 0xa5, 0x47, 0xaa, 0x23, 0x78, 0x40, 0x20, 0x44, + 0xf8, 0x18, 0xcf, 0x19, 0x11, 0xcf, 0x5d, 0xd2, 0x05, 0x4f, 0x67, 0x83, 0x45, 0xf0, + 0x0d, 0x0e, 0x88, 0x06, + ], + nsk: [ + 0x30, 0x11, 0x4e, 0xa0, 0xdd, 0x0b, 0xb6, 0x1c, 0xf0, 0xea, 0xea, 0xb6, 0xec, 0x33, + 0x31, 0xf5, 0x81, 0xb0, 0x42, 0x5e, 0x27, 0x33, 0x85, 0x01, 0x26, 0x2d, 0x7e, 0xac, + 0x74, 0x5e, 0x6e, 0x05, + ], + ovk: [ + 0x98, 0xd1, 0x69, 0x13, 0xd9, 0x9b, 0x04, 0x17, 0x7c, 0xab, 0xa4, 0x4f, 0x6e, 0x4d, + 0x22, 0x4e, 0x03, 0xb5, 0xac, 0x03, 0x1d, 0x7c, 0xe4, 0x5e, 0x86, 0x51, 0x38, 0xe1, + 0xb9, 0x96, 0xd6, 0x3b, + ], + ak: [ + 0xf3, 0x44, 0xec, 0x38, 0x0f, 0xe1, 0x27, 0x3e, 0x30, 0x98, 0xc2, 0x58, 0x8c, 0x5d, + 0x3a, 0x79, 0x1f, 0xd7, 0xba, 0x95, 0x80, 0x32, 0x76, 0x07, 0x77, 0xfd, 0x0e, 0xfa, + 0x8e, 0xf1, 0x16, 0x20, + ], + nk: [ + 0xf7, 0xcf, 0x9e, 0x77, 0xf2, 0xe5, 0x86, 0x83, 0x38, 0x3c, 0x15, 0x19, 0xac, 0x7b, + 0x06, 0x2d, 0x30, 0x04, 0x0e, 0x27, 0xa7, 0x25, 0xfb, 0x88, 0xfb, 0x19, 0xa9, 0x78, + 0xbd, 0x3f, 0xd6, 0xba, + ], + ivk: [ + 0xb7, 0x0b, 0x7c, 0xd0, 0xed, 0x03, 0xcb, 0xdf, 0xd7, 0xad, 0xa9, 0x50, 0x2e, 0xe2, + 0x45, 0xb1, 0x3e, 0x56, 0x9d, 0x54, 0xa5, 0x71, 0x9d, 0x2d, 0xaa, 0x0f, 0x5f, 0x14, + 0x51, 0x47, 0x92, 0x04, + ], + default_d: [ + 0xf1, 0x9d, 0x9b, 0x79, 0x7e, 0x39, 0xf3, 0x37, 0x44, 0x58, 0x39, + ], + default_pk_d: [ + 0xdb, 0x4c, 0xd2, 0xb0, 0xaa, 0xc4, 0xf7, 0xeb, 0x8c, 0xa1, 0x31, 0xf1, 0x65, 0x67, + 0xc4, 0x45, 0xa9, 0x55, 0x51, 0x26, 0xd3, 0xc2, 0x9f, 0x14, 0xe3, 0xd7, 0x76, 0xe8, + 0x41, 0xae, 0x74, 0x15, + ], + note_v: 0, + note_r: [ + 0x39, 0x17, 0x6d, 0xac, 0x39, 0xac, 0xe4, 0x98, 0x0e, 0xcc, 0x8d, 0x77, 0x8e, 0x89, + 0x86, 0x02, 0x55, 0xec, 0x36, 0x15, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + ], + note_cm: [ + 0xcb, 0x3c, 0xf9, 0x15, 0x32, 0x70, 0xd5, 0x7e, 0xb9, 0x14, 0xc6, 0xc2, 0xbc, 0xc0, + 0x18, 0x50, 0xc9, 0xfe, 0xd4, 0x4f, 0xce, 0x08, 0x06, 0x27, 0x8f, 0x08, 0x3e, 0xf2, + 0xdd, 0x07, 0x64, 0x39, + ], + note_pos: 0, + note_nf: [ + 0x44, 0xfa, 0xd6, 0x56, 0x4f, 0xfd, 0xec, 0x9f, 0xa1, 0x9c, 0x43, 0xa2, 0x8f, 0x86, + 0x1d, 0x5e, 0xbf, 0x60, 0x23, 0x46, 0x00, 0x7d, 0xe7, 0x62, 0x67, 0xd9, 0x75, 0x27, + 0x47, 0xab, 0x40, 0x63, + ], + }, + TestVector { + sk: [ + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + ], + ask: [ + 0xc9, 0x43, 0x56, 0x29, 0xbf, 0x8b, 0xff, 0xe5, 0x5e, 0x73, 0x35, 0xec, 0x07, 0x77, + 0x18, 0xba, 0x60, 0xba, 0x28, 0xd7, 0xac, 0x37, 0x94, 0xb7, 0x4f, 0x51, 0x2c, 0x31, + 0xaf, 0x0a, 0x53, 0x04, + ], + nsk: [ + 0x11, 0xac, 0xc2, 0xea, 0xd0, 0x7b, 0x5f, 0x00, 0x8c, 0x1f, 0x0f, 0x09, 0x0c, 0xc8, + 0xdd, 0xf3, 0x35, 0x23, 0x6f, 0xf4, 0xb2, 0x53, 0xc6, 0x49, 0x56, 0x95, 0xe9, 0xd6, + 0x39, 0xda, 0xcd, 0x08, + ], + ovk: [ + 0x3b, 0x94, 0x62, 0x10, 0xce, 0x6d, 0x1b, 0x16, 0x92, 0xd7, 0x39, 0x2a, 0xc8, 0x4a, + 0x8b, 0xc8, 0xf0, 0x3b, 0x72, 0x72, 0x3c, 0x7d, 0x36, 0x72, 0x1b, 0x80, 0x9a, 0x79, + 0xc9, 0xd6, 0xe4, 0x5b, + ], + ak: [ + 0x82, 0xff, 0x5e, 0xff, 0xc5, 0x27, 0xae, 0x84, 0x02, 0x0b, 0xf2, 0xd3, 0x52, 0x01, + 0xc1, 0x02, 0x19, 0x13, 0x19, 0x47, 0xff, 0x4b, 0x96, 0xf8, 0x81, 0xa4, 0x5f, 0x2e, + 0x8a, 0xe3, 0x05, 0x18, + ], + nk: [ + 0xc4, 0x53, 0x4d, 0x84, 0x8b, 0xb9, 0x18, 0xcf, 0x4a, 0x7f, 0x8b, 0x98, 0x74, 0x0a, + 0xb3, 0xcc, 0xee, 0x58, 0x67, 0x95, 0xff, 0x4d, 0xf6, 0x45, 0x47, 0xa8, 0x88, 0x8a, + 0x6c, 0x74, 0x15, 0xd2, + ], + ivk: [ + 0xc5, 0x18, 0x38, 0x44, 0x66, 0xb2, 0x69, 0x88, 0xb5, 0x10, 0x90, 0x67, 0x41, 0x8d, + 0x19, 0x2d, 0x9d, 0x6b, 0xd0, 0xd9, 0x23, 0x22, 0x05, 0xd7, 0x74, 0x18, 0xc2, 0x40, + 0xfc, 0x68, 0xa4, 0x06, + ], + default_d: [ + 0xae, 0xf1, 0x80, 0xf6, 0xe3, 0x4e, 0x35, 0x4b, 0x88, 0x8f, 0x81, + ], + default_pk_d: [ + 0xa6, 0xb1, 0x3e, 0xa3, 0x36, 0xdd, 0xb7, 0xa6, 0x7b, 0xb0, 0x9a, 0x0e, 0x68, 0xe9, + 0xd3, 0xcf, 0xb3, 0x92, 0x10, 0x83, 0x1e, 0xa3, 0xa2, 0x96, 0xba, 0x09, 0xa9, 0x22, + 0x06, 0x0f, 0xd3, 0x8b, + ], + note_v: 12227227834928555328, + note_r: [ + 0x47, 0x8b, 0xa0, 0xee, 0x6e, 0x1a, 0x75, 0xb6, 0x00, 0x03, 0x6f, 0x26, 0xf1, 0x8b, + 0x70, 0x15, 0xab, 0x55, 0x6b, 0xed, 0xdf, 0x8b, 0x96, 0x02, 0x38, 0x86, 0x9f, 0x89, + 0xdd, 0x80, 0x4e, 0x06, + ], + note_cm: [ + 0xb5, 0x78, 0x93, 0x50, 0x0b, 0xfb, 0x85, 0xdf, 0x2e, 0x8b, 0x01, 0xac, 0x45, 0x2f, + 0x89, 0xe1, 0x0e, 0x26, 0x6b, 0xcf, 0xa3, 0x1c, 0x31, 0xb2, 0x9a, 0x53, 0xae, 0x72, + 0xca, 0xd4, 0x69, 0x50, + ], + note_pos: 763714296, + note_nf: [ + 0x67, 0x9e, 0xb0, 0xc3, 0xa7, 0x57, 0xe2, 0xae, 0x83, 0xcd, 0xb4, 0x2a, 0x1a, 0xb2, + 0x59, 0xd7, 0x83, 0x88, 0x31, 0x54, 0x19, 0xad, 0xc7, 0x1d, 0x2e, 0x37, 0x63, 0x17, + 0x4c, 0x2e, 0x9d, 0x93, + ], + }, + TestVector { + sk: [ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, + ], + ask: [ + 0xee, 0x1c, 0x3d, 0x7e, 0xfe, 0x0a, 0x78, 0x06, 0x3d, 0x6a, 0xf3, 0xd9, 0xd8, 0x12, + 0x12, 0xaf, 0x47, 0xb7, 0xc1, 0xb7, 0x61, 0xf8, 0x5c, 0xcb, 0x06, 0x6f, 0xc1, 0x1a, + 0x6a, 0x42, 0x17, 0x03, + ], + nsk: [ + 0x1d, 0x3b, 0x71, 0x37, 0x55, 0xd7, 0x48, 0x75, 0xe8, 0xea, 0x38, 0xfd, 0x16, 0x6e, + 0x76, 0xc6, 0x2a, 0x42, 0x50, 0x21, 0x6e, 0x6b, 0xbf, 0xe4, 0x8a, 0x5e, 0x2e, 0xab, + 0xad, 0x11, 0x7f, 0x0b, + ], + ovk: [ + 0x8b, 0xf4, 0x39, 0x0e, 0x28, 0xdd, 0xc9, 0x5b, 0x83, 0x02, 0xc3, 0x81, 0xd5, 0x81, + 0x0b, 0x84, 0xba, 0x8e, 0x60, 0x96, 0xe5, 0xa7, 0x68, 0x22, 0x77, 0x4f, 0xd4, 0x9f, + 0x49, 0x1e, 0x8f, 0x49, + ], + ak: [ + 0xab, 0x83, 0x57, 0x4e, 0xb5, 0xde, 0x85, 0x9a, 0x0a, 0xb8, 0x62, 0x9d, 0xec, 0x34, + 0xc7, 0xbe, 0xe8, 0xc3, 0xfc, 0x74, 0xdf, 0xa0, 0xb1, 0x9a, 0x3a, 0x74, 0x68, 0xd1, + 0x5d, 0xca, 0x64, 0xc6, + ], + nk: [ + 0x95, 0xd5, 0x80, 0x53, 0xe0, 0x59, 0x2e, 0x4a, 0x16, 0x9c, 0xc0, 0xb7, 0x92, 0x8a, + 0xaa, 0xc3, 0xde, 0x24, 0xef, 0x15, 0x31, 0xaa, 0x9e, 0xb6, 0xf4, 0xab, 0x93, 0x91, + 0x4d, 0xa8, 0xa0, 0x6e, + ], + ivk: [ + 0x47, 0x1c, 0x24, 0xa3, 0xdc, 0x87, 0x30, 0xe7, 0x50, 0x36, 0xc0, 0xa9, 0x5f, 0x3e, + 0x2f, 0x7d, 0xd1, 0xbe, 0x6f, 0xb9, 0x3a, 0xd2, 0x95, 0x92, 0x20, 0x3d, 0xef, 0x30, + 0x41, 0x95, 0x45, 0x05, + ], + default_d: [ + 0x75, 0x99, 0xf0, 0xbf, 0x9b, 0x57, 0xcd, 0x2d, 0xc2, 0x99, 0xb6, + ], + default_pk_d: [ + 0x66, 0x14, 0x17, 0x39, 0x51, 0x4b, 0x28, 0xf0, 0x5d, 0xef, 0x8a, 0x18, 0xee, 0xee, + 0x5e, 0xed, 0x4d, 0x44, 0xc6, 0x22, 0x5c, 0x3c, 0x65, 0xd8, 0x8d, 0xd9, 0x90, 0x77, + 0x08, 0x01, 0x2f, 0x5a, + ], + note_v: 6007711596147559040, + note_r: [ + 0x14, 0x7c, 0xf2, 0xb5, 0x1b, 0x4c, 0x7c, 0x63, 0xcb, 0x77, 0xb9, 0x9e, 0x8b, 0x78, + 0x3e, 0x5b, 0x51, 0x11, 0xdb, 0x0a, 0x7c, 0xa0, 0x4d, 0x6c, 0x01, 0x4a, 0x1d, 0x7d, + 0xa8, 0x3b, 0xae, 0x0a, + ], + note_cm: [ + 0xdb, 0x85, 0xa7, 0x0a, 0x98, 0x43, 0x7f, 0x73, 0x16, 0x7f, 0xc3, 0x32, 0xd5, 0xb7, + 0xb7, 0x40, 0x82, 0x96, 0x66, 0x17, 0x70, 0xb1, 0x01, 0xb0, 0xaa, 0x87, 0x83, 0x9f, + 0x4e, 0x55, 0xf1, 0x51, + ], + note_pos: 1527428592, + note_nf: [ + 0xe9, 0x8f, 0x6a, 0x8f, 0x34, 0xff, 0x49, 0x80, 0x59, 0xb3, 0xc7, 0x31, 0xb9, 0x1f, + 0x45, 0x11, 0x08, 0xc4, 0x95, 0x4d, 0x91, 0x94, 0x84, 0x36, 0x1c, 0xf9, 0xb4, 0x8f, + 0x59, 0xae, 0x1d, 0x14, + ], + }, + TestVector { + sk: [ + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, + ], + ask: [ + 0x00, 0xc3, 0xa1, 0xe1, 0xca, 0x8f, 0x4e, 0x04, 0x80, 0xee, 0x1e, 0xe9, 0x0c, 0xa7, + 0x51, 0x78, 0x79, 0xd3, 0xfc, 0x5c, 0x81, 0x5c, 0x09, 0x03, 0xe5, 0xee, 0xbc, 0x94, + 0xbb, 0x80, 0x95, 0x03, + ], + nsk: [ + 0xe6, 0x62, 0x85, 0xa5, 0xe9, 0xb6, 0x5e, 0x15, 0x7a, 0xd2, 0xfc, 0xd5, 0x43, 0xda, + 0xd9, 0x8c, 0x67, 0xa5, 0x8a, 0xbd, 0xf2, 0x87, 0xe0, 0x55, 0x06, 0xbd, 0x1c, 0x2e, + 0x59, 0xb0, 0x72, 0x0b, + ], + ovk: [ + 0x14, 0x76, 0x78, 0xe0, 0x55, 0x3b, 0x97, 0x82, 0x93, 0x47, 0x64, 0x7c, 0x5b, 0xc7, + 0xda, 0xb4, 0xcc, 0x22, 0x02, 0xb5, 0x4e, 0xc2, 0x9f, 0xd3, 0x1a, 0x3d, 0xe6, 0xbe, + 0x08, 0x25, 0xfc, 0x5e, + ], + ak: [ + 0x3c, 0x9c, 0xde, 0x7e, 0x5d, 0x0d, 0x38, 0xa8, 0x61, 0x0f, 0xaa, 0xdb, 0xcf, 0x4c, + 0x34, 0x3f, 0x5d, 0x3c, 0xfa, 0x31, 0x55, 0xa5, 0xb9, 0x46, 0x61, 0xa6, 0x75, 0x3e, + 0x96, 0xe8, 0x84, 0xea, + ], + nk: [ + 0xb7, 0x7d, 0x36, 0xf5, 0x08, 0x94, 0x1d, 0xbd, 0x61, 0xcf, 0xd0, 0xf1, 0x59, 0xee, + 0x05, 0xcf, 0xaa, 0x78, 0xa2, 0x6c, 0x94, 0x92, 0x90, 0x38, 0x06, 0xd8, 0x3b, 0x59, + 0x8d, 0x3c, 0x1c, 0x2a, + ], + ivk: [ + 0x63, 0x6a, 0xa9, 0x64, 0xbf, 0xc2, 0x3c, 0xe4, 0xb1, 0xfc, 0xf7, 0xdf, 0xc9, 0x91, + 0x79, 0xdd, 0xc4, 0x06, 0xff, 0x55, 0x40, 0x0c, 0x92, 0x95, 0xac, 0xfc, 0x14, 0xf0, + 0x31, 0xc7, 0x26, 0x00, + ], + default_d: [ + 0x1b, 0x81, 0x61, 0x4f, 0x1d, 0xad, 0xea, 0x0f, 0x8d, 0x0a, 0x58, + ], + default_pk_d: [ + 0x25, 0xeb, 0x55, 0xfc, 0xcf, 0x76, 0x1f, 0xc6, 0x4e, 0x85, 0xa5, 0x88, 0xef, 0xe6, + 0xea, 0xd7, 0x83, 0x2f, 0xb1, 0xf0, 0xf7, 0xa8, 0x31, 0x65, 0x89, 0x5b, 0xdf, 0xf9, + 0x42, 0x92, 0x5f, 0x5c, + ], + note_v: 18234939431076114368, + note_r: [ + 0x34, 0xa4, 0xb2, 0xa9, 0x14, 0x4f, 0xf5, 0xea, 0x54, 0xef, 0xee, 0x87, 0xcf, 0x90, + 0x1b, 0x5b, 0xed, 0x5e, 0x35, 0xd2, 0x1f, 0xbb, 0xd7, 0x88, 0xd5, 0xbd, 0x9d, 0x83, + 0x3e, 0x11, 0x28, 0x04, + ], + note_cm: [ + 0xe0, 0x8c, 0xe4, 0x82, 0xb3, 0xa8, 0xfb, 0x3b, 0x35, 0xcc, 0xdb, 0xe3, 0x43, 0x37, + 0xbd, 0x10, 0x5d, 0x88, 0x39, 0x21, 0x2e, 0x0d, 0x16, 0x44, 0xb9, 0xd5, 0x5c, 0xaa, + 0x60, 0xd1, 0x9b, 0x6c, + ], + note_pos: 2291142888, + note_nf: [ + 0x55, 0x47, 0xaa, 0x12, 0xff, 0x80, 0xa6, 0xb3, 0x30, 0x4e, 0x3b, 0x05, 0x86, 0x56, + 0x47, 0x2a, 0xbd, 0x2c, 0x81, 0x83, 0xb5, 0x9d, 0x07, 0x37, 0xb9, 0x3c, 0xee, 0x75, + 0x8b, 0xec, 0x47, 0xa1, + ], + }, + TestVector { + sk: [ + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, + ], + ask: [ + 0x82, 0x36, 0xd1, 0x9d, 0x32, 0x05, 0xd8, 0x55, 0x43, 0xa0, 0x68, 0x11, 0x34, 0x3f, + 0x82, 0x7b, 0x65, 0x63, 0x77, 0x0a, 0x49, 0xaa, 0x4d, 0x0c, 0xa0, 0x08, 0x18, 0x05, + 0xd4, 0xc8, 0xea, 0x0d, + ], + nsk: [ + 0x7e, 0xc1, 0xef, 0x0b, 0xed, 0x82, 0x71, 0x82, 0x72, 0xf0, 0xf4, 0x4f, 0x01, 0x7c, + 0x48, 0x41, 0x74, 0x51, 0x3d, 0x66, 0x1d, 0xd1, 0x68, 0xaf, 0x02, 0xd2, 0x09, 0x2a, + 0x1d, 0x8a, 0x05, 0x07, + ], + ovk: [ + 0x1b, 0x6e, 0x75, 0xec, 0xe3, 0xac, 0xe8, 0xdb, 0xa6, 0xa5, 0x41, 0x0d, 0x9a, 0xd4, + 0x75, 0x56, 0x68, 0xe4, 0xb3, 0x95, 0x85, 0xd6, 0x35, 0xec, 0x1d, 0xa7, 0xc8, 0xdc, + 0xfd, 0x5f, 0xc4, 0xed, + ], + ak: [ + 0x55, 0xe8, 0x83, 0x89, 0xbb, 0x7e, 0x41, 0xde, 0x13, 0x0c, 0xfa, 0x51, 0xa8, 0x71, + 0x5f, 0xde, 0x01, 0xff, 0x9c, 0x68, 0x76, 0x64, 0x7f, 0x01, 0x75, 0xad, 0x34, 0xf0, + 0x58, 0xdd, 0xe0, 0x1a, + ], + nk: [ + 0x72, 0x5d, 0x4a, 0xd6, 0xa1, 0x50, 0x21, 0xcd, 0x1c, 0x48, 0xc5, 0xee, 0x19, 0xde, + 0x6c, 0x1e, 0x76, 0x8a, 0x2c, 0xc0, 0xa9, 0xa7, 0x30, 0xa0, 0x1b, 0xb2, 0x1c, 0x95, + 0xe3, 0xd9, 0xe4, 0x3c, + ], + ivk: [ + 0x67, 0xfa, 0x2b, 0xf7, 0xc6, 0x7d, 0x46, 0x58, 0x24, 0x3c, 0x31, 0x7c, 0x0c, 0xb4, + 0x1f, 0xd3, 0x20, 0x64, 0xdf, 0xd3, 0x70, 0x9f, 0xe0, 0xdc, 0xb7, 0x24, 0xf1, 0x4b, + 0xb0, 0x1a, 0x1d, 0x04, + ], + default_d: [ + 0xfc, 0xfb, 0x68, 0xa4, 0x0d, 0x4b, 0xc6, 0xa0, 0x4b, 0x09, 0xc4, + ], + default_pk_d: [ + 0x8b, 0x2a, 0x33, 0x7f, 0x03, 0x62, 0x2c, 0x24, 0xff, 0x38, 0x1d, 0x4c, 0x54, 0x6f, + 0x69, 0x77, 0xf9, 0x05, 0x22, 0xe9, 0x2f, 0xde, 0x44, 0xc9, 0xd1, 0xbb, 0x09, 0x97, + 0x14, 0xb9, 0xdb, 0x2b, + ], + note_v: 12015423192295118080, + note_r: [ + 0xe5, 0x57, 0x85, 0x13, 0x55, 0x74, 0x7c, 0x09, 0xac, 0x59, 0x01, 0x3c, 0xbd, 0xe8, + 0x59, 0x80, 0x96, 0x4e, 0xc1, 0x84, 0x4d, 0x9c, 0x69, 0x67, 0xca, 0x0c, 0x02, 0x9c, + 0x84, 0x57, 0xbb, 0x04, + ], + note_cm: [ + 0xbd, 0xc8, 0x54, 0xbf, 0x3e, 0x7b, 0x00, 0x82, 0x1f, 0x3b, 0x8b, 0x85, 0x23, 0x8c, + 0xcf, 0x1e, 0x67, 0x15, 0xbf, 0xe7, 0x0b, 0x63, 0x2d, 0x04, 0x4b, 0x26, 0xfb, 0x2b, + 0xc7, 0x1b, 0x7f, 0x36, + ], + note_pos: 3054857184, + note_nf: [ + 0x8a, 0x9a, 0xbd, 0xa3, 0xd4, 0xef, 0x85, 0xca, 0xf2, 0x2b, 0xfa, 0xf2, 0xc4, 0x8f, + 0x62, 0x38, 0x2a, 0x73, 0xa1, 0x62, 0x4e, 0xb8, 0xeb, 0x2b, 0xd0, 0x0d, 0x27, 0x03, + 0x01, 0xbf, 0x3d, 0x13, + ], + }, + TestVector { + sk: [ + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, + ], + ask: [ + 0xea, 0xe6, 0x88, 0x4d, 0x76, 0x4a, 0x05, 0x40, 0x61, 0xa8, 0xf1, 0xc0, 0x07, 0x6c, + 0x62, 0x4d, 0xcb, 0x73, 0x87, 0x89, 0xf7, 0xad, 0x1e, 0x74, 0x08, 0xe3, 0x1f, 0x24, + 0xdf, 0xc8, 0x26, 0x07, + ], + nsk: [ + 0xfb, 0xe6, 0x10, 0xf4, 0x2a, 0x41, 0x74, 0x9f, 0x9b, 0x6e, 0x6e, 0x4a, 0x54, 0xb5, + 0xa3, 0x2e, 0xbf, 0xe8, 0xf4, 0x38, 0x00, 0x88, 0x1b, 0xa6, 0xcd, 0x13, 0xed, 0x0b, + 0x05, 0x29, 0x46, 0x01, + ], + ovk: [ + 0xc6, 0xbc, 0x1f, 0x39, 0xf0, 0xd7, 0x86, 0x31, 0x4c, 0xb2, 0x0b, 0xf9, 0xab, 0x22, + 0x85, 0x40, 0x91, 0x35, 0x55, 0xf9, 0x70, 0x69, 0x6b, 0x6d, 0x7c, 0x77, 0xbb, 0x33, + 0x23, 0x28, 0x37, 0x2a, + ], + ak: [ + 0xe6, 0x82, 0x76, 0x59, 0x14, 0xe3, 0x86, 0x4c, 0x33, 0x9e, 0x57, 0x82, 0xb8, 0x55, + 0xc0, 0xfd, 0xf4, 0x0e, 0x0d, 0xfc, 0xed, 0xb9, 0xe7, 0xb4, 0x7b, 0xc9, 0x4b, 0x90, + 0xb3, 0xa4, 0xc9, 0x88, + ], + nk: [ + 0x82, 0x25, 0x6b, 0x95, 0x62, 0x3c, 0x67, 0x02, 0x4b, 0x44, 0x24, 0xd9, 0x14, 0x00, + 0xa3, 0x70, 0xe7, 0xac, 0x8e, 0x4d, 0x15, 0x48, 0x2a, 0x37, 0x59, 0xe0, 0x0d, 0x21, + 0x97, 0x49, 0xda, 0xee, + ], + ivk: [ + 0xea, 0x3f, 0x1d, 0x80, 0xe4, 0x30, 0x7c, 0xa7, 0x3b, 0x9f, 0x37, 0x80, 0x1f, 0x91, + 0xfb, 0xa8, 0x10, 0xcc, 0x41, 0xd2, 0x79, 0xfc, 0x29, 0xf5, 0x64, 0x23, 0x56, 0x54, + 0xa2, 0x17, 0x8e, 0x03, + ], + default_d: [ + 0xeb, 0x51, 0x98, 0x82, 0xad, 0x1e, 0x5c, 0xc6, 0x54, 0xcd, 0x59, + ], + default_pk_d: [ + 0x6b, 0x27, 0xda, 0xcc, 0xb5, 0xa8, 0x20, 0x7f, 0x53, 0x2d, 0x10, 0xca, 0x23, 0x8f, + 0x97, 0x86, 0x64, 0x8a, 0x11, 0xb5, 0x96, 0x6e, 0x51, 0xa2, 0xf7, 0xd8, 0x9e, 0x15, + 0xd2, 0x9b, 0x8f, 0xdf, + ], + note_v: 5795906953514121792, + note_r: [ + 0x68, 0xf0, 0x61, 0x04, 0x60, 0x6b, 0x0c, 0x54, 0x49, 0x84, 0x5f, 0xf4, 0xc6, 0x5f, + 0x73, 0xe9, 0x0f, 0x45, 0xef, 0x5a, 0x43, 0xc9, 0xd7, 0x4c, 0xb2, 0xc8, 0x5c, 0xf5, + 0x6c, 0x94, 0xc0, 0x02, + ], + note_cm: [ + 0xe8, 0x26, 0x7d, 0x30, 0xac, 0x11, 0xc1, 0x00, 0xbc, 0x7a, 0x0f, 0xdf, 0x91, 0xf7, + 0x1d, 0x74, 0xc5, 0xbc, 0xf2, 0xe1, 0xef, 0x95, 0x66, 0x90, 0x44, 0x73, 0x01, 0x69, + 0xde, 0x1a, 0x5b, 0x4c, + ], + note_pos: 3818571480, + note_nf: [ + 0x33, 0x2a, 0xd9, 0x9e, 0xb9, 0xe9, 0x77, 0xeb, 0x62, 0x7a, 0x12, 0x2d, 0xbf, 0xb2, + 0xf2, 0x5f, 0xe5, 0x88, 0xe5, 0x97, 0x75, 0x3e, 0xc5, 0x58, 0x0f, 0xf2, 0xbe, 0x20, + 0xb6, 0xc9, 0xa7, 0xe1, + ], + }, + TestVector { + sk: [ + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, + ], + ask: [ + 0xe8, 0xf8, 0x16, 0xb4, 0xbc, 0x08, 0xa7, 0xe5, 0x66, 0x75, 0x0c, 0xc2, 0x8a, 0xfe, + 0x82, 0xa4, 0xce, 0xa9, 0xc2, 0xbe, 0xf2, 0x44, 0xfa, 0x4b, 0x13, 0xc4, 0x73, 0x9b, + 0x28, 0x07, 0x4c, 0x0d, + ], + nsk: [ + 0x32, 0x61, 0x5b, 0x13, 0x7f, 0x28, 0x01, 0xed, 0x44, 0x6e, 0x48, 0x78, 0x1a, 0xb0, + 0x63, 0x45, 0x72, 0xe1, 0x8c, 0xfb, 0x06, 0x93, 0x72, 0x1b, 0x88, 0x03, 0xc0, 0x5b, + 0x82, 0x27, 0xd1, 0x07, + ], + ovk: [ + 0xf6, 0x2c, 0x05, 0xe8, 0x48, 0xa8, 0x73, 0xef, 0x88, 0x5e, 0x12, 0xb0, 0x8c, 0x5e, + 0x7c, 0xa2, 0xf3, 0x24, 0x24, 0xba, 0xcc, 0x75, 0x4c, 0xb6, 0x97, 0x50, 0x44, 0x4d, + 0x35, 0x5f, 0x51, 0x06, + ], + ak: [ + 0xff, 0x27, 0xdb, 0x07, 0x51, 0x94, 0x5d, 0x3e, 0xe4, 0xbe, 0x9c, 0xf1, 0x5c, 0x2e, + 0xa2, 0x11, 0xb2, 0x4b, 0x16, 0x4d, 0x5f, 0x2d, 0x7d, 0xdf, 0xf5, 0xe4, 0xa0, 0x70, + 0x8f, 0x10, 0xb9, 0x5e, + ], + nk: [ + 0x94, 0x38, 0x85, 0x95, 0x9d, 0x4e, 0xf8, 0xa9, 0xcf, 0xca, 0x07, 0xc4, 0x57, 0xf0, + 0x9e, 0xc7, 0x4b, 0x96, 0xf9, 0x93, 0xd8, 0xe0, 0xfa, 0x32, 0xb1, 0x9c, 0x03, 0xe3, + 0xb0, 0x7a, 0x42, 0x0f, + ], + ivk: [ + 0xb5, 0xc5, 0x89, 0x49, 0x43, 0x95, 0x69, 0x33, 0xc0, 0xe5, 0xc1, 0x2d, 0x31, 0x1f, + 0xc1, 0x2c, 0xba, 0x58, 0x35, 0x4b, 0x5c, 0x38, 0x9e, 0xdc, 0x03, 0xda, 0x55, 0x08, + 0x4f, 0x74, 0xc2, 0x05, + ], + default_d: [ + 0xbe, 0xbb, 0x0f, 0xb4, 0x6b, 0x8a, 0xaf, 0xf8, 0x90, 0x40, 0xf6, + ], + default_pk_d: [ + 0xd1, 0x1d, 0xa0, 0x1f, 0x0b, 0x43, 0xbd, 0xd5, 0x28, 0x8d, 0x32, 0x38, 0x5b, 0x87, + 0x71, 0xd2, 0x23, 0x49, 0x3c, 0x69, 0x80, 0x25, 0x44, 0x04, 0x3f, 0x77, 0xcf, 0x1d, + 0x71, 0xc1, 0xcb, 0x8c, + ], + note_v: 18023134788442677120, + note_r: [ + 0x49, 0xf9, 0x0b, 0x47, 0xfd, 0x52, 0xfe, 0xe7, 0xc1, 0xc8, 0x1f, 0x0d, 0xcb, 0x5b, + 0x74, 0xc3, 0xfb, 0x9b, 0x3e, 0x03, 0x97, 0x6f, 0x8b, 0x75, 0x24, 0xea, 0xba, 0xd0, + 0x08, 0x89, 0x21, 0x07, + ], + note_cm: [ + 0x57, 0x2b, 0xa2, 0x05, 0x25, 0xb0, 0xac, 0x4d, 0x6d, 0xc0, 0x1a, 0xc2, 0xea, 0x10, + 0x90, 0xb6, 0xe0, 0xf2, 0xf4, 0xbf, 0x4e, 0xc4, 0xa0, 0xdb, 0x5b, 0xbc, 0xcb, 0x5b, + 0x78, 0x3a, 0x1e, 0x55, + ], + note_pos: 287318480, + note_nf: [ + 0xfc, 0x74, 0xcd, 0x0e, 0x4b, 0xe0, 0x49, 0x57, 0xb1, 0x96, 0xcf, 0x87, 0x34, 0xae, + 0x99, 0x23, 0x96, 0xaf, 0x4c, 0xfa, 0x8f, 0xec, 0xbb, 0x86, 0xf9, 0x61, 0xe6, 0xb4, + 0x07, 0xd5, 0x1e, 0x11, + ], + }, + TestVector { + sk: [ + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, + ], + ask: [ + 0x74, 0xb4, 0x4a, 0x37, 0xf1, 0x50, 0x23, 0xc0, 0x60, 0x42, 0x7e, 0x1d, 0xae, 0xa3, + 0xf6, 0x43, 0x12, 0xdd, 0x8f, 0xeb, 0x7b, 0x2c, 0xed, 0xf0, 0xdd, 0x55, 0x44, 0x49, + 0x3f, 0x87, 0x2c, 0x06, + ], + nsk: [ + 0x07, 0x5c, 0x35, 0xdb, 0x8b, 0x1b, 0x25, 0x75, 0x42, 0x23, 0xec, 0xee, 0x34, 0xab, + 0x73, 0x0d, 0xdd, 0xd1, 0xf1, 0x4a, 0x6a, 0x54, 0xf4, 0xc6, 0xf4, 0x68, 0x45, 0x3c, + 0x3c, 0x6e, 0xd6, 0x0b, + ], + ovk: [ + 0xe9, 0xe0, 0xdc, 0x1e, 0xd3, 0x11, 0xda, 0xed, 0x64, 0xbd, 0x74, 0xda, 0x5d, 0x94, + 0xfe, 0x88, 0xa6, 0xea, 0x41, 0x4b, 0x73, 0x12, 0xde, 0x3d, 0x2a, 0x78, 0xf6, 0x46, + 0x32, 0xbb, 0xe3, 0x73, + ], + ak: [ + 0x28, 0x3f, 0x9a, 0xaf, 0xa9, 0xbc, 0xb3, 0xe6, 0xce, 0x17, 0xe6, 0x32, 0x12, 0x63, + 0x4c, 0xb3, 0xee, 0x55, 0x0c, 0x47, 0x6b, 0x67, 0x6b, 0xd3, 0x56, 0xa6, 0xdf, 0x8a, + 0xdf, 0x51, 0xd2, 0x5e, + ], + nk: [ + 0xdc, 0x4c, 0x67, 0xb1, 0x0d, 0x4b, 0x0a, 0x21, 0x8d, 0xc6, 0xe1, 0x48, 0x70, 0x66, + 0x74, 0x0a, 0x40, 0x93, 0x17, 0x86, 0x6c, 0x32, 0xe6, 0x64, 0xb5, 0x0e, 0x39, 0x7a, + 0xa8, 0x03, 0x89, 0xd4, + ], + ivk: [ + 0x87, 0x16, 0xc8, 0x28, 0x80, 0xe1, 0x36, 0x83, 0xe1, 0xbb, 0x05, 0x9d, 0xd0, 0x6c, + 0x80, 0xc9, 0x01, 0x34, 0xa9, 0x6d, 0x5a, 0xfc, 0xa8, 0xaa, 0xc2, 0xbb, 0xf6, 0x8b, + 0xb0, 0x5f, 0x84, 0x02, + ], + default_d: [ + 0xad, 0x6e, 0x2e, 0x18, 0x5a, 0x31, 0x00, 0xe3, 0xa6, 0xa8, 0xb3, + ], + default_pk_d: [ + 0x32, 0xcb, 0x28, 0x06, 0xb8, 0x82, 0xf1, 0x36, 0x8b, 0x0d, 0x4a, 0x89, 0x8f, 0x72, + 0xc4, 0xc8, 0xf7, 0x28, 0x13, 0x2c, 0xc1, 0x24, 0x56, 0x94, 0x6e, 0x7f, 0x4c, 0xb0, + 0xfb, 0x05, 0x8d, 0xa9, + ], + note_v: 11803618549661680832, + note_r: [ + 0x51, 0x65, 0xaf, 0xf2, 0x2d, 0xd4, 0xed, 0x56, 0xb4, 0xd8, 0x1d, 0x1f, 0x17, 0x1c, + 0xc3, 0xd6, 0x43, 0x2f, 0xed, 0x1b, 0xeb, 0xf2, 0x0a, 0x7b, 0xea, 0xb1, 0x2d, 0xb1, + 0x42, 0xf9, 0x4a, 0x0c, + ], + note_cm: [ + 0xab, 0x7f, 0xc5, 0x66, 0x87, 0x3c, 0xcd, 0xe6, 0x71, 0xf5, 0x98, 0x27, 0x67, 0x85, + 0x60, 0xa0, 0x06, 0xf8, 0x2b, 0xb7, 0xad, 0xcd, 0x75, 0x22, 0x3f, 0xa8, 0x59, 0x36, + 0xf7, 0x8c, 0x2b, 0x23, + ], + note_pos: 1051032776, + note_nf: [ + 0xd2, 0xe8, 0x87, 0xbd, 0x85, 0x4a, 0x80, 0x2b, 0xce, 0x85, 0x70, 0x53, 0x02, 0x0f, + 0x5d, 0x3e, 0x7c, 0x8a, 0xe5, 0x26, 0x7c, 0x5b, 0x65, 0x83, 0xb3, 0xd2, 0x12, 0xcc, + 0x8b, 0xb6, 0x98, 0x90, + ], + }, + TestVector { + sk: [ + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, + ], + ask: [ + 0x03, 0x9d, 0xd9, 0x3d, 0xf3, 0x11, 0xff, 0x8f, 0xba, 0xb3, 0xfe, 0x23, 0x02, 0x19, + 0xcd, 0x42, 0xac, 0x87, 0x94, 0x84, 0xf3, 0x0b, 0x90, 0x3a, 0x3c, 0x1e, 0x67, 0xcc, + 0xca, 0x5a, 0x7b, 0x0d, + ], + nsk: [ + 0x04, 0x9f, 0xa1, 0x4f, 0x48, 0x6c, 0x75, 0xb9, 0xfa, 0xd7, 0xe3, 0xb6, 0x73, 0xa4, + 0x43, 0xdd, 0x07, 0x4e, 0xaa, 0x96, 0xed, 0xcb, 0x2a, 0x53, 0xea, 0xaa, 0xbd, 0xaf, + 0x70, 0xff, 0xbb, 0x08, + ], + ovk: [ + 0x14, 0x7d, 0xd1, 0x1d, 0x77, 0xeb, 0xa1, 0xb1, 0x63, 0x6f, 0xd6, 0x19, 0x0c, 0x62, + 0xb9, 0xa5, 0xd0, 0x48, 0x1b, 0xee, 0x7e, 0x91, 0x7f, 0xab, 0x02, 0xe2, 0x18, 0x58, + 0x06, 0x3a, 0xb5, 0x04, + ], + ak: [ + 0x36, 0x40, 0x48, 0xee, 0xdb, 0xe8, 0xca, 0x20, 0x5e, 0xb7, 0xe7, 0xba, 0x0a, 0x90, + 0x12, 0x16, 0x6c, 0x7c, 0x7b, 0xd9, 0xeb, 0x22, 0x8e, 0x08, 0x48, 0x14, 0x48, 0xc4, + 0x88, 0xaa, 0x21, 0xd2, + ], + nk: [ + 0xed, 0x60, 0xaf, 0x1c, 0xe7, 0xdf, 0x38, 0x07, 0x0d, 0x38, 0x51, 0x43, 0x2a, 0x96, + 0x48, 0x0d, 0xb0, 0xb4, 0x17, 0xc3, 0x68, 0x2a, 0x1d, 0x68, 0xe3, 0xe8, 0x93, 0x34, + 0x23, 0x5c, 0x0b, 0xdf, + ], + ivk: [ + 0x99, 0xc9, 0xb4, 0xb8, 0x4f, 0x4b, 0x4e, 0x35, 0x0f, 0x78, 0x7d, 0x1c, 0xf7, 0x05, + 0x1d, 0x50, 0xec, 0xc3, 0x4b, 0x1a, 0x5b, 0x20, 0xd2, 0xd2, 0x13, 0x9b, 0x4a, 0xf1, + 0xf1, 0x60, 0xe0, 0x01, + ], + default_d: [ + 0x21, 0xc9, 0x0e, 0x1c, 0x65, 0x8b, 0x3e, 0xfe, 0x86, 0xaf, 0x58, + ], + default_pk_d: [ + 0x9e, 0x64, 0x17, 0x4b, 0x4a, 0xb9, 0x81, 0x40, 0x5c, 0x32, 0x3b, 0x5e, 0x12, 0x47, + 0x59, 0x45, 0xa4, 0x6d, 0x4f, 0xed, 0xf8, 0x06, 0x08, 0x28, 0x04, 0x1c, 0xd2, 0x0e, + 0x62, 0xfd, 0x2c, 0xef, + ], + note_v: 5584102310880684544, + note_r: [ + 0x8c, 0x3e, 0x56, 0x44, 0x9d, 0xc8, 0x63, 0x54, 0xd3, 0x3b, 0x02, 0x5e, 0xf2, 0x79, + 0x34, 0x60, 0xbc, 0xb1, 0x69, 0xf3, 0x32, 0x4e, 0x4a, 0x6b, 0x64, 0xba, 0xa6, 0x08, + 0x32, 0x31, 0x57, 0x04, + ], + note_cm: [ + 0x7b, 0x48, 0xa8, 0x37, 0x5d, 0x3e, 0xbd, 0x56, 0xbc, 0x64, 0x9b, 0xb5, 0xb5, 0x24, + 0x23, 0x36, 0xc2, 0xa0, 0x5a, 0x08, 0x03, 0x23, 0x9b, 0x5b, 0x88, 0xfd, 0x92, 0x07, + 0x8f, 0xea, 0x4d, 0x04, + ], + note_pos: 1814747072, + note_nf: [ + 0xa8, 0x2f, 0x17, 0x50, 0xcc, 0x5b, 0x2b, 0xee, 0x64, 0x9a, 0x36, 0x5c, 0x04, 0x20, + 0xed, 0x87, 0x07, 0x5b, 0x88, 0x71, 0xfd, 0xa4, 0xa7, 0xf5, 0x84, 0x0d, 0x6b, 0xbe, + 0xb1, 0x7c, 0xd6, 0x20, + ], + }, + TestVector { + sk: [ + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, + ], + ask: [ + 0xeb, 0xbb, 0x40, 0xa9, 0x80, 0xba, 0x3b, 0x88, 0x60, 0x94, 0x8d, 0x01, 0x1e, 0x1b, + 0xfb, 0x4a, 0xff, 0xe1, 0x6c, 0x65, 0x2e, 0x90, 0xe9, 0x82, 0x58, 0x30, 0x2f, 0x44, + 0x64, 0xc9, 0x1e, 0x0c, + ], + nsk: [ + 0x68, 0x43, 0x1b, 0x19, 0x91, 0x04, 0x21, 0x52, 0x00, 0xb9, 0x5e, 0xe5, 0xcb, 0x71, + 0xbf, 0x8b, 0x88, 0x3a, 0x3e, 0x95, 0xb7, 0x98, 0x9c, 0xad, 0x19, 0x70, 0x63, 0x14, + 0x1e, 0xbb, 0xfd, 0x00, + ], + ovk: [ + 0x57, 0x34, 0x67, 0xa7, 0xb3, 0x0e, 0xad, 0x6c, 0xcc, 0x50, 0x47, 0x44, 0xca, 0x9e, + 0x1a, 0x28, 0x1a, 0x0d, 0x1a, 0x08, 0x73, 0x8b, 0x06, 0xa0, 0x68, 0x4f, 0xea, 0xcd, + 0x1e, 0x9d, 0x12, 0x6d, + ], + ak: [ + 0x71, 0xc3, 0x52, 0x3e, 0xec, 0xa3, 0x53, 0x11, 0xfb, 0xd5, 0xd7, 0xe7, 0xd7, 0x0b, + 0x70, 0x9d, 0x6c, 0x35, 0xa2, 0x4f, 0x26, 0x2b, 0x34, 0xbf, 0x64, 0x05, 0x9b, 0xf2, + 0xc0, 0x2e, 0x0b, 0xa8, + ], + nk: [ + 0x62, 0x44, 0x00, 0x10, 0x3b, 0x65, 0x69, 0xb7, 0x35, 0x8f, 0xe8, 0x0f, 0x6f, 0x6c, + 0xad, 0x43, 0x25, 0xde, 0xfd, 0xa9, 0xd9, 0x49, 0x9c, 0x2b, 0x8f, 0x88, 0x6a, 0x62, + 0x69, 0xa2, 0xaa, 0x52, + ], + ivk: [ + 0xdb, 0x95, 0xea, 0x8b, 0xd9, 0xf9, 0x3d, 0x41, 0xb5, 0xab, 0x2b, 0xeb, 0xc9, 0x1a, + 0x38, 0xed, 0xd5, 0x27, 0x08, 0x3e, 0x2a, 0x6e, 0xf9, 0xf3, 0xc2, 0x97, 0x02, 0xd5, + 0xff, 0x89, 0xed, 0x00, + ], + default_d: [ + 0x23, 0x3c, 0x4a, 0xb8, 0x86, 0xa5, 0x5e, 0x3b, 0xa3, 0x74, 0xc0, + ], + default_pk_d: [ + 0xb6, 0x8e, 0x9e, 0xe0, 0xc0, 0x67, 0x8d, 0x7b, 0x30, 0x36, 0x93, 0x1c, 0x83, 0x1a, + 0x25, 0x25, 0x5f, 0x7e, 0xe4, 0x87, 0x38, 0x5a, 0x30, 0x31, 0x6e, 0x15, 0xf6, 0x48, + 0x2b, 0x87, 0x4f, 0xda, + ], + note_v: 17811330145809239872, + note_r: [ + 0x6e, 0xbb, 0xed, 0x74, 0x36, 0x19, 0xa2, 0x56, 0xf9, 0xad, 0x2e, 0x85, 0x88, 0x0c, + 0xfa, 0xa9, 0x09, 0x8a, 0x5f, 0xdb, 0x16, 0x29, 0x99, 0x0d, 0x9a, 0x7d, 0x3b, 0xb9, + 0x3f, 0xc9, 0x00, 0x03, + ], + note_cm: [ + 0xd3, 0x76, 0xa7, 0xbe, 0xe8, 0xce, 0x67, 0xf4, 0xef, 0xde, 0x56, 0xaa, 0x77, 0xcf, + 0x64, 0x41, 0x9b, 0x0e, 0x55, 0x0a, 0xbb, 0xcb, 0x8e, 0x2b, 0xcb, 0xda, 0x8b, 0x63, + 0xe4, 0x1d, 0xeb, 0x37, + ], + note_pos: 2578461368, + note_nf: [ + 0x65, 0x36, 0x74, 0x87, 0x3b, 0x3c, 0x67, 0x0c, 0x58, 0x85, 0x84, 0x73, 0xe7, 0xfe, + 0x72, 0x19, 0x72, 0xfb, 0x96, 0xe2, 0x15, 0xb8, 0x73, 0x77, 0xa1, 0x7c, 0xa3, 0x71, + 0x0d, 0x93, 0xc9, 0xe9, + ], + }, + ]; + + for tv in test_vectors { + let mut ask_repr = FsRepr::default(); + let mut nsk_repr = FsRepr::default(); + ask_repr.read_le(&tv.ask[..]).unwrap(); + nsk_repr.read_le(&tv.nsk[..]).unwrap(); + let nsk = ::Fs::from_repr(nsk_repr).unwrap(); + + let ak = JUBJUB + .generator(FixedGenerators::SpendingKeyGenerator) + .mul(ask_repr.clone(), &JUBJUB); + { + let mut vec = Vec::new(); + ak.write(&mut vec).unwrap(); + assert_eq!(&vec, &tv.ak); + } + { + let mut ak = [0u8; 32]; + librustzcash_ask_to_ak(&tv.ask, &mut ak); + assert_eq!(&ak, &tv.ak); + } + + let pgk = ProofGenerationKey { ak, nsk }; + let fvk = pgk.to_viewing_key(&JUBJUB); + { + let mut vec = Vec::new(); + fvk.nk.write(&mut vec).unwrap(); + assert_eq!(&vec, &tv.nk); + } + { + let mut nk = [0u8; 32]; + librustzcash_nsk_to_nk(&tv.nsk, &mut nk); + assert_eq!(&nk, &tv.nk); + } + + { + let mut vec = Vec::new(); + fvk.ivk().into_repr().write_le(&mut vec).unwrap(); + assert_eq!(&vec, &tv.ivk); + } + { + let mut ivk = [0u8; 32]; + librustzcash_crh_ivk(&tv.ak, &tv.nk, &mut ivk); + assert_eq!(&ivk, &tv.ivk); + } + + let diversifier = Diversifier(tv.default_d); + assert!(librustzcash_check_diversifier(&tv.default_d)); + + let addr = fvk.to_payment_address(diversifier, &JUBJUB).unwrap(); + { + let mut vec = Vec::new(); + addr.pk_d().write(&mut vec).unwrap(); + assert_eq!(&vec, &tv.default_pk_d); + } + { + let mut default_pk_d = [0u8; 32]; + librustzcash_ivk_to_pkd(&tv.ivk, &tv.default_d, &mut default_pk_d); + assert_eq!(&default_pk_d, &tv.default_pk_d); + } + + let mut note_r_repr = FsRepr::default(); + note_r_repr.read_le(&tv.note_r[..]).unwrap(); + let note_r = ::Fs::from_repr(note_r_repr).unwrap(); + let note = addr.create_note(tv.note_v, note_r, &JUBJUB).unwrap(); + { + let mut vec = Vec::new(); + note.cm(&JUBJUB).into_repr().write_le(&mut vec).unwrap(); + assert_eq!(&vec, &tv.note_cm); + } + + assert_eq!(note.nf(&fvk, tv.note_pos, &JUBJUB), tv.note_nf); + } +} diff --git a/src/rust/src/tests/mod.rs b/src/rust/src/tests/mod.rs new file mode 100644 index 000000000..dba738767 --- /dev/null +++ b/src/rust/src/tests/mod.rs @@ -0,0 +1,96 @@ +use zcash_primitives::jubjub::{FixedGenerators, JubjubParams}; + +use super::JUBJUB; + +mod key_agreement; +mod key_components; +mod notes; +mod signatures; + +#[test] +fn sapling_generators() { + struct SaplingGenerators { + skb: [u8; 32], + pkb: [u8; 32], + npb: [u8; 32], + wprb: [u8; 32], + vcvb: [u8; 32], + vcrb: [u8; 32], + }; + + // From https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/sapling_generators.py + let sapling_generators = SaplingGenerators { + skb: [ + 0x30, 0xb5, 0xf2, 0xaa, 0xad, 0x32, 0x56, 0x30, 0xbc, 0xdd, 0xdb, 0xce, 0x4d, 0x67, + 0x65, 0x6d, 0x05, 0xfd, 0x1c, 0xc2, 0xd0, 0x37, 0xbb, 0x53, 0x75, 0xb6, 0xe9, 0x6d, + 0x9e, 0x01, 0xa1, 0xd7, + ], + pkb: [ + 0xe7, 0xe8, 0x5d, 0xe0, 0xf7, 0xf9, 0x7a, 0x46, 0xd2, 0x49, 0xa1, 0xf5, 0xea, 0x51, + 0xdf, 0x50, 0xcc, 0x48, 0x49, 0x0f, 0x84, 0x01, 0xc9, 0xde, 0x7a, 0x2a, 0xdf, 0x18, + 0x07, 0xd1, 0xb6, 0xd4, + ], + npb: [ + 0x65, 0x00, 0x2b, 0xc7, 0x36, 0xfa, 0xf7, 0xa3, 0x42, 0x2e, 0xff, 0xff, 0xe8, 0xb8, + 0x55, 0xe1, 0x8f, 0xba, 0x96, 0xa0, 0x15, 0x8a, 0x9e, 0xfc, 0xa5, 0x84, 0xbf, 0x40, + 0x54, 0x9d, 0x36, 0xe1, + ], + wprb: [ + 0xac, 0x77, 0x6c, 0x79, 0x65, 0x63, 0xfc, 0xd4, 0x4c, 0xc4, 0x9c, 0xfa, 0xea, 0x8b, + 0xb7, 0x96, 0x95, 0x2c, 0x26, 0x6e, 0x47, 0x77, 0x9d, 0x94, 0x57, 0x4c, 0x10, 0xad, + 0x01, 0x75, 0x4b, 0x11, + ], + vcvb: [ + 0xd7, 0xc8, 0x67, 0x06, 0xf5, 0x81, 0x7a, 0xa7, 0x18, 0xcd, 0x1c, 0xfa, 0xd0, 0x32, + 0x33, 0xbc, 0xd6, 0x4a, 0x77, 0x89, 0xfd, 0x94, 0x22, 0xd3, 0xb1, 0x7a, 0xf6, 0x82, + 0x3a, 0x7e, 0x6a, 0xc6, + ], + vcrb: [ + 0x8b, 0x6a, 0x0b, 0x38, 0xb9, 0xfa, 0xae, 0x3c, 0x3b, 0x80, 0x3b, 0x47, 0xb0, 0xf1, + 0x46, 0xad, 0x50, 0xab, 0x22, 0x1e, 0x6e, 0x2a, 0xfb, 0xe6, 0xdb, 0xde, 0x45, 0xcb, + 0xa9, 0xd3, 0x81, 0xed, + ], + }; + + { + let mut vec = Vec::new(); + let p = JUBJUB.generator(FixedGenerators::SpendingKeyGenerator); + p.write(&mut vec).unwrap(); + assert_eq!(&vec, &sapling_generators.skb); + } + + { + let mut vec = Vec::new(); + let p = JUBJUB.generator(FixedGenerators::ProofGenerationKey); + p.write(&mut vec).unwrap(); + assert_eq!(&vec, &sapling_generators.pkb); + } + + { + let mut vec = Vec::new(); + let p = JUBJUB.generator(FixedGenerators::NullifierPosition); + p.write(&mut vec).unwrap(); + assert_eq!(&vec, &sapling_generators.npb); + } + + { + let mut vec = Vec::new(); + let p = JUBJUB.generator(FixedGenerators::NoteCommitmentRandomness); + p.write(&mut vec).unwrap(); + assert_eq!(&vec, &sapling_generators.wprb); + } + + { + let mut vec = Vec::new(); + let p = JUBJUB.generator(FixedGenerators::ValueCommitmentValue); + p.write(&mut vec).unwrap(); + assert_eq!(&vec, &sapling_generators.vcvb); + } + + { + let mut vec = Vec::new(); + let p = JUBJUB.generator(FixedGenerators::ValueCommitmentRandomness); + p.write(&mut vec).unwrap(); + assert_eq!(&vec, &sapling_generators.vcrb); + } +} diff --git a/src/rust/src/tests/notes.rs b/src/rust/src/tests/notes.rs new file mode 100644 index 000000000..6b48b5ff8 --- /dev/null +++ b/src/rust/src/tests/notes.rs @@ -0,0 +1,673 @@ +use crate::librustzcash_sapling_compute_cm; +use crate::librustzcash_sapling_compute_nf; + +#[test] +fn notes() { + #![allow(dead_code)] + struct TestVector { + sk: [u8; 32], + ask: [u8; 32], + nsk: [u8; 32], + ovk: [u8; 32], + ak: [u8; 32], + nk: [u8; 32], + ivk: [u8; 32], + default_d: [u8; 11], + default_pk_d: [u8; 32], + note_v: u64, + note_r: [u8; 32], + note_cm: [u8; 32], + note_pos: u64, + note_nf: [u8; 32], + }; + + // From https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/sapling_key_components.py + let test_vectors = vec![ + TestVector { + sk: [ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + ], + ask: [ + 0x85, 0x48, 0xa1, 0x4a, 0x47, 0x3e, 0xa5, 0x47, 0xaa, 0x23, 0x78, 0x40, 0x20, 0x44, + 0xf8, 0x18, 0xcf, 0x19, 0x11, 0xcf, 0x5d, 0xd2, 0x05, 0x4f, 0x67, 0x83, 0x45, 0xf0, + 0x0d, 0x0e, 0x88, 0x06, + ], + nsk: [ + 0x30, 0x11, 0x4e, 0xa0, 0xdd, 0x0b, 0xb6, 0x1c, 0xf0, 0xea, 0xea, 0xb6, 0xec, 0x33, + 0x31, 0xf5, 0x81, 0xb0, 0x42, 0x5e, 0x27, 0x33, 0x85, 0x01, 0x26, 0x2d, 0x7e, 0xac, + 0x74, 0x5e, 0x6e, 0x05, + ], + ovk: [ + 0x98, 0xd1, 0x69, 0x13, 0xd9, 0x9b, 0x04, 0x17, 0x7c, 0xab, 0xa4, 0x4f, 0x6e, 0x4d, + 0x22, 0x4e, 0x03, 0xb5, 0xac, 0x03, 0x1d, 0x7c, 0xe4, 0x5e, 0x86, 0x51, 0x38, 0xe1, + 0xb9, 0x96, 0xd6, 0x3b, + ], + ak: [ + 0xf3, 0x44, 0xec, 0x38, 0x0f, 0xe1, 0x27, 0x3e, 0x30, 0x98, 0xc2, 0x58, 0x8c, 0x5d, + 0x3a, 0x79, 0x1f, 0xd7, 0xba, 0x95, 0x80, 0x32, 0x76, 0x07, 0x77, 0xfd, 0x0e, 0xfa, + 0x8e, 0xf1, 0x16, 0x20, + ], + nk: [ + 0xf7, 0xcf, 0x9e, 0x77, 0xf2, 0xe5, 0x86, 0x83, 0x38, 0x3c, 0x15, 0x19, 0xac, 0x7b, + 0x06, 0x2d, 0x30, 0x04, 0x0e, 0x27, 0xa7, 0x25, 0xfb, 0x88, 0xfb, 0x19, 0xa9, 0x78, + 0xbd, 0x3f, 0xd6, 0xba, + ], + ivk: [ + 0xb7, 0x0b, 0x7c, 0xd0, 0xed, 0x03, 0xcb, 0xdf, 0xd7, 0xad, 0xa9, 0x50, 0x2e, 0xe2, + 0x45, 0xb1, 0x3e, 0x56, 0x9d, 0x54, 0xa5, 0x71, 0x9d, 0x2d, 0xaa, 0x0f, 0x5f, 0x14, + 0x51, 0x47, 0x92, 0x04, + ], + default_d: [ + 0xf1, 0x9d, 0x9b, 0x79, 0x7e, 0x39, 0xf3, 0x37, 0x44, 0x58, 0x39, + ], + default_pk_d: [ + 0xdb, 0x4c, 0xd2, 0xb0, 0xaa, 0xc4, 0xf7, 0xeb, 0x8c, 0xa1, 0x31, 0xf1, 0x65, 0x67, + 0xc4, 0x45, 0xa9, 0x55, 0x51, 0x26, 0xd3, 0xc2, 0x9f, 0x14, 0xe3, 0xd7, 0x76, 0xe8, + 0x41, 0xae, 0x74, 0x15, + ], + note_v: 0, + note_r: [ + 0x39, 0x17, 0x6d, 0xac, 0x39, 0xac, 0xe4, 0x98, 0x0e, 0xcc, 0x8d, 0x77, 0x8e, 0x89, + 0x86, 0x02, 0x55, 0xec, 0x36, 0x15, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + ], + note_cm: [ + 0xcb, 0x3c, 0xf9, 0x15, 0x32, 0x70, 0xd5, 0x7e, 0xb9, 0x14, 0xc6, 0xc2, 0xbc, 0xc0, + 0x18, 0x50, 0xc9, 0xfe, 0xd4, 0x4f, 0xce, 0x08, 0x06, 0x27, 0x8f, 0x08, 0x3e, 0xf2, + 0xdd, 0x07, 0x64, 0x39, + ], + note_pos: 0, + note_nf: [ + 0x44, 0xfa, 0xd6, 0x56, 0x4f, 0xfd, 0xec, 0x9f, 0xa1, 0x9c, 0x43, 0xa2, 0x8f, 0x86, + 0x1d, 0x5e, 0xbf, 0x60, 0x23, 0x46, 0x00, 0x7d, 0xe7, 0x62, 0x67, 0xd9, 0x75, 0x27, + 0x47, 0xab, 0x40, 0x63, + ], + }, + TestVector { + sk: [ + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + ], + ask: [ + 0xc9, 0x43, 0x56, 0x29, 0xbf, 0x8b, 0xff, 0xe5, 0x5e, 0x73, 0x35, 0xec, 0x07, 0x77, + 0x18, 0xba, 0x60, 0xba, 0x28, 0xd7, 0xac, 0x37, 0x94, 0xb7, 0x4f, 0x51, 0x2c, 0x31, + 0xaf, 0x0a, 0x53, 0x04, + ], + nsk: [ + 0x11, 0xac, 0xc2, 0xea, 0xd0, 0x7b, 0x5f, 0x00, 0x8c, 0x1f, 0x0f, 0x09, 0x0c, 0xc8, + 0xdd, 0xf3, 0x35, 0x23, 0x6f, 0xf4, 0xb2, 0x53, 0xc6, 0x49, 0x56, 0x95, 0xe9, 0xd6, + 0x39, 0xda, 0xcd, 0x08, + ], + ovk: [ + 0x3b, 0x94, 0x62, 0x10, 0xce, 0x6d, 0x1b, 0x16, 0x92, 0xd7, 0x39, 0x2a, 0xc8, 0x4a, + 0x8b, 0xc8, 0xf0, 0x3b, 0x72, 0x72, 0x3c, 0x7d, 0x36, 0x72, 0x1b, 0x80, 0x9a, 0x79, + 0xc9, 0xd6, 0xe4, 0x5b, + ], + ak: [ + 0x82, 0xff, 0x5e, 0xff, 0xc5, 0x27, 0xae, 0x84, 0x02, 0x0b, 0xf2, 0xd3, 0x52, 0x01, + 0xc1, 0x02, 0x19, 0x13, 0x19, 0x47, 0xff, 0x4b, 0x96, 0xf8, 0x81, 0xa4, 0x5f, 0x2e, + 0x8a, 0xe3, 0x05, 0x18, + ], + nk: [ + 0xc4, 0x53, 0x4d, 0x84, 0x8b, 0xb9, 0x18, 0xcf, 0x4a, 0x7f, 0x8b, 0x98, 0x74, 0x0a, + 0xb3, 0xcc, 0xee, 0x58, 0x67, 0x95, 0xff, 0x4d, 0xf6, 0x45, 0x47, 0xa8, 0x88, 0x8a, + 0x6c, 0x74, 0x15, 0xd2, + ], + ivk: [ + 0xc5, 0x18, 0x38, 0x44, 0x66, 0xb2, 0x69, 0x88, 0xb5, 0x10, 0x90, 0x67, 0x41, 0x8d, + 0x19, 0x2d, 0x9d, 0x6b, 0xd0, 0xd9, 0x23, 0x22, 0x05, 0xd7, 0x74, 0x18, 0xc2, 0x40, + 0xfc, 0x68, 0xa4, 0x06, + ], + default_d: [ + 0xae, 0xf1, 0x80, 0xf6, 0xe3, 0x4e, 0x35, 0x4b, 0x88, 0x8f, 0x81, + ], + default_pk_d: [ + 0xa6, 0xb1, 0x3e, 0xa3, 0x36, 0xdd, 0xb7, 0xa6, 0x7b, 0xb0, 0x9a, 0x0e, 0x68, 0xe9, + 0xd3, 0xcf, 0xb3, 0x92, 0x10, 0x83, 0x1e, 0xa3, 0xa2, 0x96, 0xba, 0x09, 0xa9, 0x22, + 0x06, 0x0f, 0xd3, 0x8b, + ], + note_v: 12227227834928555328, + note_r: [ + 0x47, 0x8b, 0xa0, 0xee, 0x6e, 0x1a, 0x75, 0xb6, 0x00, 0x03, 0x6f, 0x26, 0xf1, 0x8b, + 0x70, 0x15, 0xab, 0x55, 0x6b, 0xed, 0xdf, 0x8b, 0x96, 0x02, 0x38, 0x86, 0x9f, 0x89, + 0xdd, 0x80, 0x4e, 0x06, + ], + note_cm: [ + 0xb5, 0x78, 0x93, 0x50, 0x0b, 0xfb, 0x85, 0xdf, 0x2e, 0x8b, 0x01, 0xac, 0x45, 0x2f, + 0x89, 0xe1, 0x0e, 0x26, 0x6b, 0xcf, 0xa3, 0x1c, 0x31, 0xb2, 0x9a, 0x53, 0xae, 0x72, + 0xca, 0xd4, 0x69, 0x50, + ], + note_pos: 763714296, + note_nf: [ + 0x67, 0x9e, 0xb0, 0xc3, 0xa7, 0x57, 0xe2, 0xae, 0x83, 0xcd, 0xb4, 0x2a, 0x1a, 0xb2, + 0x59, 0xd7, 0x83, 0x88, 0x31, 0x54, 0x19, 0xad, 0xc7, 0x1d, 0x2e, 0x37, 0x63, 0x17, + 0x4c, 0x2e, 0x9d, 0x93, + ], + }, + TestVector { + sk: [ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, + ], + ask: [ + 0xee, 0x1c, 0x3d, 0x7e, 0xfe, 0x0a, 0x78, 0x06, 0x3d, 0x6a, 0xf3, 0xd9, 0xd8, 0x12, + 0x12, 0xaf, 0x47, 0xb7, 0xc1, 0xb7, 0x61, 0xf8, 0x5c, 0xcb, 0x06, 0x6f, 0xc1, 0x1a, + 0x6a, 0x42, 0x17, 0x03, + ], + nsk: [ + 0x1d, 0x3b, 0x71, 0x37, 0x55, 0xd7, 0x48, 0x75, 0xe8, 0xea, 0x38, 0xfd, 0x16, 0x6e, + 0x76, 0xc6, 0x2a, 0x42, 0x50, 0x21, 0x6e, 0x6b, 0xbf, 0xe4, 0x8a, 0x5e, 0x2e, 0xab, + 0xad, 0x11, 0x7f, 0x0b, + ], + ovk: [ + 0x8b, 0xf4, 0x39, 0x0e, 0x28, 0xdd, 0xc9, 0x5b, 0x83, 0x02, 0xc3, 0x81, 0xd5, 0x81, + 0x0b, 0x84, 0xba, 0x8e, 0x60, 0x96, 0xe5, 0xa7, 0x68, 0x22, 0x77, 0x4f, 0xd4, 0x9f, + 0x49, 0x1e, 0x8f, 0x49, + ], + ak: [ + 0xab, 0x83, 0x57, 0x4e, 0xb5, 0xde, 0x85, 0x9a, 0x0a, 0xb8, 0x62, 0x9d, 0xec, 0x34, + 0xc7, 0xbe, 0xe8, 0xc3, 0xfc, 0x74, 0xdf, 0xa0, 0xb1, 0x9a, 0x3a, 0x74, 0x68, 0xd1, + 0x5d, 0xca, 0x64, 0xc6, + ], + nk: [ + 0x95, 0xd5, 0x80, 0x53, 0xe0, 0x59, 0x2e, 0x4a, 0x16, 0x9c, 0xc0, 0xb7, 0x92, 0x8a, + 0xaa, 0xc3, 0xde, 0x24, 0xef, 0x15, 0x31, 0xaa, 0x9e, 0xb6, 0xf4, 0xab, 0x93, 0x91, + 0x4d, 0xa8, 0xa0, 0x6e, + ], + ivk: [ + 0x47, 0x1c, 0x24, 0xa3, 0xdc, 0x87, 0x30, 0xe7, 0x50, 0x36, 0xc0, 0xa9, 0x5f, 0x3e, + 0x2f, 0x7d, 0xd1, 0xbe, 0x6f, 0xb9, 0x3a, 0xd2, 0x95, 0x92, 0x20, 0x3d, 0xef, 0x30, + 0x41, 0x95, 0x45, 0x05, + ], + default_d: [ + 0x75, 0x99, 0xf0, 0xbf, 0x9b, 0x57, 0xcd, 0x2d, 0xc2, 0x99, 0xb6, + ], + default_pk_d: [ + 0x66, 0x14, 0x17, 0x39, 0x51, 0x4b, 0x28, 0xf0, 0x5d, 0xef, 0x8a, 0x18, 0xee, 0xee, + 0x5e, 0xed, 0x4d, 0x44, 0xc6, 0x22, 0x5c, 0x3c, 0x65, 0xd8, 0x8d, 0xd9, 0x90, 0x77, + 0x08, 0x01, 0x2f, 0x5a, + ], + note_v: 6007711596147559040, + note_r: [ + 0x14, 0x7c, 0xf2, 0xb5, 0x1b, 0x4c, 0x7c, 0x63, 0xcb, 0x77, 0xb9, 0x9e, 0x8b, 0x78, + 0x3e, 0x5b, 0x51, 0x11, 0xdb, 0x0a, 0x7c, 0xa0, 0x4d, 0x6c, 0x01, 0x4a, 0x1d, 0x7d, + 0xa8, 0x3b, 0xae, 0x0a, + ], + note_cm: [ + 0xdb, 0x85, 0xa7, 0x0a, 0x98, 0x43, 0x7f, 0x73, 0x16, 0x7f, 0xc3, 0x32, 0xd5, 0xb7, + 0xb7, 0x40, 0x82, 0x96, 0x66, 0x17, 0x70, 0xb1, 0x01, 0xb0, 0xaa, 0x87, 0x83, 0x9f, + 0x4e, 0x55, 0xf1, 0x51, + ], + note_pos: 1527428592, + note_nf: [ + 0xe9, 0x8f, 0x6a, 0x8f, 0x34, 0xff, 0x49, 0x80, 0x59, 0xb3, 0xc7, 0x31, 0xb9, 0x1f, + 0x45, 0x11, 0x08, 0xc4, 0x95, 0x4d, 0x91, 0x94, 0x84, 0x36, 0x1c, 0xf9, 0xb4, 0x8f, + 0x59, 0xae, 0x1d, 0x14, + ], + }, + TestVector { + sk: [ + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, + ], + ask: [ + 0x00, 0xc3, 0xa1, 0xe1, 0xca, 0x8f, 0x4e, 0x04, 0x80, 0xee, 0x1e, 0xe9, 0x0c, 0xa7, + 0x51, 0x78, 0x79, 0xd3, 0xfc, 0x5c, 0x81, 0x5c, 0x09, 0x03, 0xe5, 0xee, 0xbc, 0x94, + 0xbb, 0x80, 0x95, 0x03, + ], + nsk: [ + 0xe6, 0x62, 0x85, 0xa5, 0xe9, 0xb6, 0x5e, 0x15, 0x7a, 0xd2, 0xfc, 0xd5, 0x43, 0xda, + 0xd9, 0x8c, 0x67, 0xa5, 0x8a, 0xbd, 0xf2, 0x87, 0xe0, 0x55, 0x06, 0xbd, 0x1c, 0x2e, + 0x59, 0xb0, 0x72, 0x0b, + ], + ovk: [ + 0x14, 0x76, 0x78, 0xe0, 0x55, 0x3b, 0x97, 0x82, 0x93, 0x47, 0x64, 0x7c, 0x5b, 0xc7, + 0xda, 0xb4, 0xcc, 0x22, 0x02, 0xb5, 0x4e, 0xc2, 0x9f, 0xd3, 0x1a, 0x3d, 0xe6, 0xbe, + 0x08, 0x25, 0xfc, 0x5e, + ], + ak: [ + 0x3c, 0x9c, 0xde, 0x7e, 0x5d, 0x0d, 0x38, 0xa8, 0x61, 0x0f, 0xaa, 0xdb, 0xcf, 0x4c, + 0x34, 0x3f, 0x5d, 0x3c, 0xfa, 0x31, 0x55, 0xa5, 0xb9, 0x46, 0x61, 0xa6, 0x75, 0x3e, + 0x96, 0xe8, 0x84, 0xea, + ], + nk: [ + 0xb7, 0x7d, 0x36, 0xf5, 0x08, 0x94, 0x1d, 0xbd, 0x61, 0xcf, 0xd0, 0xf1, 0x59, 0xee, + 0x05, 0xcf, 0xaa, 0x78, 0xa2, 0x6c, 0x94, 0x92, 0x90, 0x38, 0x06, 0xd8, 0x3b, 0x59, + 0x8d, 0x3c, 0x1c, 0x2a, + ], + ivk: [ + 0x63, 0x6a, 0xa9, 0x64, 0xbf, 0xc2, 0x3c, 0xe4, 0xb1, 0xfc, 0xf7, 0xdf, 0xc9, 0x91, + 0x79, 0xdd, 0xc4, 0x06, 0xff, 0x55, 0x40, 0x0c, 0x92, 0x95, 0xac, 0xfc, 0x14, 0xf0, + 0x31, 0xc7, 0x26, 0x00, + ], + default_d: [ + 0x1b, 0x81, 0x61, 0x4f, 0x1d, 0xad, 0xea, 0x0f, 0x8d, 0x0a, 0x58, + ], + default_pk_d: [ + 0x25, 0xeb, 0x55, 0xfc, 0xcf, 0x76, 0x1f, 0xc6, 0x4e, 0x85, 0xa5, 0x88, 0xef, 0xe6, + 0xea, 0xd7, 0x83, 0x2f, 0xb1, 0xf0, 0xf7, 0xa8, 0x31, 0x65, 0x89, 0x5b, 0xdf, 0xf9, + 0x42, 0x92, 0x5f, 0x5c, + ], + note_v: 18234939431076114368, + note_r: [ + 0x34, 0xa4, 0xb2, 0xa9, 0x14, 0x4f, 0xf5, 0xea, 0x54, 0xef, 0xee, 0x87, 0xcf, 0x90, + 0x1b, 0x5b, 0xed, 0x5e, 0x35, 0xd2, 0x1f, 0xbb, 0xd7, 0x88, 0xd5, 0xbd, 0x9d, 0x83, + 0x3e, 0x11, 0x28, 0x04, + ], + note_cm: [ + 0xe0, 0x8c, 0xe4, 0x82, 0xb3, 0xa8, 0xfb, 0x3b, 0x35, 0xcc, 0xdb, 0xe3, 0x43, 0x37, + 0xbd, 0x10, 0x5d, 0x88, 0x39, 0x21, 0x2e, 0x0d, 0x16, 0x44, 0xb9, 0xd5, 0x5c, 0xaa, + 0x60, 0xd1, 0x9b, 0x6c, + ], + note_pos: 2291142888, + note_nf: [ + 0x55, 0x47, 0xaa, 0x12, 0xff, 0x80, 0xa6, 0xb3, 0x30, 0x4e, 0x3b, 0x05, 0x86, 0x56, + 0x47, 0x2a, 0xbd, 0x2c, 0x81, 0x83, 0xb5, 0x9d, 0x07, 0x37, 0xb9, 0x3c, 0xee, 0x75, + 0x8b, 0xec, 0x47, 0xa1, + ], + }, + TestVector { + sk: [ + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, + ], + ask: [ + 0x82, 0x36, 0xd1, 0x9d, 0x32, 0x05, 0xd8, 0x55, 0x43, 0xa0, 0x68, 0x11, 0x34, 0x3f, + 0x82, 0x7b, 0x65, 0x63, 0x77, 0x0a, 0x49, 0xaa, 0x4d, 0x0c, 0xa0, 0x08, 0x18, 0x05, + 0xd4, 0xc8, 0xea, 0x0d, + ], + nsk: [ + 0x7e, 0xc1, 0xef, 0x0b, 0xed, 0x82, 0x71, 0x82, 0x72, 0xf0, 0xf4, 0x4f, 0x01, 0x7c, + 0x48, 0x41, 0x74, 0x51, 0x3d, 0x66, 0x1d, 0xd1, 0x68, 0xaf, 0x02, 0xd2, 0x09, 0x2a, + 0x1d, 0x8a, 0x05, 0x07, + ], + ovk: [ + 0x1b, 0x6e, 0x75, 0xec, 0xe3, 0xac, 0xe8, 0xdb, 0xa6, 0xa5, 0x41, 0x0d, 0x9a, 0xd4, + 0x75, 0x56, 0x68, 0xe4, 0xb3, 0x95, 0x85, 0xd6, 0x35, 0xec, 0x1d, 0xa7, 0xc8, 0xdc, + 0xfd, 0x5f, 0xc4, 0xed, + ], + ak: [ + 0x55, 0xe8, 0x83, 0x89, 0xbb, 0x7e, 0x41, 0xde, 0x13, 0x0c, 0xfa, 0x51, 0xa8, 0x71, + 0x5f, 0xde, 0x01, 0xff, 0x9c, 0x68, 0x76, 0x64, 0x7f, 0x01, 0x75, 0xad, 0x34, 0xf0, + 0x58, 0xdd, 0xe0, 0x1a, + ], + nk: [ + 0x72, 0x5d, 0x4a, 0xd6, 0xa1, 0x50, 0x21, 0xcd, 0x1c, 0x48, 0xc5, 0xee, 0x19, 0xde, + 0x6c, 0x1e, 0x76, 0x8a, 0x2c, 0xc0, 0xa9, 0xa7, 0x30, 0xa0, 0x1b, 0xb2, 0x1c, 0x95, + 0xe3, 0xd9, 0xe4, 0x3c, + ], + ivk: [ + 0x67, 0xfa, 0x2b, 0xf7, 0xc6, 0x7d, 0x46, 0x58, 0x24, 0x3c, 0x31, 0x7c, 0x0c, 0xb4, + 0x1f, 0xd3, 0x20, 0x64, 0xdf, 0xd3, 0x70, 0x9f, 0xe0, 0xdc, 0xb7, 0x24, 0xf1, 0x4b, + 0xb0, 0x1a, 0x1d, 0x04, + ], + default_d: [ + 0xfc, 0xfb, 0x68, 0xa4, 0x0d, 0x4b, 0xc6, 0xa0, 0x4b, 0x09, 0xc4, + ], + default_pk_d: [ + 0x8b, 0x2a, 0x33, 0x7f, 0x03, 0x62, 0x2c, 0x24, 0xff, 0x38, 0x1d, 0x4c, 0x54, 0x6f, + 0x69, 0x77, 0xf9, 0x05, 0x22, 0xe9, 0x2f, 0xde, 0x44, 0xc9, 0xd1, 0xbb, 0x09, 0x97, + 0x14, 0xb9, 0xdb, 0x2b, + ], + note_v: 12015423192295118080, + note_r: [ + 0xe5, 0x57, 0x85, 0x13, 0x55, 0x74, 0x7c, 0x09, 0xac, 0x59, 0x01, 0x3c, 0xbd, 0xe8, + 0x59, 0x80, 0x96, 0x4e, 0xc1, 0x84, 0x4d, 0x9c, 0x69, 0x67, 0xca, 0x0c, 0x02, 0x9c, + 0x84, 0x57, 0xbb, 0x04, + ], + note_cm: [ + 0xbd, 0xc8, 0x54, 0xbf, 0x3e, 0x7b, 0x00, 0x82, 0x1f, 0x3b, 0x8b, 0x85, 0x23, 0x8c, + 0xcf, 0x1e, 0x67, 0x15, 0xbf, 0xe7, 0x0b, 0x63, 0x2d, 0x04, 0x4b, 0x26, 0xfb, 0x2b, + 0xc7, 0x1b, 0x7f, 0x36, + ], + note_pos: 3054857184, + note_nf: [ + 0x8a, 0x9a, 0xbd, 0xa3, 0xd4, 0xef, 0x85, 0xca, 0xf2, 0x2b, 0xfa, 0xf2, 0xc4, 0x8f, + 0x62, 0x38, 0x2a, 0x73, 0xa1, 0x62, 0x4e, 0xb8, 0xeb, 0x2b, 0xd0, 0x0d, 0x27, 0x03, + 0x01, 0xbf, 0x3d, 0x13, + ], + }, + TestVector { + sk: [ + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, + ], + ask: [ + 0xea, 0xe6, 0x88, 0x4d, 0x76, 0x4a, 0x05, 0x40, 0x61, 0xa8, 0xf1, 0xc0, 0x07, 0x6c, + 0x62, 0x4d, 0xcb, 0x73, 0x87, 0x89, 0xf7, 0xad, 0x1e, 0x74, 0x08, 0xe3, 0x1f, 0x24, + 0xdf, 0xc8, 0x26, 0x07, + ], + nsk: [ + 0xfb, 0xe6, 0x10, 0xf4, 0x2a, 0x41, 0x74, 0x9f, 0x9b, 0x6e, 0x6e, 0x4a, 0x54, 0xb5, + 0xa3, 0x2e, 0xbf, 0xe8, 0xf4, 0x38, 0x00, 0x88, 0x1b, 0xa6, 0xcd, 0x13, 0xed, 0x0b, + 0x05, 0x29, 0x46, 0x01, + ], + ovk: [ + 0xc6, 0xbc, 0x1f, 0x39, 0xf0, 0xd7, 0x86, 0x31, 0x4c, 0xb2, 0x0b, 0xf9, 0xab, 0x22, + 0x85, 0x40, 0x91, 0x35, 0x55, 0xf9, 0x70, 0x69, 0x6b, 0x6d, 0x7c, 0x77, 0xbb, 0x33, + 0x23, 0x28, 0x37, 0x2a, + ], + ak: [ + 0xe6, 0x82, 0x76, 0x59, 0x14, 0xe3, 0x86, 0x4c, 0x33, 0x9e, 0x57, 0x82, 0xb8, 0x55, + 0xc0, 0xfd, 0xf4, 0x0e, 0x0d, 0xfc, 0xed, 0xb9, 0xe7, 0xb4, 0x7b, 0xc9, 0x4b, 0x90, + 0xb3, 0xa4, 0xc9, 0x88, + ], + nk: [ + 0x82, 0x25, 0x6b, 0x95, 0x62, 0x3c, 0x67, 0x02, 0x4b, 0x44, 0x24, 0xd9, 0x14, 0x00, + 0xa3, 0x70, 0xe7, 0xac, 0x8e, 0x4d, 0x15, 0x48, 0x2a, 0x37, 0x59, 0xe0, 0x0d, 0x21, + 0x97, 0x49, 0xda, 0xee, + ], + ivk: [ + 0xea, 0x3f, 0x1d, 0x80, 0xe4, 0x30, 0x7c, 0xa7, 0x3b, 0x9f, 0x37, 0x80, 0x1f, 0x91, + 0xfb, 0xa8, 0x10, 0xcc, 0x41, 0xd2, 0x79, 0xfc, 0x29, 0xf5, 0x64, 0x23, 0x56, 0x54, + 0xa2, 0x17, 0x8e, 0x03, + ], + default_d: [ + 0xeb, 0x51, 0x98, 0x82, 0xad, 0x1e, 0x5c, 0xc6, 0x54, 0xcd, 0x59, + ], + default_pk_d: [ + 0x6b, 0x27, 0xda, 0xcc, 0xb5, 0xa8, 0x20, 0x7f, 0x53, 0x2d, 0x10, 0xca, 0x23, 0x8f, + 0x97, 0x86, 0x64, 0x8a, 0x11, 0xb5, 0x96, 0x6e, 0x51, 0xa2, 0xf7, 0xd8, 0x9e, 0x15, + 0xd2, 0x9b, 0x8f, 0xdf, + ], + note_v: 5795906953514121792, + note_r: [ + 0x68, 0xf0, 0x61, 0x04, 0x60, 0x6b, 0x0c, 0x54, 0x49, 0x84, 0x5f, 0xf4, 0xc6, 0x5f, + 0x73, 0xe9, 0x0f, 0x45, 0xef, 0x5a, 0x43, 0xc9, 0xd7, 0x4c, 0xb2, 0xc8, 0x5c, 0xf5, + 0x6c, 0x94, 0xc0, 0x02, + ], + note_cm: [ + 0xe8, 0x26, 0x7d, 0x30, 0xac, 0x11, 0xc1, 0x00, 0xbc, 0x7a, 0x0f, 0xdf, 0x91, 0xf7, + 0x1d, 0x74, 0xc5, 0xbc, 0xf2, 0xe1, 0xef, 0x95, 0x66, 0x90, 0x44, 0x73, 0x01, 0x69, + 0xde, 0x1a, 0x5b, 0x4c, + ], + note_pos: 3818571480, + note_nf: [ + 0x33, 0x2a, 0xd9, 0x9e, 0xb9, 0xe9, 0x77, 0xeb, 0x62, 0x7a, 0x12, 0x2d, 0xbf, 0xb2, + 0xf2, 0x5f, 0xe5, 0x88, 0xe5, 0x97, 0x75, 0x3e, 0xc5, 0x58, 0x0f, 0xf2, 0xbe, 0x20, + 0xb6, 0xc9, 0xa7, 0xe1, + ], + }, + TestVector { + sk: [ + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, + ], + ask: [ + 0xe8, 0xf8, 0x16, 0xb4, 0xbc, 0x08, 0xa7, 0xe5, 0x66, 0x75, 0x0c, 0xc2, 0x8a, 0xfe, + 0x82, 0xa4, 0xce, 0xa9, 0xc2, 0xbe, 0xf2, 0x44, 0xfa, 0x4b, 0x13, 0xc4, 0x73, 0x9b, + 0x28, 0x07, 0x4c, 0x0d, + ], + nsk: [ + 0x32, 0x61, 0x5b, 0x13, 0x7f, 0x28, 0x01, 0xed, 0x44, 0x6e, 0x48, 0x78, 0x1a, 0xb0, + 0x63, 0x45, 0x72, 0xe1, 0x8c, 0xfb, 0x06, 0x93, 0x72, 0x1b, 0x88, 0x03, 0xc0, 0x5b, + 0x82, 0x27, 0xd1, 0x07, + ], + ovk: [ + 0xf6, 0x2c, 0x05, 0xe8, 0x48, 0xa8, 0x73, 0xef, 0x88, 0x5e, 0x12, 0xb0, 0x8c, 0x5e, + 0x7c, 0xa2, 0xf3, 0x24, 0x24, 0xba, 0xcc, 0x75, 0x4c, 0xb6, 0x97, 0x50, 0x44, 0x4d, + 0x35, 0x5f, 0x51, 0x06, + ], + ak: [ + 0xff, 0x27, 0xdb, 0x07, 0x51, 0x94, 0x5d, 0x3e, 0xe4, 0xbe, 0x9c, 0xf1, 0x5c, 0x2e, + 0xa2, 0x11, 0xb2, 0x4b, 0x16, 0x4d, 0x5f, 0x2d, 0x7d, 0xdf, 0xf5, 0xe4, 0xa0, 0x70, + 0x8f, 0x10, 0xb9, 0x5e, + ], + nk: [ + 0x94, 0x38, 0x85, 0x95, 0x9d, 0x4e, 0xf8, 0xa9, 0xcf, 0xca, 0x07, 0xc4, 0x57, 0xf0, + 0x9e, 0xc7, 0x4b, 0x96, 0xf9, 0x93, 0xd8, 0xe0, 0xfa, 0x32, 0xb1, 0x9c, 0x03, 0xe3, + 0xb0, 0x7a, 0x42, 0x0f, + ], + ivk: [ + 0xb5, 0xc5, 0x89, 0x49, 0x43, 0x95, 0x69, 0x33, 0xc0, 0xe5, 0xc1, 0x2d, 0x31, 0x1f, + 0xc1, 0x2c, 0xba, 0x58, 0x35, 0x4b, 0x5c, 0x38, 0x9e, 0xdc, 0x03, 0xda, 0x55, 0x08, + 0x4f, 0x74, 0xc2, 0x05, + ], + default_d: [ + 0xbe, 0xbb, 0x0f, 0xb4, 0x6b, 0x8a, 0xaf, 0xf8, 0x90, 0x40, 0xf6, + ], + default_pk_d: [ + 0xd1, 0x1d, 0xa0, 0x1f, 0x0b, 0x43, 0xbd, 0xd5, 0x28, 0x8d, 0x32, 0x38, 0x5b, 0x87, + 0x71, 0xd2, 0x23, 0x49, 0x3c, 0x69, 0x80, 0x25, 0x44, 0x04, 0x3f, 0x77, 0xcf, 0x1d, + 0x71, 0xc1, 0xcb, 0x8c, + ], + note_v: 18023134788442677120, + note_r: [ + 0x49, 0xf9, 0x0b, 0x47, 0xfd, 0x52, 0xfe, 0xe7, 0xc1, 0xc8, 0x1f, 0x0d, 0xcb, 0x5b, + 0x74, 0xc3, 0xfb, 0x9b, 0x3e, 0x03, 0x97, 0x6f, 0x8b, 0x75, 0x24, 0xea, 0xba, 0xd0, + 0x08, 0x89, 0x21, 0x07, + ], + note_cm: [ + 0x57, 0x2b, 0xa2, 0x05, 0x25, 0xb0, 0xac, 0x4d, 0x6d, 0xc0, 0x1a, 0xc2, 0xea, 0x10, + 0x90, 0xb6, 0xe0, 0xf2, 0xf4, 0xbf, 0x4e, 0xc4, 0xa0, 0xdb, 0x5b, 0xbc, 0xcb, 0x5b, + 0x78, 0x3a, 0x1e, 0x55, + ], + note_pos: 287318480, + note_nf: [ + 0xfc, 0x74, 0xcd, 0x0e, 0x4b, 0xe0, 0x49, 0x57, 0xb1, 0x96, 0xcf, 0x87, 0x34, 0xae, + 0x99, 0x23, 0x96, 0xaf, 0x4c, 0xfa, 0x8f, 0xec, 0xbb, 0x86, 0xf9, 0x61, 0xe6, 0xb4, + 0x07, 0xd5, 0x1e, 0x11, + ], + }, + TestVector { + sk: [ + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, + ], + ask: [ + 0x74, 0xb4, 0x4a, 0x37, 0xf1, 0x50, 0x23, 0xc0, 0x60, 0x42, 0x7e, 0x1d, 0xae, 0xa3, + 0xf6, 0x43, 0x12, 0xdd, 0x8f, 0xeb, 0x7b, 0x2c, 0xed, 0xf0, 0xdd, 0x55, 0x44, 0x49, + 0x3f, 0x87, 0x2c, 0x06, + ], + nsk: [ + 0x07, 0x5c, 0x35, 0xdb, 0x8b, 0x1b, 0x25, 0x75, 0x42, 0x23, 0xec, 0xee, 0x34, 0xab, + 0x73, 0x0d, 0xdd, 0xd1, 0xf1, 0x4a, 0x6a, 0x54, 0xf4, 0xc6, 0xf4, 0x68, 0x45, 0x3c, + 0x3c, 0x6e, 0xd6, 0x0b, + ], + ovk: [ + 0xe9, 0xe0, 0xdc, 0x1e, 0xd3, 0x11, 0xda, 0xed, 0x64, 0xbd, 0x74, 0xda, 0x5d, 0x94, + 0xfe, 0x88, 0xa6, 0xea, 0x41, 0x4b, 0x73, 0x12, 0xde, 0x3d, 0x2a, 0x78, 0xf6, 0x46, + 0x32, 0xbb, 0xe3, 0x73, + ], + ak: [ + 0x28, 0x3f, 0x9a, 0xaf, 0xa9, 0xbc, 0xb3, 0xe6, 0xce, 0x17, 0xe6, 0x32, 0x12, 0x63, + 0x4c, 0xb3, 0xee, 0x55, 0x0c, 0x47, 0x6b, 0x67, 0x6b, 0xd3, 0x56, 0xa6, 0xdf, 0x8a, + 0xdf, 0x51, 0xd2, 0x5e, + ], + nk: [ + 0xdc, 0x4c, 0x67, 0xb1, 0x0d, 0x4b, 0x0a, 0x21, 0x8d, 0xc6, 0xe1, 0x48, 0x70, 0x66, + 0x74, 0x0a, 0x40, 0x93, 0x17, 0x86, 0x6c, 0x32, 0xe6, 0x64, 0xb5, 0x0e, 0x39, 0x7a, + 0xa8, 0x03, 0x89, 0xd4, + ], + ivk: [ + 0x87, 0x16, 0xc8, 0x28, 0x80, 0xe1, 0x36, 0x83, 0xe1, 0xbb, 0x05, 0x9d, 0xd0, 0x6c, + 0x80, 0xc9, 0x01, 0x34, 0xa9, 0x6d, 0x5a, 0xfc, 0xa8, 0xaa, 0xc2, 0xbb, 0xf6, 0x8b, + 0xb0, 0x5f, 0x84, 0x02, + ], + default_d: [ + 0xad, 0x6e, 0x2e, 0x18, 0x5a, 0x31, 0x00, 0xe3, 0xa6, 0xa8, 0xb3, + ], + default_pk_d: [ + 0x32, 0xcb, 0x28, 0x06, 0xb8, 0x82, 0xf1, 0x36, 0x8b, 0x0d, 0x4a, 0x89, 0x8f, 0x72, + 0xc4, 0xc8, 0xf7, 0x28, 0x13, 0x2c, 0xc1, 0x24, 0x56, 0x94, 0x6e, 0x7f, 0x4c, 0xb0, + 0xfb, 0x05, 0x8d, 0xa9, + ], + note_v: 11803618549661680832, + note_r: [ + 0x51, 0x65, 0xaf, 0xf2, 0x2d, 0xd4, 0xed, 0x56, 0xb4, 0xd8, 0x1d, 0x1f, 0x17, 0x1c, + 0xc3, 0xd6, 0x43, 0x2f, 0xed, 0x1b, 0xeb, 0xf2, 0x0a, 0x7b, 0xea, 0xb1, 0x2d, 0xb1, + 0x42, 0xf9, 0x4a, 0x0c, + ], + note_cm: [ + 0xab, 0x7f, 0xc5, 0x66, 0x87, 0x3c, 0xcd, 0xe6, 0x71, 0xf5, 0x98, 0x27, 0x67, 0x85, + 0x60, 0xa0, 0x06, 0xf8, 0x2b, 0xb7, 0xad, 0xcd, 0x75, 0x22, 0x3f, 0xa8, 0x59, 0x36, + 0xf7, 0x8c, 0x2b, 0x23, + ], + note_pos: 1051032776, + note_nf: [ + 0xd2, 0xe8, 0x87, 0xbd, 0x85, 0x4a, 0x80, 0x2b, 0xce, 0x85, 0x70, 0x53, 0x02, 0x0f, + 0x5d, 0x3e, 0x7c, 0x8a, 0xe5, 0x26, 0x7c, 0x5b, 0x65, 0x83, 0xb3, 0xd2, 0x12, 0xcc, + 0x8b, 0xb6, 0x98, 0x90, + ], + }, + TestVector { + sk: [ + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, + ], + ask: [ + 0x03, 0x9d, 0xd9, 0x3d, 0xf3, 0x11, 0xff, 0x8f, 0xba, 0xb3, 0xfe, 0x23, 0x02, 0x19, + 0xcd, 0x42, 0xac, 0x87, 0x94, 0x84, 0xf3, 0x0b, 0x90, 0x3a, 0x3c, 0x1e, 0x67, 0xcc, + 0xca, 0x5a, 0x7b, 0x0d, + ], + nsk: [ + 0x04, 0x9f, 0xa1, 0x4f, 0x48, 0x6c, 0x75, 0xb9, 0xfa, 0xd7, 0xe3, 0xb6, 0x73, 0xa4, + 0x43, 0xdd, 0x07, 0x4e, 0xaa, 0x96, 0xed, 0xcb, 0x2a, 0x53, 0xea, 0xaa, 0xbd, 0xaf, + 0x70, 0xff, 0xbb, 0x08, + ], + ovk: [ + 0x14, 0x7d, 0xd1, 0x1d, 0x77, 0xeb, 0xa1, 0xb1, 0x63, 0x6f, 0xd6, 0x19, 0x0c, 0x62, + 0xb9, 0xa5, 0xd0, 0x48, 0x1b, 0xee, 0x7e, 0x91, 0x7f, 0xab, 0x02, 0xe2, 0x18, 0x58, + 0x06, 0x3a, 0xb5, 0x04, + ], + ak: [ + 0x36, 0x40, 0x48, 0xee, 0xdb, 0xe8, 0xca, 0x20, 0x5e, 0xb7, 0xe7, 0xba, 0x0a, 0x90, + 0x12, 0x16, 0x6c, 0x7c, 0x7b, 0xd9, 0xeb, 0x22, 0x8e, 0x08, 0x48, 0x14, 0x48, 0xc4, + 0x88, 0xaa, 0x21, 0xd2, + ], + nk: [ + 0xed, 0x60, 0xaf, 0x1c, 0xe7, 0xdf, 0x38, 0x07, 0x0d, 0x38, 0x51, 0x43, 0x2a, 0x96, + 0x48, 0x0d, 0xb0, 0xb4, 0x17, 0xc3, 0x68, 0x2a, 0x1d, 0x68, 0xe3, 0xe8, 0x93, 0x34, + 0x23, 0x5c, 0x0b, 0xdf, + ], + ivk: [ + 0x99, 0xc9, 0xb4, 0xb8, 0x4f, 0x4b, 0x4e, 0x35, 0x0f, 0x78, 0x7d, 0x1c, 0xf7, 0x05, + 0x1d, 0x50, 0xec, 0xc3, 0x4b, 0x1a, 0x5b, 0x20, 0xd2, 0xd2, 0x13, 0x9b, 0x4a, 0xf1, + 0xf1, 0x60, 0xe0, 0x01, + ], + default_d: [ + 0x21, 0xc9, 0x0e, 0x1c, 0x65, 0x8b, 0x3e, 0xfe, 0x86, 0xaf, 0x58, + ], + default_pk_d: [ + 0x9e, 0x64, 0x17, 0x4b, 0x4a, 0xb9, 0x81, 0x40, 0x5c, 0x32, 0x3b, 0x5e, 0x12, 0x47, + 0x59, 0x45, 0xa4, 0x6d, 0x4f, 0xed, 0xf8, 0x06, 0x08, 0x28, 0x04, 0x1c, 0xd2, 0x0e, + 0x62, 0xfd, 0x2c, 0xef, + ], + note_v: 5584102310880684544, + note_r: [ + 0x8c, 0x3e, 0x56, 0x44, 0x9d, 0xc8, 0x63, 0x54, 0xd3, 0x3b, 0x02, 0x5e, 0xf2, 0x79, + 0x34, 0x60, 0xbc, 0xb1, 0x69, 0xf3, 0x32, 0x4e, 0x4a, 0x6b, 0x64, 0xba, 0xa6, 0x08, + 0x32, 0x31, 0x57, 0x04, + ], + note_cm: [ + 0x7b, 0x48, 0xa8, 0x37, 0x5d, 0x3e, 0xbd, 0x56, 0xbc, 0x64, 0x9b, 0xb5, 0xb5, 0x24, + 0x23, 0x36, 0xc2, 0xa0, 0x5a, 0x08, 0x03, 0x23, 0x9b, 0x5b, 0x88, 0xfd, 0x92, 0x07, + 0x8f, 0xea, 0x4d, 0x04, + ], + note_pos: 1814747072, + note_nf: [ + 0xa8, 0x2f, 0x17, 0x50, 0xcc, 0x5b, 0x2b, 0xee, 0x64, 0x9a, 0x36, 0x5c, 0x04, 0x20, + 0xed, 0x87, 0x07, 0x5b, 0x88, 0x71, 0xfd, 0xa4, 0xa7, 0xf5, 0x84, 0x0d, 0x6b, 0xbe, + 0xb1, 0x7c, 0xd6, 0x20, + ], + }, + TestVector { + sk: [ + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, + ], + ask: [ + 0xeb, 0xbb, 0x40, 0xa9, 0x80, 0xba, 0x3b, 0x88, 0x60, 0x94, 0x8d, 0x01, 0x1e, 0x1b, + 0xfb, 0x4a, 0xff, 0xe1, 0x6c, 0x65, 0x2e, 0x90, 0xe9, 0x82, 0x58, 0x30, 0x2f, 0x44, + 0x64, 0xc9, 0x1e, 0x0c, + ], + nsk: [ + 0x68, 0x43, 0x1b, 0x19, 0x91, 0x04, 0x21, 0x52, 0x00, 0xb9, 0x5e, 0xe5, 0xcb, 0x71, + 0xbf, 0x8b, 0x88, 0x3a, 0x3e, 0x95, 0xb7, 0x98, 0x9c, 0xad, 0x19, 0x70, 0x63, 0x14, + 0x1e, 0xbb, 0xfd, 0x00, + ], + ovk: [ + 0x57, 0x34, 0x67, 0xa7, 0xb3, 0x0e, 0xad, 0x6c, 0xcc, 0x50, 0x47, 0x44, 0xca, 0x9e, + 0x1a, 0x28, 0x1a, 0x0d, 0x1a, 0x08, 0x73, 0x8b, 0x06, 0xa0, 0x68, 0x4f, 0xea, 0xcd, + 0x1e, 0x9d, 0x12, 0x6d, + ], + ak: [ + 0x71, 0xc3, 0x52, 0x3e, 0xec, 0xa3, 0x53, 0x11, 0xfb, 0xd5, 0xd7, 0xe7, 0xd7, 0x0b, + 0x70, 0x9d, 0x6c, 0x35, 0xa2, 0x4f, 0x26, 0x2b, 0x34, 0xbf, 0x64, 0x05, 0x9b, 0xf2, + 0xc0, 0x2e, 0x0b, 0xa8, + ], + nk: [ + 0x62, 0x44, 0x00, 0x10, 0x3b, 0x65, 0x69, 0xb7, 0x35, 0x8f, 0xe8, 0x0f, 0x6f, 0x6c, + 0xad, 0x43, 0x25, 0xde, 0xfd, 0xa9, 0xd9, 0x49, 0x9c, 0x2b, 0x8f, 0x88, 0x6a, 0x62, + 0x69, 0xa2, 0xaa, 0x52, + ], + ivk: [ + 0xdb, 0x95, 0xea, 0x8b, 0xd9, 0xf9, 0x3d, 0x41, 0xb5, 0xab, 0x2b, 0xeb, 0xc9, 0x1a, + 0x38, 0xed, 0xd5, 0x27, 0x08, 0x3e, 0x2a, 0x6e, 0xf9, 0xf3, 0xc2, 0x97, 0x02, 0xd5, + 0xff, 0x89, 0xed, 0x00, + ], + default_d: [ + 0x23, 0x3c, 0x4a, 0xb8, 0x86, 0xa5, 0x5e, 0x3b, 0xa3, 0x74, 0xc0, + ], + default_pk_d: [ + 0xb6, 0x8e, 0x9e, 0xe0, 0xc0, 0x67, 0x8d, 0x7b, 0x30, 0x36, 0x93, 0x1c, 0x83, 0x1a, + 0x25, 0x25, 0x5f, 0x7e, 0xe4, 0x87, 0x38, 0x5a, 0x30, 0x31, 0x6e, 0x15, 0xf6, 0x48, + 0x2b, 0x87, 0x4f, 0xda, + ], + note_v: 17811330145809239872, + note_r: [ + 0x6e, 0xbb, 0xed, 0x74, 0x36, 0x19, 0xa2, 0x56, 0xf9, 0xad, 0x2e, 0x85, 0x88, 0x0c, + 0xfa, 0xa9, 0x09, 0x8a, 0x5f, 0xdb, 0x16, 0x29, 0x99, 0x0d, 0x9a, 0x7d, 0x3b, 0xb9, + 0x3f, 0xc9, 0x00, 0x03, + ], + note_cm: [ + 0xd3, 0x76, 0xa7, 0xbe, 0xe8, 0xce, 0x67, 0xf4, 0xef, 0xde, 0x56, 0xaa, 0x77, 0xcf, + 0x64, 0x41, 0x9b, 0x0e, 0x55, 0x0a, 0xbb, 0xcb, 0x8e, 0x2b, 0xcb, 0xda, 0x8b, 0x63, + 0xe4, 0x1d, 0xeb, 0x37, + ], + note_pos: 2578461368, + note_nf: [ + 0x65, 0x36, 0x74, 0x87, 0x3b, 0x3c, 0x67, 0x0c, 0x58, 0x85, 0x84, 0x73, 0xe7, 0xfe, + 0x72, 0x19, 0x72, 0xfb, 0x96, 0xe2, 0x15, 0xb8, 0x73, 0x77, 0xa1, 0x7c, 0xa3, 0x71, + 0x0d, 0x93, 0xc9, 0xe9, + ], + }, + ]; + + for tv in test_vectors { + // Compute commitment and compare with test vector + let mut result = [0u8; 32]; + assert!(librustzcash_sapling_compute_cm( + &tv.default_d, + &tv.default_pk_d, + tv.note_v, + &tv.note_r, + &mut result + )); + assert_eq!(&result, &tv.note_cm); + + // Compute nullifier and compare with test vector + assert!(librustzcash_sapling_compute_nf( + &tv.default_d, + &tv.default_pk_d, + tv.note_v, + &tv.note_r, + &tv.ak, + &tv.nk, + tv.note_pos, + &mut result + )); + assert_eq!(&result, &tv.note_nf); + } +} diff --git a/src/rust/src/tests/signatures.rs b/src/rust/src/tests/signatures.rs new file mode 100644 index 000000000..68ac7997c --- /dev/null +++ b/src/rust/src/tests/signatures.rs @@ -0,0 +1,514 @@ +use ff::{PrimeField, PrimeFieldRepr}; +use pairing::bls12_381::Bls12; +use zcash_primitives::jubjub::{FixedGenerators, JubjubEngine}; +use zcash_primitives::redjubjub::{PrivateKey, PublicKey, Signature}; + +use super::JUBJUB; + +#[test] +fn redjubjub_signatures() { + struct TestVector { + sk: [u8; 32], + vk: [u8; 32], + alpha: [u8; 32], + rsk: [u8; 32], + rvk: [u8; 32], + m: [u8; 32], + sig: [u8; 64], + rsig: [u8; 64], + }; + + // From https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/sapling_signatures.py + let test_vectors = vec![ + TestVector { + sk: [ + 0x18, 0xe2, 0x8d, 0xea, 0x5c, 0x11, 0x81, 0x7a, 0xee, 0xb2, 0x1a, 0x19, 0x98, 0x1d, + 0x28, 0x36, 0x8e, 0xc4, 0x38, 0xaf, 0xc2, 0x5a, 0x8d, 0xb9, 0x4e, 0xbe, 0x08, 0xd7, + 0xa0, 0x28, 0x8e, 0x09, + ], + vk: [ + 0x9b, 0x01, 0x53, 0xb0, 0x3d, 0x32, 0x0f, 0xe2, 0x3e, 0x28, 0x34, 0xd5, 0xd6, 0x1d, + 0xbb, 0x1f, 0x51, 0x9b, 0x3f, 0x41, 0xf8, 0xf9, 0x46, 0x15, 0x2b, 0xf0, 0xc3, 0xf2, + 0x47, 0xd1, 0x18, 0x07, + ], + alpha: [ + 0xff, 0xd1, 0xa1, 0x27, 0x32, 0x52, 0xb1, 0x87, 0xf4, 0xed, 0x32, 0x6d, 0xfc, 0x98, + 0x85, 0x3e, 0x29, 0x17, 0xc2, 0xb3, 0x63, 0x79, 0xb1, 0x75, 0xda, 0x63, 0xb9, 0xef, + 0x6d, 0xda, 0x6c, 0x08, + ], + rsk: [ + 0x60, 0x87, 0x38, 0x3b, 0x30, 0x55, 0x9b, 0x31, 0x60, 0x90, 0x85, 0xb9, 0x00, 0x96, + 0x45, 0xce, 0xb6, 0xa0, 0xc6, 0x61, 0x25, 0x99, 0xd7, 0x28, 0x80, 0x72, 0x8e, 0x61, + 0x24, 0x4e, 0x7d, 0x03, + ], + rvk: [ + 0xc1, 0xba, 0xbc, 0xb6, 0xea, 0xe2, 0xb9, 0x94, 0xee, 0x6d, 0x65, 0xc1, 0x0b, 0x9d, + 0xad, 0x59, 0x40, 0xdc, 0x73, 0x5b, 0x07, 0x50, 0x4d, 0xae, 0xd1, 0xe4, 0x6b, 0x07, + 0x09, 0xb4, 0x51, 0x36, + ], + m: [ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + ], + sig: [ + 0xea, 0xa0, 0x57, 0x47, 0x6b, 0x4a, 0xb4, 0x82, 0x28, 0x8b, 0x93, 0xdf, 0x8f, 0xe0, + 0xc5, 0xce, 0x9d, 0x78, 0x83, 0x67, 0xf2, 0xbe, 0x55, 0x1b, 0x7f, 0x7a, 0x82, 0xa6, + 0xdb, 0x36, 0x04, 0x68, 0xde, 0xb9, 0xa7, 0xb7, 0xaf, 0xaa, 0xdf, 0xec, 0xa6, 0xf4, + 0x81, 0x19, 0x3d, 0xc6, 0x57, 0x57, 0x47, 0xf6, 0x0a, 0x1a, 0x8a, 0x48, 0xff, 0x0a, + 0xd7, 0x0c, 0xf8, 0xcb, 0x8d, 0x52, 0x8e, 0x08, + ], + rsig: [ + 0xd5, 0x6f, 0x0d, 0x91, 0xaf, 0x42, 0x4e, 0x1f, 0x1c, 0x7f, 0xb8, 0x6b, 0xa4, 0xee, + 0xd1, 0x43, 0xcc, 0x16, 0x66, 0x0c, 0x5f, 0xe8, 0xd7, 0xdc, 0x0d, 0x28, 0x4b, 0xcf, + 0x65, 0xa0, 0x89, 0xe9, 0x8b, 0x56, 0x1f, 0x9f, 0x20, 0x1a, 0x63, 0x3d, 0x70, 0x0c, + 0xd3, 0x98, 0x1e, 0x8c, 0xac, 0x07, 0xb5, 0xa8, 0x7e, 0xfa, 0x61, 0x86, 0x06, 0x2d, + 0xd8, 0xe5, 0xd6, 0x32, 0x5e, 0x7b, 0x82, 0x02, + ], + }, + TestVector { + sk: [ + 0x05, 0x96, 0x54, 0xf9, 0x61, 0x27, 0x3d, 0xaf, 0xda, 0x3b, 0x26, 0x77, 0xb3, 0x5c, + 0x18, 0xaf, 0x6b, 0x11, 0xad, 0xfb, 0x9e, 0xe9, 0x0b, 0x48, 0x93, 0x5e, 0x55, 0x7c, + 0x8d, 0x5d, 0x9c, 0x04, + ], + vk: [ + 0xfa, 0xf6, 0xc3, 0xb7, 0x37, 0xe8, 0xe6, 0x11, 0xaa, 0xfe, 0xa5, 0x2f, 0x03, 0xbb, + 0x27, 0x86, 0xe1, 0x83, 0x53, 0xeb, 0xe0, 0xd3, 0x13, 0x9e, 0x3c, 0x54, 0x49, 0x87, + 0x80, 0xc8, 0xc1, 0x99, + ], + alpha: [ + 0xc3, 0x0b, 0x96, 0x20, 0x8d, 0xa8, 0x00, 0xe1, 0x0a, 0xf0, 0x25, 0x42, 0xce, 0x69, + 0x4b, 0x7e, 0xd7, 0x6a, 0x28, 0x29, 0x9f, 0x85, 0x99, 0x8e, 0x5d, 0x61, 0x08, 0x12, + 0x68, 0x1b, 0xf0, 0x03, + ], + rsk: [ + 0xc8, 0xa1, 0xea, 0x19, 0xef, 0xcf, 0x3d, 0x90, 0xe5, 0x2b, 0x4c, 0xb9, 0x81, 0xc6, + 0x63, 0x2d, 0x43, 0x7c, 0xd5, 0x24, 0x3e, 0x6f, 0xa5, 0xd6, 0xf0, 0xbf, 0x5d, 0x8e, + 0xf5, 0x78, 0x8c, 0x08, + ], + rvk: [ + 0xd5, 0x24, 0xdc, 0xe7, 0x73, 0x40, 0x69, 0x75, 0x8a, 0x91, 0xf0, 0x07, 0xa8, 0x69, + 0x50, 0x5d, 0xfc, 0x4a, 0xba, 0x17, 0x20, 0x59, 0x4d, 0x4d, 0x74, 0xf0, 0x07, 0x70, + 0x0e, 0x62, 0xee, 0x00, + ], + m: [ + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, + ], + sig: [ + 0x22, 0x35, 0x54, 0x94, 0xa8, 0x31, 0x6a, 0xb1, 0x34, 0x73, 0xf5, 0x5e, 0x62, 0x66, + 0xb2, 0xfb, 0x41, 0x97, 0x31, 0x5e, 0xac, 0x62, 0xf8, 0x2c, 0xc7, 0x3d, 0xca, 0xca, + 0x19, 0x90, 0x90, 0xf1, 0x5b, 0xe1, 0x98, 0xce, 0x7d, 0x3f, 0x9f, 0xc8, 0xff, 0xf5, + 0x50, 0xe1, 0x08, 0x81, 0xec, 0x49, 0xff, 0x27, 0x36, 0x9e, 0x7d, 0x4f, 0xd9, 0x64, + 0x01, 0x53, 0x49, 0x2a, 0x0a, 0x06, 0x25, 0x08, + ], + rsig: [ + 0xf4, 0xb8, 0x94, 0xba, 0x84, 0xce, 0x1e, 0xc3, 0x8a, 0x63, 0x15, 0x2f, 0xc4, 0x09, + 0xf9, 0x47, 0xd6, 0x1a, 0xbb, 0x1f, 0x48, 0x91, 0x63, 0x6b, 0xc3, 0xee, 0x19, 0xef, + 0x6d, 0x4b, 0x30, 0xc0, 0xfd, 0x22, 0x86, 0x6b, 0x84, 0xff, 0xbc, 0x7e, 0x2a, 0x78, + 0xc4, 0x3f, 0x57, 0x83, 0xd2, 0xd2, 0xea, 0xd0, 0x78, 0x59, 0x55, 0x03, 0x74, 0x43, + 0xc2, 0xf4, 0xd5, 0x2f, 0x78, 0x5e, 0xee, 0x07, + ], + }, + TestVector { + sk: [ + 0xad, 0xe7, 0xab, 0xb5, 0x51, 0xc7, 0x9d, 0x0f, 0x0e, 0x42, 0xef, 0x7f, 0x12, 0x06, + 0xb8, 0x77, 0x12, 0xa8, 0x4a, 0x61, 0xde, 0xa3, 0xf3, 0x7b, 0x42, 0x49, 0x6d, 0x7e, + 0xfd, 0x12, 0x52, 0x0c, + ], + vk: [ + 0x36, 0x9e, 0xa7, 0x51, 0x76, 0x2f, 0x83, 0x9d, 0x25, 0x70, 0x1a, 0x5e, 0xeb, 0x55, + 0x1e, 0xc4, 0xf0, 0x6c, 0x12, 0x90, 0xb3, 0xb9, 0xc3, 0xa7, 0x24, 0x40, 0x2d, 0xec, + 0x02, 0x73, 0x92, 0x21, + ], + alpha: [ + 0x81, 0x92, 0x25, 0x29, 0xa6, 0x3e, 0xe7, 0x43, 0xfc, 0x4f, 0xbb, 0xac, 0x45, 0xc4, + 0x98, 0x83, 0x16, 0xbc, 0x9b, 0x6e, 0x42, 0x8b, 0x01, 0xa8, 0xd3, 0x1f, 0xc1, 0xc2, + 0xa6, 0xca, 0x62, 0x05, + ], + rsk: [ + 0x77, 0x4d, 0xda, 0x07, 0x99, 0xf7, 0xed, 0x82, 0x87, 0x81, 0xe2, 0x5f, 0xc4, 0xa9, + 0xe8, 0x54, 0x28, 0x29, 0xb2, 0xce, 0x1f, 0xf4, 0x8d, 0x1d, 0x6d, 0xb9, 0xfa, 0xdb, + 0xb9, 0x28, 0x37, 0x03, + ], + rvk: [ + 0x0d, 0x92, 0xad, 0x6d, 0x46, 0xed, 0xac, 0xd0, 0x23, 0xd4, 0xd2, 0xef, 0x70, 0x3a, + 0x6c, 0xa0, 0xa7, 0x92, 0xcf, 0xc4, 0xb7, 0xda, 0x11, 0xc2, 0x35, 0x3b, 0xc8, 0x45, + 0xa2, 0x7a, 0x97, 0x4d, + ], + m: [ + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, + ], + sig: [ + 0xdd, 0x65, 0x21, 0x01, 0x4d, 0xff, 0x70, 0x6e, 0x3a, 0x38, 0x52, 0x7a, 0x86, 0xb6, + 0xc1, 0x6e, 0x94, 0x14, 0x80, 0xe7, 0x33, 0xef, 0xf7, 0x9e, 0xbe, 0x0c, 0x43, 0x03, + 0x79, 0xd7, 0x57, 0x04, 0x9d, 0xb7, 0x90, 0xcd, 0x5e, 0x14, 0x44, 0x7c, 0x38, 0x6f, + 0x5f, 0xcb, 0x41, 0x9f, 0x27, 0xc4, 0x41, 0x3f, 0x35, 0x88, 0xfa, 0x21, 0x42, 0xd2, + 0xcf, 0xba, 0xed, 0x08, 0x2c, 0xc6, 0xdb, 0x07, + ], + rsig: [ + 0xd8, 0x94, 0x45, 0xcb, 0x9b, 0xd1, 0x03, 0x35, 0x69, 0x23, 0x1d, 0xd6, 0x28, 0xaa, + 0x62, 0x81, 0x09, 0xfe, 0x93, 0x50, 0x2b, 0xf2, 0x2f, 0x9a, 0x5f, 0x37, 0xb1, 0x4e, + 0x51, 0x7f, 0x9a, 0x20, 0x54, 0xae, 0xe3, 0xc8, 0x1b, 0x60, 0xb3, 0xf0, 0x55, 0x1e, + 0x32, 0xf7, 0x93, 0x5a, 0xbc, 0x2f, 0x37, 0xb9, 0x9a, 0xb3, 0xec, 0x99, 0x68, 0x02, + 0xef, 0xd6, 0x50, 0x69, 0xe1, 0x28, 0x12, 0x08, + ], + }, + TestVector { + sk: [ + 0xc9, 0xd2, 0xae, 0x1f, 0x6d, 0x32, 0xa6, 0x75, 0xd0, 0x9e, 0xb0, 0x82, 0x3f, 0x46, + 0x7f, 0xa9, 0x21, 0xb3, 0x28, 0x4a, 0xcb, 0x35, 0xfa, 0xbd, 0xfc, 0x99, 0x4d, 0xe5, + 0x49, 0xb8, 0x59, 0x0d, + ], + vk: [ + 0x2d, 0x2f, 0x31, 0x6e, 0x5c, 0x36, 0x9a, 0xe4, 0xdd, 0x2c, 0x82, 0x5f, 0x3d, 0x86, + 0x46, 0x00, 0x58, 0x40, 0x71, 0x84, 0x60, 0x3b, 0x21, 0x2c, 0xf3, 0x45, 0x9f, 0x36, + 0xc8, 0x69, 0x7f, 0xd8, + ], + alpha: [ + 0xeb, 0xbc, 0x89, 0x03, 0x11, 0x07, 0xc4, 0x4f, 0x47, 0x88, 0x9e, 0xd4, 0xd4, 0x37, + 0x5a, 0x41, 0x14, 0xcf, 0x8a, 0x75, 0xdd, 0x33, 0xb9, 0x62, 0xf2, 0xd7, 0x59, 0xd3, + 0xf4, 0xc6, 0xdf, 0x06, + ], + rsk: [ + 0xfd, 0x62, 0x41, 0x4c, 0x1f, 0x2b, 0xd3, 0xf4, 0x94, 0x16, 0x87, 0x8a, 0x80, 0x5d, + 0x71, 0x44, 0x35, 0x47, 0x7f, 0xbe, 0xa7, 0x2e, 0x4c, 0x1a, 0x46, 0xc2, 0x73, 0x53, + 0x54, 0xca, 0xbb, 0x05, + ], + rvk: [ + 0xf0, 0x43, 0x0e, 0x95, 0x3b, 0xe6, 0x0b, 0xf4, 0x38, 0xdb, 0xdc, 0xc2, 0x30, 0x3f, + 0x0e, 0x32, 0xa6, 0xf7, 0xce, 0x2f, 0xbe, 0xdf, 0xb1, 0x3a, 0xc5, 0x18, 0xf7, 0x5a, + 0x3f, 0xd1, 0x0e, 0xb5, + ], + m: [ + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, + ], + sig: [ + 0x72, 0x79, 0xa7, 0x5c, 0x01, 0x36, 0x75, 0xb3, 0x29, 0x84, 0xe5, 0xc7, 0x3a, 0x98, + 0x91, 0xeb, 0xf0, 0xb2, 0x29, 0xb1, 0x6e, 0x62, 0x35, 0xba, 0x36, 0xdf, 0xa1, 0xb5, + 0xa1, 0x0c, 0x5e, 0x44, 0x57, 0x81, 0x91, 0x89, 0x7c, 0x06, 0xb8, 0x52, 0x4a, 0x26, + 0x74, 0xaa, 0x7a, 0x0c, 0x8c, 0x23, 0x5f, 0x52, 0xd3, 0x3a, 0xc9, 0x2c, 0x70, 0x56, + 0xb2, 0xbe, 0x95, 0x3c, 0x3f, 0xaa, 0x3d, 0x07, + ], + rsig: [ + 0xaa, 0xd4, 0x82, 0x8c, 0xb3, 0x42, 0xcf, 0x09, 0xb0, 0x0e, 0x30, 0x2c, 0xbb, 0xe7, + 0xcc, 0x3e, 0x95, 0xfe, 0x1f, 0xf8, 0x28, 0x74, 0x8e, 0x5f, 0x5b, 0xc6, 0x9c, 0xbf, + 0xde, 0x6e, 0x27, 0x22, 0xd7, 0x64, 0x35, 0x68, 0x7e, 0x85, 0x0c, 0xd3, 0x07, 0xa9, + 0xc1, 0x82, 0xec, 0x10, 0xe6, 0x88, 0x1d, 0xd6, 0x5e, 0xed, 0xc1, 0x1f, 0xa7, 0xb4, + 0x6d, 0xe3, 0xa7, 0x19, 0x59, 0xce, 0xc0, 0x02, + ], + }, + TestVector { + sk: [ + 0x33, 0xbc, 0xd2, 0x86, 0x45, 0x41, 0xb8, 0xbb, 0x7f, 0xdc, 0x77, 0xa1, 0x9d, 0x97, + 0x0f, 0x92, 0x4e, 0xae, 0xec, 0xf4, 0x10, 0x3c, 0x38, 0xc8, 0xd2, 0xb0, 0x66, 0x81, + 0x42, 0xf2, 0x7d, 0x09, + ], + vk: [ + 0x74, 0x17, 0x94, 0xe6, 0x2c, 0xf9, 0x32, 0x0c, 0x58, 0xba, 0xc5, 0x94, 0xa2, 0xb9, + 0x0e, 0x34, 0x0a, 0x6d, 0x8a, 0x68, 0x05, 0x6f, 0x6e, 0xd5, 0xc7, 0x86, 0x8c, 0x5f, + 0xf3, 0xe4, 0xd6, 0x16, + ], + alpha: [ + 0x7c, 0xe7, 0x25, 0xa5, 0xfe, 0xf6, 0x1b, 0xd4, 0xa1, 0xe9, 0xc7, 0x73, 0x28, 0xe8, + 0x21, 0x0e, 0xb7, 0x29, 0x2d, 0x95, 0x4c, 0x64, 0xe9, 0x9e, 0x8b, 0xed, 0xd0, 0x7a, + 0xb3, 0xab, 0x0e, 0x0d, + ], + rsk: [ + 0xf8, 0x76, 0x01, 0x55, 0xe5, 0x29, 0x3d, 0xbf, 0x9e, 0xb5, 0x77, 0x48, 0x32, 0x5f, + 0xc9, 0xf9, 0x04, 0x9d, 0xe5, 0x88, 0x5c, 0x65, 0xba, 0x60, 0xb5, 0xee, 0x03, 0x97, + 0x0b, 0xe9, 0x0e, 0x08, + ], + rvk: [ + 0x66, 0x62, 0xba, 0x09, 0x95, 0x0a, 0xcc, 0xd2, 0xce, 0xa3, 0xc7, 0xa8, 0x12, 0x90, + 0xcd, 0x59, 0x78, 0xa6, 0x2b, 0x5a, 0xc5, 0xbb, 0xc4, 0x8d, 0x9f, 0x58, 0x19, 0xcd, + 0xc9, 0x64, 0x6f, 0x0a, + ], + m: [ + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, + ], + sig: [ + 0x51, 0x23, 0xb3, 0x1f, 0x84, 0xaf, 0x0c, 0x35, 0x5e, 0x13, 0xe7, 0x8a, 0x64, 0xd7, + 0xa3, 0xcd, 0xfd, 0x6b, 0xdf, 0xfd, 0xc7, 0x33, 0x38, 0xd9, 0x31, 0x7f, 0x73, 0x43, + 0x91, 0xa5, 0x5a, 0xe6, 0x25, 0x8f, 0x69, 0x80, 0xb9, 0xc7, 0xd1, 0x90, 0xcf, 0xa3, + 0x65, 0x81, 0xa9, 0xa4, 0x7a, 0x86, 0x3f, 0xd3, 0xbf, 0x76, 0x59, 0x42, 0x22, 0x95, + 0xb7, 0x5f, 0xd1, 0x22, 0xc3, 0xdd, 0x8a, 0x05, + ], + rsig: [ + 0x5b, 0xae, 0x25, 0x4f, 0xbd, 0xed, 0x60, 0x7a, 0x5c, 0x48, 0xb5, 0x30, 0x29, 0xf5, + 0x9b, 0xa7, 0x06, 0x32, 0x48, 0x79, 0xaa, 0x18, 0xd9, 0xc4, 0x73, 0x19, 0x00, 0x4b, + 0xe0, 0x2c, 0xec, 0xe0, 0xb8, 0xbb, 0x02, 0x4a, 0x7a, 0xab, 0xaa, 0x0a, 0x64, 0x0f, + 0x3a, 0x54, 0xdc, 0xda, 0xf2, 0x11, 0x31, 0x46, 0x9a, 0x50, 0x06, 0xbe, 0x27, 0x81, + 0xa5, 0x67, 0xff, 0xa6, 0x50, 0x3a, 0x35, 0x03, + ], + }, + TestVector { + sk: [ + 0xca, 0x35, 0x06, 0xd6, 0xaf, 0x77, 0x67, 0xb5, 0x79, 0x0e, 0xf0, 0xc5, 0x19, 0x0f, + 0xb3, 0xf3, 0x87, 0x7c, 0x4a, 0xab, 0x40, 0xe0, 0xdd, 0x65, 0x1a, 0xbb, 0xda, 0xcb, + 0x54, 0x4e, 0xd0, 0x05, + ], + vk: [ + 0xba, 0xb6, 0xcf, 0xb5, 0xc8, 0xea, 0x34, 0x91, 0x25, 0x1b, 0x46, 0xd5, 0x2a, 0xca, + 0x25, 0xd9, 0xe9, 0xaf, 0x69, 0xfa, 0xa9, 0xb4, 0xe4, 0x0b, 0x03, 0xad, 0x00, 0x86, + 0xde, 0x59, 0xb5, 0x1f, + ], + alpha: [ + 0xbe, 0xa3, 0x87, 0x20, 0x3f, 0x43, 0x76, 0x0a, 0xd3, 0x7d, 0x61, 0xde, 0x0e, 0xb5, + 0x9f, 0xca, 0x6c, 0xab, 0x75, 0x60, 0xdf, 0x64, 0xfa, 0xbb, 0x95, 0x11, 0x57, 0x9f, + 0x6f, 0x68, 0x26, 0x06, + ], + rsk: [ + 0x88, 0xd9, 0x8d, 0xf6, 0xee, 0xba, 0xdd, 0xbf, 0x4c, 0x8c, 0x51, 0xa4, 0x28, 0xc4, + 0x52, 0xbe, 0xf4, 0x27, 0xc0, 0x0b, 0x20, 0x45, 0xd8, 0x21, 0xb0, 0xcc, 0x31, 0x6b, + 0xc4, 0xb6, 0xf6, 0x0b, + ], + rvk: [ + 0x11, 0x26, 0x7d, 0x14, 0xd5, 0xe0, 0xb2, 0xbb, 0x3c, 0xe0, 0x99, 0xe8, 0xef, 0x84, + 0x49, 0x47, 0x1c, 0xbc, 0xfc, 0x69, 0x39, 0xa4, 0xb3, 0x48, 0xde, 0xa2, 0xc1, 0x73, + 0x56, 0xa1, 0xe8, 0xdd, + ], + m: [ + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, + ], + sig: [ + 0xdc, 0x18, 0xc8, 0x8d, 0x96, 0x44, 0x42, 0x40, 0x6d, 0x65, 0x0a, 0xa2, 0xff, 0xbd, + 0x83, 0xd1, 0x13, 0xbf, 0x6a, 0x19, 0xda, 0x78, 0xf2, 0x66, 0x5b, 0x29, 0x4f, 0xa5, + 0xfa, 0x45, 0x0b, 0x92, 0x81, 0xa0, 0x7e, 0x32, 0x0c, 0x1a, 0xa3, 0x1d, 0x32, 0x44, + 0x9e, 0x00, 0xc5, 0xc3, 0x2d, 0xb2, 0xf4, 0x13, 0xdf, 0x0b, 0x63, 0xd0, 0x72, 0x8f, + 0xa4, 0x09, 0x41, 0xa8, 0xda, 0x02, 0x4f, 0x01, + ], + rsig: [ + 0x59, 0xe2, 0xe8, 0x18, 0x76, 0x6c, 0x50, 0xfc, 0x8f, 0x38, 0x40, 0xb2, 0x72, 0xaf, + 0x9a, 0xd9, 0x47, 0x56, 0xc8, 0x41, 0x32, 0x95, 0xfc, 0x79, 0x5f, 0xaf, 0xbc, 0xc0, + 0x71, 0x8e, 0x6c, 0x08, 0x16, 0x9a, 0x00, 0xd5, 0x83, 0x02, 0x77, 0x2a, 0x28, 0x28, + 0x43, 0xe8, 0x88, 0xd9, 0x81, 0xfa, 0x04, 0x79, 0x5d, 0x01, 0x4c, 0xf9, 0xc8, 0xcd, + 0xb9, 0x07, 0xff, 0x1b, 0x43, 0x0d, 0x92, 0x00, + ], + }, + TestVector { + sk: [ + 0xbc, 0x27, 0x83, 0x8d, 0xe2, 0xa6, 0x14, 0xcf, 0xba, 0x6c, 0x3e, 0x92, 0x2a, 0x8f, + 0x84, 0x24, 0xd9, 0x85, 0x6f, 0x68, 0x16, 0xf3, 0xbc, 0x61, 0x02, 0x31, 0x3b, 0x7f, + 0xaf, 0x5c, 0x3a, 0x0c, + ], + vk: [ + 0xd7, 0x9b, 0xe9, 0xff, 0x22, 0x9a, 0x2e, 0x35, 0xf5, 0xbc, 0xa4, 0x48, 0xe5, 0xeb, + 0x4a, 0x8a, 0xa9, 0x7f, 0xb4, 0x18, 0x02, 0x91, 0x25, 0xcf, 0xba, 0xa7, 0x8a, 0x91, + 0xa3, 0x82, 0xb0, 0x94, + ], + alpha: [ + 0x21, 0xa7, 0x15, 0x0e, 0x19, 0x4f, 0xed, 0xfe, 0xf9, 0x0c, 0x5d, 0x10, 0xe4, 0x20, + 0x85, 0x8b, 0xca, 0x40, 0x04, 0x04, 0x0e, 0xb6, 0x81, 0xd1, 0x4e, 0x75, 0xc4, 0x47, + 0x13, 0x51, 0xcb, 0x02, + ], + rsk: [ + 0x26, 0xa2, 0xa1, 0xc4, 0x9c, 0xe7, 0x6a, 0xfd, 0x31, 0x69, 0xd3, 0xd5, 0x7a, 0x8f, + 0xa1, 0x09, 0xa3, 0x8b, 0x3f, 0x6b, 0x23, 0x6e, 0xd7, 0x2c, 0xa8, 0xf6, 0xcb, 0x61, + 0xd8, 0xf8, 0x87, 0x00, + ], + rvk: [ + 0x54, 0xbf, 0x1b, 0xe7, 0x2e, 0x6d, 0x41, 0x20, 0x8b, 0x8a, 0xec, 0x11, 0x61, 0xd3, + 0xba, 0x59, 0x51, 0x9f, 0xb9, 0x3d, 0xa0, 0x1a, 0x55, 0xe6, 0x78, 0xe2, 0x75, 0x20, + 0x06, 0x60, 0x36, 0xc9, + ], + m: [ + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, + ], + sig: [ + 0x9a, 0xf6, 0xf2, 0x80, 0x0f, 0x4b, 0x80, 0xf7, 0x93, 0xbe, 0x64, 0x8a, 0x43, 0x9f, + 0x86, 0xe5, 0x7d, 0xa1, 0xb9, 0x19, 0x99, 0x9e, 0x41, 0x91, 0x09, 0x99, 0xd4, 0x2e, + 0xd0, 0xf3, 0x89, 0x6d, 0xb7, 0x6e, 0x06, 0x38, 0x8b, 0x27, 0x2c, 0x99, 0x85, 0x8b, + 0x55, 0x04, 0xd0, 0x2e, 0xc6, 0xb4, 0xd5, 0x25, 0xb8, 0x71, 0x38, 0x10, 0x50, 0x5f, + 0x4f, 0xc0, 0x31, 0x08, 0x3a, 0x14, 0xbf, 0x09, + ], + rsig: [ + 0x3f, 0x7d, 0x50, 0x71, 0xb8, 0x76, 0x17, 0x49, 0x05, 0x71, 0xa8, 0xbe, 0x91, 0x74, + 0x9e, 0x69, 0xf6, 0xbc, 0xba, 0x5a, 0xb6, 0x26, 0xe4, 0x2f, 0xf9, 0x2d, 0x0d, 0x7d, + 0xab, 0x73, 0xf3, 0x03, 0x61, 0xe5, 0xa2, 0x24, 0x99, 0x8e, 0x1f, 0x5e, 0xa1, 0xe5, + 0xf8, 0x68, 0x9a, 0x06, 0xa2, 0x77, 0x48, 0xbf, 0x74, 0x19, 0x63, 0xef, 0x51, 0x33, + 0x22, 0xf4, 0xa1, 0xba, 0x99, 0xaa, 0x36, 0x03, + ], + }, + TestVector { + sk: [ + 0xb2, 0x08, 0x59, 0xb8, 0x8e, 0xe3, 0x33, 0x8a, 0x64, 0x95, 0x4f, 0x8a, 0x9e, 0x8e, + 0x9b, 0xf3, 0xe7, 0x11, 0x5a, 0xcf, 0x7c, 0x6e, 0x7f, 0x01, 0x43, 0x2c, 0x5f, 0x76, + 0x96, 0xd2, 0xd0, 0x05, + ], + vk: [ + 0xa8, 0x1f, 0xe6, 0x84, 0x6d, 0xbe, 0x0a, 0x75, 0xc0, 0xf4, 0x9b, 0x21, 0x32, 0x32, + 0xbe, 0xad, 0xd1, 0xf9, 0xa5, 0x64, 0x67, 0x3d, 0x25, 0xb9, 0x1e, 0xe0, 0xf1, 0x7c, + 0xe9, 0xca, 0xa3, 0x63, + ], + alpha: [ + 0x44, 0xd9, 0x08, 0xe1, 0xc1, 0x5e, 0x6b, 0xd9, 0x38, 0x0a, 0x8b, 0x23, 0x5a, 0xce, + 0x02, 0xfa, 0xc1, 0xc0, 0x87, 0x94, 0x45, 0x4b, 0xcd, 0xb4, 0xa6, 0xf4, 0x8c, 0xea, + 0x78, 0xa7, 0x4a, 0x04, + ], + rsk: [ + 0xf6, 0xe1, 0x61, 0x99, 0x50, 0x42, 0x9f, 0x63, 0x9d, 0x9f, 0xda, 0xad, 0xf8, 0x5c, + 0x9e, 0xed, 0xa9, 0xd2, 0xe1, 0x63, 0xc2, 0xb9, 0x4c, 0xb6, 0xe9, 0x20, 0xec, 0x60, + 0x0f, 0x7a, 0x1b, 0x0a, + ], + rvk: [ + 0x0b, 0x68, 0xd5, 0x0f, 0x91, 0x3c, 0xd1, 0xb7, 0x8b, 0x59, 0x92, 0x1e, 0x16, 0x56, + 0xd5, 0x76, 0xb0, 0xeb, 0x17, 0x1e, 0xd3, 0x87, 0x0d, 0x39, 0xfe, 0xc6, 0x94, 0x41, + 0xb3, 0x4b, 0x25, 0x38, + ], + m: [ + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, + ], + sig: [ + 0x64, 0x59, 0x67, 0x6a, 0x94, 0x16, 0x34, 0xec, 0xb6, 0x1e, 0x59, 0xb7, 0x9a, 0x98, + 0xab, 0xe5, 0x87, 0x6f, 0x35, 0x6f, 0x72, 0x8a, 0xa0, 0x9e, 0x0c, 0xca, 0x9e, 0xfe, + 0x05, 0x76, 0x1a, 0x33, 0x09, 0xaa, 0x88, 0xb2, 0xfa, 0x0e, 0xe2, 0xd0, 0x4c, 0x1c, + 0x46, 0xe9, 0xf2, 0xa0, 0x48, 0xd5, 0x9d, 0x55, 0x65, 0xaf, 0xa6, 0xc3, 0xf1, 0x5b, + 0xce, 0x70, 0x8d, 0xaa, 0xab, 0x7b, 0x34, 0x0e, + ], + rsig: [ + 0xc9, 0x66, 0x84, 0xec, 0x7e, 0xa6, 0x0b, 0xde, 0x87, 0x88, 0x22, 0xdd, 0xca, 0xf6, + 0xb8, 0xb0, 0xbd, 0x31, 0x98, 0x51, 0x54, 0xdf, 0x9a, 0xd4, 0xf6, 0x90, 0x7d, 0xf8, + 0xfe, 0xd9, 0x5c, 0x1d, 0x84, 0xfe, 0x67, 0xe6, 0x78, 0x75, 0xa5, 0x39, 0x55, 0x0e, + 0xb2, 0x51, 0x4f, 0x19, 0x3b, 0x8e, 0xd4, 0x57, 0x25, 0x6c, 0x8d, 0x30, 0x28, 0x1d, + 0x6f, 0x8b, 0xb9, 0x54, 0x49, 0x24, 0xca, 0x0c, + ], + }, + TestVector { + sk: [ + 0x32, 0x16, 0xae, 0x47, 0xe9, 0xf5, 0x3e, 0x8a, 0x52, 0x79, 0x6f, 0x24, 0xb6, 0x24, + 0x60, 0x77, 0x6b, 0xd5, 0xf2, 0x05, 0xa7, 0x8e, 0x15, 0x95, 0xbc, 0x8e, 0xfe, 0xdc, + 0x51, 0x9d, 0x36, 0x0b, + ], + vk: [ + 0xdf, 0x74, 0xbf, 0x04, 0x79, 0x61, 0xcc, 0x5c, 0xda, 0xc8, 0x28, 0x90, 0xc7, 0x6e, + 0xc6, 0x75, 0xbd, 0x4e, 0x89, 0xea, 0xd2, 0x80, 0xc9, 0x52, 0xd7, 0xc3, 0x3e, 0xea, + 0xf2, 0xb5, 0xa6, 0x6b, + ], + alpha: [ + 0xc9, 0x61, 0xf2, 0xdd, 0x93, 0x68, 0x2a, 0xdb, 0x93, 0xf5, 0xc0, 0x5a, 0x73, 0xfd, + 0xbc, 0x6d, 0x43, 0xc7, 0x0e, 0x1b, 0x15, 0xe8, 0xd5, 0x3e, 0x3f, 0x17, 0xa8, 0x24, + 0x94, 0xe3, 0xf2, 0x09, + ], + rsk: [ + 0x44, 0x4b, 0xa9, 0x4e, 0x1e, 0x50, 0xd2, 0x94, 0x63, 0x5e, 0x68, 0xb2, 0x95, 0x01, + 0xb5, 0x3e, 0xae, 0x61, 0xcd, 0x1f, 0xbb, 0x3b, 0x84, 0xcd, 0x52, 0xf6, 0x72, 0x9c, + 0xfb, 0xcb, 0xab, 0x06, + ], + rvk: [ + 0x0a, 0xfb, 0xe4, 0x06, 0xa8, 0x91, 0xc3, 0xb8, 0xc3, 0x10, 0xc2, 0x15, 0xbc, 0x68, + 0xa9, 0x13, 0xde, 0x7c, 0xda, 0x06, 0xaf, 0x29, 0x42, 0x00, 0x56, 0x46, 0x8d, 0x0c, + 0x08, 0x85, 0x5b, 0x28, + ], + m: [ + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, + ], + sig: [ + 0x24, 0x93, 0x2c, 0x1f, 0xaa, 0x01, 0x63, 0xca, 0x9a, 0x7f, 0xcd, 0xe4, 0x76, 0x11, + 0x29, 0xd2, 0xe5, 0xe9, 0x9c, 0xf5, 0xef, 0xa2, 0x5d, 0x27, 0x04, 0x58, 0x8e, 0x1c, + 0x75, 0x67, 0x7b, 0x5e, 0xeb, 0xe4, 0x55, 0x04, 0x8d, 0x7c, 0xe1, 0xb0, 0xd2, 0x01, + 0x27, 0x53, 0xf7, 0x1b, 0x27, 0x25, 0x01, 0x2e, 0xe1, 0x85, 0x49, 0x28, 0x73, 0x18, + 0xf9, 0xcd, 0x73, 0xf0, 0x7f, 0x0f, 0xb5, 0x02, + ], + rsig: [ + 0xf7, 0xfa, 0x26, 0xca, 0x22, 0xf3, 0x86, 0xc4, 0x3c, 0x19, 0x1a, 0x0b, 0x3e, 0xa6, + 0x57, 0x7e, 0x8e, 0xea, 0xa3, 0xf3, 0x6b, 0x9b, 0xd1, 0xa3, 0xac, 0x3d, 0xf6, 0xf8, + 0x83, 0xa3, 0xff, 0xdb, 0x31, 0x32, 0x0b, 0xde, 0x62, 0x7f, 0xf4, 0x6f, 0xc2, 0x26, + 0x4a, 0x32, 0x63, 0xb9, 0xab, 0x67, 0x12, 0x3b, 0xa5, 0xe1, 0x08, 0x43, 0x20, 0xd9, + 0x10, 0xb3, 0x94, 0xef, 0x8c, 0x65, 0xba, 0x09, + ], + }, + TestVector { + sk: [ + 0x85, 0x83, 0x6f, 0x98, 0x32, 0xb2, 0x8d, 0xe7, 0xc6, 0x36, 0x13, 0xe2, 0xa6, 0xed, + 0x36, 0xfb, 0x1a, 0xb4, 0x4f, 0xb0, 0xc1, 0x3f, 0xa8, 0x79, 0x8c, 0xd9, 0xcd, 0x30, + 0x30, 0xd4, 0x55, 0x03, + ], + vk: [ + 0xbf, 0xd5, 0xbc, 0x00, 0xc7, 0xc0, 0x22, 0xaa, 0x89, 0x01, 0xae, 0x08, 0x3c, 0x12, + 0xd5, 0x4b, 0x82, 0xf0, 0xdd, 0xff, 0x8e, 0xd6, 0xdb, 0x9a, 0x12, 0xd5, 0x9a, 0x5e, + 0xf6, 0xa5, 0xa2, 0xe0, + ], + alpha: [ + 0xa2, 0xe8, 0xb9, 0xe1, 0x6d, 0x6f, 0xf3, 0xca, 0x6c, 0x53, 0xd4, 0xe8, 0x8a, 0xbb, + 0xb9, 0x9b, 0xe7, 0xaf, 0x7e, 0x36, 0x59, 0x63, 0x1f, 0x1e, 0xae, 0x1e, 0xff, 0x23, + 0x87, 0x4d, 0x8e, 0x0c, + ], + rsk: [ + 0x70, 0x3f, 0x32, 0xa3, 0x41, 0x13, 0xea, 0xe1, 0xb0, 0x79, 0x1f, 0xfe, 0x9d, 0x88, + 0x88, 0xf0, 0x01, 0x29, 0x9a, 0xe5, 0x19, 0x68, 0x60, 0x91, 0x91, 0x48, 0x99, 0xef, + 0xcc, 0x6c, 0x66, 0x01, + ], + rvk: [ + 0xeb, 0x92, 0x97, 0x03, 0x6c, 0xf5, 0x17, 0xe1, 0x5e, 0x9e, 0xfe, 0x39, 0x75, 0x32, + 0x8d, 0xb4, 0x8e, 0xe7, 0xc2, 0x69, 0x4e, 0x94, 0x6d, 0xb2, 0x5f, 0x52, 0x87, 0x88, + 0xf6, 0xa1, 0xdb, 0x14, + ], + m: [ + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, + ], + sig: [ + 0x64, 0xab, 0xd1, 0x25, 0xbf, 0xc4, 0xc6, 0x54, 0xfa, 0xf2, 0xb6, 0xdd, 0x75, 0x3e, + 0xc6, 0x90, 0x22, 0x4d, 0xbc, 0xab, 0x8c, 0xd6, 0x32, 0xdd, 0x59, 0x3c, 0x91, 0xce, + 0x3a, 0xb0, 0xbc, 0xad, 0xca, 0x92, 0x76, 0x34, 0x02, 0x1c, 0x31, 0x47, 0x6c, 0x78, + 0xc5, 0xac, 0x7c, 0xcc, 0xab, 0xbd, 0x6f, 0x92, 0x7d, 0xf2, 0x05, 0xea, 0xa7, 0x07, + 0xcc, 0x00, 0xd4, 0x7d, 0x39, 0xf3, 0xe4, 0x0c, + ], + rsig: [ + 0xeb, 0x7a, 0x06, 0x5d, 0x75, 0xf8, 0x45, 0xdc, 0x09, 0x41, 0xb7, 0x09, 0xc0, 0xb1, + 0x49, 0xea, 0xfd, 0x80, 0x5e, 0xa5, 0x8f, 0x38, 0x0b, 0x92, 0xb9, 0xd3, 0x10, 0x8a, + 0x56, 0x1b, 0xda, 0x17, 0x85, 0xdf, 0x8f, 0x10, 0x1e, 0x0e, 0x14, 0x0f, 0xca, 0xee, + 0x99, 0xb7, 0xdb, 0xb7, 0xdf, 0xbf, 0x7e, 0x61, 0xf3, 0xa1, 0x2f, 0x46, 0x09, 0x50, + 0x69, 0xe0, 0x6e, 0x88, 0x96, 0xa9, 0xe4, 0x04, + ], + }, + ]; + + for tv in test_vectors { + let sk = PrivateKey::::read(&tv.sk[..]).unwrap(); + let vk = PublicKey::::read(&tv.vk[..], &JUBJUB).unwrap(); + let rvk = PublicKey::::read(&tv.rvk[..], &JUBJUB).unwrap(); + let sig = Signature::read(&tv.sig[..]).unwrap(); + let rsig = Signature::read(&tv.rsig[..]).unwrap(); + + let mut alpha_repr = <::Fs as PrimeField>::Repr::default(); + alpha_repr.read_le(&tv.alpha[..]).unwrap(); + let alpha = ::Fs::from_repr(alpha_repr).unwrap(); + + { + let mut vec = Vec::new(); + sk.randomize(alpha.clone()).write(&mut vec).unwrap(); + assert_eq!(&vec, &tv.rsk); + } + { + let mut vec = Vec::new(); + vk.randomize(alpha, FixedGenerators::SpendingKeyGenerator, &JUBJUB) + .write(&mut vec) + .unwrap(); + assert_eq!(&vec, &tv.rvk); + } + + assert!(vk.verify(&tv.m, &sig, FixedGenerators::SpendingKeyGenerator, &JUBJUB)); + assert!(rvk.verify(&tv.m, &rsig, FixedGenerators::SpendingKeyGenerator, &JUBJUB)); + assert!(!vk.verify(&tv.m, &rsig, FixedGenerators::SpendingKeyGenerator, &JUBJUB)); + assert!(!rvk.verify(&tv.m, &sig, FixedGenerators::SpendingKeyGenerator, &JUBJUB)); + } +} From ef81abdde392253154e9bcde33e141503b508e50 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 3 Feb 2020 19:37:13 +0000 Subject: [PATCH 2/9] Bring in Cargo.lock from librustzcash repo Source: https://github.com/zcash/librustzcash.git Revision: a57dc7f47807ea50cb0a5deec9b84b3e7da11bc0 --- src/rust/Cargo.lock | 720 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 720 insertions(+) create mode 100644 src/rust/Cargo.lock diff --git a/src/rust/Cargo.lock b/src/rust/Cargo.lock new file mode 100644 index 000000000..7a33a24e5 --- /dev/null +++ b/src/rust/Cargo.lock @@ -0,0 +1,720 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "aes" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "aes-soft" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "aesni" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "arrayref" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "arrayvec" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "autocfg" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bech32" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bellman" +version = "0.2.0" +dependencies = [ + "bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "blake2s_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ff 0.5.0", + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "group 0.2.0", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pairing 0.15.0", + "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bit-vec" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "blake2b_simd" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "blake2s_simd" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "block-cipher-trait" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "block-padding" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "byteorder" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "c2-chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cfg-if" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "constant_time_eq" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "crossbeam" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-channel" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-deque" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-queue" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crossbeam-utils" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crypto_api" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "crypto_api_chachapoly" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "crypto_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "directories" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ff" +version = "0.5.0" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ff_derive 0.4.0", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ff_derive" +version = "0.4.0" +dependencies = [ + "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fpe" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-cpupool" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "generic-array" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "getrandom" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "group" +version = "0.2.0" +dependencies = [ + "ff 0.5.0", + "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "hex-literal" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "hex-literal-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hex-literal-impl" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libc" +version = "0.2.62" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "librustzcash" +version = "0.2.0" +dependencies = [ + "bellman 0.2.0", + "blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "blake2s_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ff 0.5.0", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "pairing 0.15.0", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "zcash_primitives 0.1.0", + "zcash_proofs 0.1.0", +] + +[[package]] +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "memoffset" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "nodrop" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "num-bigint" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-integer" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-traits" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num_cpus" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "pairing" +version = "0.15.0" +dependencies = [ + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ff 0.5.0", + "group 0.2.0", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "proc-macro-hack" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro2" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quote" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_chacha" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_xorshift" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "scopeguard" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "sha2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syn" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "typenum" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wasi" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "zcash_client_backend" +version = "0.1.0" +dependencies = [ + "bech32 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pairing 0.15.0", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zcash_primitives 0.1.0", +] + +[[package]] +name = "zcash_primitives" +version = "0.1.0" +dependencies = [ + "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "blake2s_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crypto_api_chachapoly 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ff 0.5.0", + "fpe 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pairing 0.15.0", + "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "zcash_proofs" +version = "0.1.0" +dependencies = [ + "bellman 0.2.0", + "blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "ff 0.5.0", + "pairing 0.15.0", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zcash_primitives 0.1.0", +] + +[metadata] +"checksum aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "54eb1d8fe354e5fc611daf4f2ea97dd45a765f4f1e4512306ec183ae2e8f20c9" +"checksum aes-soft 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cfd7e7ae3f9a1fb5c03b389fc6bb9a51400d0c13053f0dca698c832bfd893a0d" +"checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100" +"checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" +"checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" +"checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" +"checksum bech32 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e0089c35ab7c6f2bc55ab23f769913f0ac65b1023e7e74638a1f43128dd5df2" +"checksum bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f" +"checksum blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5850aeee1552f495dd0250014cf64b82b7c8879a89d83b33bbdace2cc4f63182" +"checksum blake2s_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "979da0ce13c897d6be19e005ea77ac12b0fea0157aeeee7feb8c49f91386f0ea" +"checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +"checksum block-cipher-trait 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1c924d49bd09e7c06003acda26cd9742e796e34282ec6c1189404dee0c1f4774" +"checksum block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09" +"checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" +"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" +"checksum constant_time_eq 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "995a44c877f9212528ccc74b21a232f66ad69001e40ede5bcee2ac9ef2657120" +"checksum crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2d818a4990769aac0c7ff1360e233ef3a41adcb009ebb2036bf6915eb0f6b23c" +"checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa" +"checksum crossbeam-deque 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71" +"checksum crossbeam-epoch 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9" +"checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" +"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +"checksum crypto_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f855e87e75a4799e18b8529178adcde6fd4f97c1449ff4821e747ff728bb102" +"checksum crypto_api_chachapoly 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "95b2ad7cab08fd71addba81df5077c49df208effdfb3118a1519f9cdeac5aaf2" +"checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +"checksum directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72d337a64190607d4fcca2cb78982c5dd57f4916e19696b48a575fa746b6cb0f" +"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +"checksum fpe 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21988a326139165b75e3196bc6962ca638e5fb0c95102fbf152a3743174b01e4" +"checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" +"checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" +"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +"checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" +"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" +"checksum hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "961de220ec9a91af2e1e5bd80d02109155695e516771762381ef8581317066e0" +"checksum hex-literal-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9d4c5c844e2fee0bf673d54c2c177f1713b3d2af2ff6e666b49cb7572e6cf42d" +"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +"checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" +"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" +"checksum num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f9c3f34cdd24f334cb265d9bf8bfa8a241920d026916785747a92f0e55541a1a" +"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" +"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" +"checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" +"checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" +"checksum proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e688f31d92ffd7c1ddc57a1b4e6d773c0f2a14ee437a4b0a4f5a69c80eb221c8" +"checksum proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e98a83a9f9b331f54b924e68a66acb1bb35cb01fb0a23645139967abefb697e8" +"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +"checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" +"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" +"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +"checksum rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8" +"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" +"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +"checksum sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b4d8bfd0e469f417657573d8451fb33d16cfe0989359b93baf3a1ffc639543d" +"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" +"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" +"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" +"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" From 28b2a65c6461d62e1708d4d311b67ff6ca94ac31 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 3 Feb 2020 19:45:03 +0000 Subject: [PATCH 3/9] rust: Pin toolchain to 1.36.0, matching depends system --- src/rust/rust-toolchain | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/rust/rust-toolchain diff --git a/src/rust/rust-toolchain b/src/rust/rust-toolchain new file mode 100644 index 000000000..39fc130ef --- /dev/null +++ b/src/rust/rust-toolchain @@ -0,0 +1 @@ +1.36.0 From 62d0af94cfcc160f8f56f1e9dcb9bfe418b8911c Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 3 Feb 2020 19:45:33 +0000 Subject: [PATCH 4/9] rust: Adjust Cargo.toml so that it compiles The Cargo.lock is updated to account for the Zcash Rust crates no longer being in the same workspace. Dependencies that were not transitive dependencies of librustzcash are also removed, but no versions change. --- src/rust/Cargo.lock | 105 ++++++++++++++------------------------------ src/rust/Cargo.toml | 17 +++---- 2 files changed, 39 insertions(+), 83 deletions(-) diff --git a/src/rust/Cargo.lock b/src/rust/Cargo.lock index 7a33a24e5..f01f70e06 100644 --- a/src/rust/Cargo.lock +++ b/src/rust/Cargo.lock @@ -47,30 +47,22 @@ name = "autocfg" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "bech32" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "bellman" version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "blake2s_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.5.0", + "ff 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "group 0.2.0", - "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "group 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.15.0", - "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pairing 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -252,15 +244,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ff" version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff_derive 0.4.0", + "ff_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "ff_derive" version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", @@ -317,8 +311,9 @@ dependencies = [ [[package]] name = "group" version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ff 0.5.0", + "ff 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -328,23 +323,6 @@ name = "hex" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "hex-literal" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "hex-literal-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "hex-literal-impl" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -359,17 +337,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "librustzcash" version = "0.2.0" dependencies = [ - "bellman 0.2.0", + "bellman 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "blake2s_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.5.0", + "ff 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.15.0", + "pairing 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_primitives 0.1.0", - "zcash_proofs 0.1.0", + "zcash_primitives 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "zcash_proofs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -436,12 +414,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pairing" version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.5.0", - "group 0.2.0", + "ff 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "group 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -449,16 +427,6 @@ name = "ppv-lite86" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "proc-macro-hack" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "proc-macro2" version = "1.0.3" @@ -601,52 +569,40 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "zcash_client_backend" -version = "0.1.0" -dependencies = [ - "bech32 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.15.0", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_primitives 0.1.0", -] - [[package]] name = "zcash_primitives" version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "aes 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "blake2s_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "crypto_api_chachapoly 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.5.0", + "ff 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "fpe 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.15.0", + "pairing 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "zcash_proofs" version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bellman 0.2.0", + "bellman 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "ff 0.5.0", - "pairing 0.15.0", + "ff 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pairing 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "zcash_primitives 0.1.0", + "zcash_primitives 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] @@ -656,7 +612,7 @@ dependencies = [ "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" "checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba" "checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" -"checksum bech32 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e0089c35ab7c6f2bc55ab23f769913f0ac65b1023e7e74638a1f43128dd5df2" +"checksum bellman 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a8b3143b11715f8105882a1df9b3d36386aa8e3a6cfd573a2974c9ea9a22fea" "checksum bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f" "checksum blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5850aeee1552f495dd0250014cf64b82b7c8879a89d83b33bbdace2cc4f63182" "checksum blake2s_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "979da0ce13c897d6be19e005ea77ac12b0fea0157aeeee7feb8c49f91386f0ea" @@ -679,14 +635,15 @@ dependencies = [ "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" "checksum directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72d337a64190607d4fcca2cb78982c5dd57f4916e19696b48a575fa746b6cb0f" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +"checksum ff 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44b4c77ad8a724f1ebb882af5d2d7a2ab62f4d63c8e401d40ab0de1d75262ea3" +"checksum ff_derive 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9cb38a53026415988765d8d7d81b680187a77a486ba9e249dbccd5a3e74429b" "checksum fpe 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21988a326139165b75e3196bc6962ca638e5fb0c95102fbf152a3743174b01e4" "checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" "checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" +"checksum group 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8cbdfc48f95bef47e3daf3b9d552a1dde6311e3a5fefa43e16c59f651d56fe5b" "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" -"checksum hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "961de220ec9a91af2e1e5bd80d02109155695e516771762381ef8581317066e0" -"checksum hex-literal-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9d4c5c844e2fee0bf673d54c2c177f1713b3d2af2ff6e666b49cb7572e6cf42d" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" @@ -697,8 +654,8 @@ dependencies = [ "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +"checksum pairing 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ec7b64119b36952d5a0c7baf959ef061a07665751706f046f9f6f0f9d83d459" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" -"checksum proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e688f31d92ffd7c1ddc57a1b4e6d773c0f2a14ee437a4b0a4f5a69c80eb221c8" "checksum proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e98a83a9f9b331f54b924e68a66acb1bb35cb01fb0a23645139967abefb697e8" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" @@ -718,3 +675,5 @@ dependencies = [ "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum zcash_primitives 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9530749bc784c4ca0d7bf000333cec29acf94f1875ad8db088e12dfee1095d13" +"checksum zcash_proofs 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f12228d3bff81779e848bc7e7a68f282c717ef2f67a69e6477f4667fbb06078" diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml index 432222b00..e94dc9d83 100644 --- a/src/rust/Cargo.toml +++ b/src/rust/Cargo.toml @@ -8,8 +8,8 @@ authors = [ "Jay Graber ", "Simon Liu " ] -homepage = "https://github.com/zcash/librustzcash" -repository = "https://github.com/zcash/librustzcash" +homepage = "https://github.com/zcash/zcash" +repository = "https://github.com/zcash/zcash" readme = "README.md" license = "MIT OR Apache-2.0" edition = "2018" @@ -20,17 +20,14 @@ path = "src/rustzcash.rs" crate-type = ["staticlib"] [dependencies] -bellman = { version = "0.2.0", path = "../bellman" } +bellman = "0.2.0" blake2b_simd = "0.5" blake2s_simd = "0.5" -ff = { version = "0.5.0", path = "../ff" } +ff = "0.5.0" libc = "0.2" -pairing = { version = "0.15.0", path = "../pairing" } +pairing = "0.15.0" lazy_static = "1" byteorder = "1" rand_core = "0.5.1" -zcash_primitives = { version = "0.1.0", path = "../zcash_primitives" } -zcash_proofs = { version = "0.1.0", path = "../zcash_proofs" } - -[badges] -maintenance = { status = "deprecated" } +zcash_primitives = "0.1.0" +zcash_proofs = "0.1.0" From 72ab00fdee5bd712197c71d28ba3791fee625f05 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 3 Feb 2020 19:50:01 +0000 Subject: [PATCH 5/9] Update .gitignore for Rust code --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 935c8b268..80f7ae7b7 100644 --- a/.gitignore +++ b/.gitignore @@ -72,6 +72,9 @@ src/univalue/gen # Compilation Makefile +# Rust +src/rust/target + # Unit-tests Makefile.test src/test/buildenv.py From 90f723413600e7900f79b02640b78f574dd8b0a8 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 4 Feb 2020 12:20:49 +0000 Subject: [PATCH 6/9] Replace librustzcash from depends system with src/rust The --enable-online-rust configure flag replicates the behaviour of the LIBRUSTZCASH_OVERRIDE environment variable (enabling the build system to use crates.io instead of vendored dependencies). --- .gitignore | 2 + configure.ac | 13 ++- depends/Makefile | 1 + depends/config.site.in | 3 + depends/packages/crate_bellman.mk | 4 +- depends/packages/crate_ff.mk | 15 +++ depends/packages/crate_ff_derive.mk | 15 +++ depends/packages/crate_group.mk | 15 +++ depends/packages/crate_pairing.mk | 4 +- depends/packages/crate_zcash_primitives.mk | 15 +++ depends/packages/crate_zcash_proofs.mk | 15 +++ depends/packages/librustzcash.mk | 73 ------------- depends/packages/packages.mk | 11 +- depends/patches/librustzcash/cargo.config | 20 ---- .../librustzcash/remove-dev-dependencies.diff | 102 ------------------ src/.cargo/config.offline | 5 + src/Makefile.am | 40 ++++++- src/Makefile.bench.include | 2 +- src/Makefile.gtest.include | 2 +- src/Makefile.test.include | 2 +- 20 files changed, 153 insertions(+), 206 deletions(-) create mode 100644 depends/packages/crate_ff.mk create mode 100644 depends/packages/crate_ff_derive.mk create mode 100644 depends/packages/crate_group.mk create mode 100644 depends/packages/crate_zcash_primitives.mk create mode 100644 depends/packages/crate_zcash_proofs.mk delete mode 100644 depends/packages/librustzcash.mk delete mode 100644 depends/patches/librustzcash/cargo.config delete mode 100644 depends/patches/librustzcash/remove-dev-dependencies.diff create mode 100644 src/.cargo/config.offline diff --git a/.gitignore b/.gitignore index 80f7ae7b7..6ce5e4ded 100644 --- a/.gitignore +++ b/.gitignore @@ -73,6 +73,8 @@ src/univalue/gen Makefile # Rust +src/.cargo/.configured-for-* +src/.cargo/config src/rust/target # Unit-tests diff --git a/configure.ac b/configure.ac index d839c02f5..9958a3783 100644 --- a/configure.ac +++ b/configure.ac @@ -77,12 +77,21 @@ AC_PATH_TOOL(GCOV, gcov) AC_PATH_PROG(LCOV, lcov) AC_PATH_PROG(GENHTML, genhtml) AC_PATH_PROG([GIT], [git]) +AC_PATH_PROG(RUSTC, rustc) +AC_PATH_PROG(CARGO, cargo) AC_PATH_PROG(CCACHE,ccache) AC_PATH_PROG(XGETTEXT,xgettext) AC_PATH_PROG(HEXDUMP,hexdump) AC_PATH_TOOL(READELF,readelf) AC_PATH_TOOL(CPPFILT,c++filt) +AC_ARG_ENABLE([online-rust], + [AS_HELP_STRING([--enable-online-rust], + [enable Rust to fetch dependencies from the network (default is to use vendored dependencies)])], + [enable_online_rust=$enableval], + [enable_online_rust=no]) +AM_CONDITIONAL(ENABLE_ONLINE_RUST, test "$enable_online_rust" != no) + # Enable wallet AC_ARG_ENABLE([wallet], [AS_HELP_STRING([--disable-wallet], @@ -809,7 +818,7 @@ else fi fi -RUST_LIBS="-lrustzcash" +RUST_LIBS="" case $host in *mingw*) ;; @@ -933,6 +942,8 @@ AC_SUBST(BITCOIN_DAEMON_NAME) AC_SUBST(BITCOIN_CLI_NAME) AC_SUBST(BITCOIN_TX_NAME) +AC_SUBST(RUST_TARGET) +AC_SUBST(RUST_VENDORED_SOURCES) AC_SUBST(RELDFLAGS) AC_SUBST(DEBUG_CPPFLAGS) AC_SUBST(DEBUG_CXXFLAGS) diff --git a/depends/Makefile b/depends/Makefile index bb353182c..750f51012 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -117,6 +117,7 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_ -e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|' \ -e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \ -e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \ + -e 's|@rust_target@|$(if $(rust_rust_target_$(canonical_host)),$(rust_rust_target_$(canonical_host)),$(canonical_host))|' \ -e 's|@no_wallet@|$(NO_WALLET)|' \ -e 's|@debug@|$(DEBUG)|' \ $< > $@ diff --git a/depends/config.site.in b/depends/config.site.in index 8cdbcd2e4..dbcb7a6e4 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -13,6 +13,9 @@ if test -z $enable_wallet && test -n "@no_wallet@"; then enable_wallet=no fi +RUST_TARGET="@rust_target@" +RUST_VENDORED_SOURCES="$depends_prefix/vendored-sources" + if test x@host_os@ = xdarwin; then BREW=no PORT=no diff --git a/depends/packages/crate_bellman.mk b/depends/packages/crate_bellman.mk index 5c7d904ca..279ea677f 100644 --- a/depends/packages/crate_bellman.mk +++ b/depends/packages/crate_bellman.mk @@ -1,9 +1,9 @@ package=crate_bellman $(package)_crate_name=bellman -$(package)_version=0.1.0 +$(package)_version=0.2.0 $(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) $(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=eae372472c7ea8f7c8fc6a62f7d5535db8302de7f1aafda2e13a97c4830d3bcf +$(package)_sha256_hash=8a8b3143b11715f8105882a1df9b3d36386aa8e3a6cfd573a2974c9ea9a22fea $(package)_crate_versioned_name=$($(package)_crate_name) define $(package)_preprocess_cmds diff --git a/depends/packages/crate_ff.mk b/depends/packages/crate_ff.mk new file mode 100644 index 000000000..8b7dd1084 --- /dev/null +++ b/depends/packages/crate_ff.mk @@ -0,0 +1,15 @@ +package=crate_ff +$(package)_crate_name=ff +$(package)_version=0.5.0 +$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) +$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate +$(package)_sha256_hash=44b4c77ad8a724f1ebb882af5d2d7a2ab62f4d63c8e401d40ab0de1d75262ea3 +$(package)_crate_versioned_name=$($(package)_crate_name) + +define $(package)_preprocess_cmds + $(call generate_crate_checksum,$(package)) +endef + +define $(package)_stage_cmds + $(call vendor_crate_source,$(package)) +endef diff --git a/depends/packages/crate_ff_derive.mk b/depends/packages/crate_ff_derive.mk new file mode 100644 index 000000000..eb05c2665 --- /dev/null +++ b/depends/packages/crate_ff_derive.mk @@ -0,0 +1,15 @@ +package=crate_ff_derive +$(package)_crate_name=ff_derive +$(package)_version=0.4.0 +$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) +$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate +$(package)_sha256_hash=a9cb38a53026415988765d8d7d81b680187a77a486ba9e249dbccd5a3e74429b +$(package)_crate_versioned_name=$($(package)_crate_name) + +define $(package)_preprocess_cmds + $(call generate_crate_checksum,$(package)) +endef + +define $(package)_stage_cmds + $(call vendor_crate_source,$(package)) +endef diff --git a/depends/packages/crate_group.mk b/depends/packages/crate_group.mk new file mode 100644 index 000000000..cfe083c06 --- /dev/null +++ b/depends/packages/crate_group.mk @@ -0,0 +1,15 @@ +package=crate_group +$(package)_crate_name=group +$(package)_version=0.2.0 +$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) +$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate +$(package)_sha256_hash=8cbdfc48f95bef47e3daf3b9d552a1dde6311e3a5fefa43e16c59f651d56fe5b +$(package)_crate_versioned_name=$($(package)_crate_name) + +define $(package)_preprocess_cmds + $(call generate_crate_checksum,$(package)) +endef + +define $(package)_stage_cmds + $(call vendor_crate_source,$(package)) +endef diff --git a/depends/packages/crate_pairing.mk b/depends/packages/crate_pairing.mk index c81e23bed..c86cbca0a 100644 --- a/depends/packages/crate_pairing.mk +++ b/depends/packages/crate_pairing.mk @@ -1,9 +1,9 @@ package=crate_pairing $(package)_crate_name=pairing -$(package)_version=0.14.2 +$(package)_version=0.15.0 $(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) $(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=ceda21136251c6d5a422d3d798d8ac22515a6e8d3521bb60c59a8349d36d0d57 +$(package)_sha256_hash=0ec7b64119b36952d5a0c7baf959ef061a07665751706f046f9f6f0f9d83d459 $(package)_crate_versioned_name=$($(package)_crate_name) define $(package)_preprocess_cmds diff --git a/depends/packages/crate_zcash_primitives.mk b/depends/packages/crate_zcash_primitives.mk new file mode 100644 index 000000000..bbfefff49 --- /dev/null +++ b/depends/packages/crate_zcash_primitives.mk @@ -0,0 +1,15 @@ +package=crate_zcash_primitives +$(package)_crate_name=zcash_primitives +$(package)_version=0.1.0 +$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) +$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate +$(package)_sha256_hash=9530749bc784c4ca0d7bf000333cec29acf94f1875ad8db088e12dfee1095d13 +$(package)_crate_versioned_name=$($(package)_crate_name) + +define $(package)_preprocess_cmds + $(call generate_crate_checksum,$(package)) +endef + +define $(package)_stage_cmds + $(call vendor_crate_source,$(package)) +endef diff --git a/depends/packages/crate_zcash_proofs.mk b/depends/packages/crate_zcash_proofs.mk new file mode 100644 index 000000000..93a1d1555 --- /dev/null +++ b/depends/packages/crate_zcash_proofs.mk @@ -0,0 +1,15 @@ +package=crate_zcash_proofs +$(package)_crate_name=zcash_proofs +$(package)_version=0.1.0 +$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) +$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate +$(package)_sha256_hash=6f12228d3bff81779e848bc7e7a68f282c717ef2f67a69e6477f4667fbb06078 +$(package)_crate_versioned_name=$($(package)_crate_name) + +define $(package)_preprocess_cmds + $(call generate_crate_checksum,$(package)) +endef + +define $(package)_stage_cmds + $(call vendor_crate_source,$(package)) +endef diff --git a/depends/packages/librustzcash.mk b/depends/packages/librustzcash.mk deleted file mode 100644 index 2cad26f00..000000000 --- a/depends/packages/librustzcash.mk +++ /dev/null @@ -1,73 +0,0 @@ -package=librustzcash -$(package)_version=0.2.0 -$(package)_download_path=https://github.com/zcash/$(package)/archive/ -$(package)_file_name=$(package)-$($(package)_git_commit).tar.gz -$(package)_download_file=$($(package)_git_commit).tar.gz -$(package)_sha256_hash=dfb80e9a57d944a91092094a423a8a6631e38b602b337aad5f98dc21002ca6dc -$(package)_git_commit=a57dc7f47807ea50cb0a5deec9b84b3e7da11bc0 -$(package)_dependencies=rust -ifeq ($(LIBRUSTZCASH_OVERRIDE),) -$(package)_dependencies+=$(rust_crates) -$(package)_patches=cargo.config remove-dev-dependencies.diff -endif - -$(package)_rust_target=$(if $(rust_rust_target_$(canonical_host)),$(rust_rust_target_$(canonical_host)),$(canonical_host)) - -ifeq ($(host_os),mingw32) -$(package)_library_file=target/x86_64-pc-windows-gnu/release/rustzcash.lib -else ifneq ($(canonical_host),$(build)) -$(package)_library_file=target/$($(package)_rust_target)/release/librustzcash.a -else -$(package)_library_file=target/release/librustzcash.a -endif - -define $(package)_set_vars -$(package)_build_opts=--release -ifeq ($(LIBRUSTZCASH_OVERRIDE),) -$(package)_build_opts+=--frozen -endif -ifneq ($(canonical_host),$(build)) -$(package)_build_opts+=--target=$($(package)_rust_target) -endif -endef - -ifneq ($(LIBRUSTZCASH_OVERRIDE),) - -define $(package)_fetch_cmds -endef - -define $(package)_extract_cmds -endef - -define $(package)_build_cmds - cd $(LIBRUSTZCASH_OVERRIDE) && \ - $(host_prefix)/native/bin/cargo build --package librustzcash $($(package)_build_opts) -endef - -define $(package)_stage_cmds - mkdir $($(package)_staging_dir)$(host_prefix)/lib/ && \ - mkdir $($(package)_staging_dir)$(host_prefix)/include/ && \ - cp $(LIBRUSTZCASH_OVERRIDE)/$($(package)_library_file) $($(package)_staging_dir)$(host_prefix)/lib/ && \ - cp $(LIBRUSTZCASH_OVERRIDE)/librustzcash/include/librustzcash.h $($(package)_staging_dir)$(host_prefix)/include/ -endef - -else - -define $(package)_preprocess_cmds - patch -p1 < $($(package)_patch_dir)/remove-dev-dependencies.diff && \ - mkdir .cargo && \ - cat $($(package)_patch_dir)/cargo.config | sed 's|CRATE_REGISTRY|$(host_prefix)/$(CRATE_REGISTRY)|' > .cargo/config -endef - -define $(package)_build_cmds - $(host_prefix)/native/bin/cargo build --package librustzcash $($(package)_build_opts) -endef - -define $(package)_stage_cmds - mkdir $($(package)_staging_dir)$(host_prefix)/lib/ && \ - mkdir $($(package)_staging_dir)$(host_prefix)/include/ && \ - cp $($(package)_library_file) $($(package)_staging_dir)$(host_prefix)/lib/ && \ - cp librustzcash/include/librustzcash.h $($(package)_staging_dir)$(host_prefix)/include/ -endef - -endif diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 02e78c512..dc247e84c 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -6,6 +6,7 @@ rust_crates := \ crate_arrayvec \ crate_autocfg \ crate_bech32 \ + crate_bellman \ crate_bit_vec \ crate_blake2b_simd \ crate_blake2s_simd \ @@ -28,11 +29,14 @@ rust_crates := \ crate_digest \ crate_directories \ crate_fake_simd \ + crate_ff_derive \ + crate_ff \ crate_fpe \ crate_futures_cpupool \ crate_futures \ crate_generic_array \ crate_getrandom \ + crate_group \ crate_hex \ crate_lazy_static \ crate_libc \ @@ -44,6 +48,7 @@ rust_crates := \ crate_num_integer \ crate_num_traits \ crate_opaque_debug \ + crate_pairing \ crate_ppv_lite86 \ crate_proc_macro2 \ crate_quote \ @@ -64,8 +69,10 @@ rust_crates := \ crate_wasi \ crate_winapi_i686_pc_windows_gnu \ crate_winapi \ - crate_winapi_x86_64_pc_windows_gnu -rust_packages := rust $(rust_crates) librustzcash + crate_winapi_x86_64_pc_windows_gnu \ + crate_zcash_primitives \ + crate_zcash_proofs +rust_packages := rust $(rust_crates) proton_packages := proton zcash_packages := libsodium utfcpp packages := boost openssl libevent zeromq $(zcash_packages) googletest diff --git a/depends/patches/librustzcash/cargo.config b/depends/patches/librustzcash/cargo.config deleted file mode 100644 index 84d447afb..000000000 --- a/depends/patches/librustzcash/cargo.config +++ /dev/null @@ -1,20 +0,0 @@ -[source.crates-io] -replace-with = "vendored-sources" - -[source."https://github.com/gtank/blake2-rfc"] -git = "https://github.com/gtank/blake2-rfc" -rev = "7a5b5fc99ae483a0043db7547fb79a6fa44b88a9" -replace-with = "vendored-sources" - -[source."https://github.com/zcash-hackworks/sapling-crypto"] -git = "https://github.com/zcash-hackworks/sapling-crypto" -rev = "21084bde2019c04bd34208e63c3560fe2c02fb0e" -replace-with = "vendored-sources" - -[source."https://github.com/zcash-hackworks/zip32"] -git = "https://github.com/zcash-hackworks/zip32" -rev = "176470ef41583b5bd0bd749bd1b61d417aa8ec79" -replace-with = "vendored-sources" - -[source.vendored-sources] -directory = "CRATE_REGISTRY" diff --git a/depends/patches/librustzcash/remove-dev-dependencies.diff b/depends/patches/librustzcash/remove-dev-dependencies.diff deleted file mode 100644 index 3cc75eaae..000000000 --- a/depends/patches/librustzcash/remove-dev-dependencies.diff +++ /dev/null @@ -1,102 +0,0 @@ -diff --git a/Cargo.lock b/Cargo.lock -index 7a33a24..d60f744 100644 ---- a/Cargo.lock -+++ b/Cargo.lock -@@ -64,7 +64,6 @@ dependencies = [ - "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "group 0.2.0", -- "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.15.0", - "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -@@ -328,23 +327,6 @@ name = "hex" - version = "0.3.2" - source = "registry+https://github.com/rust-lang/crates.io-index" - --[[package]] --name = "hex-literal" --version = "0.2.1" --source = "registry+https://github.com/rust-lang/crates.io-index" --dependencies = [ -- "hex-literal-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -- "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", --] -- --[[package]] --name = "hex-literal-impl" --version = "0.2.1" --source = "registry+https://github.com/rust-lang/crates.io-index" --dependencies = [ -- "proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", --] -- - [[package]] - name = "lazy_static" - version = "1.4.0" -@@ -449,16 +431,6 @@ name = "ppv-lite86" - version = "0.2.5" - source = "registry+https://github.com/rust-lang/crates.io-index" - --[[package]] --name = "proc-macro-hack" --version = "0.5.9" --source = "registry+https://github.com/rust-lang/crates.io-index" --dependencies = [ -- "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", -- "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -- "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", --] -- - [[package]] - name = "proc-macro2" - version = "1.0.3" -@@ -624,7 +596,6 @@ dependencies = [ - "ff 0.5.0", - "fpe 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", -- "hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "pairing 0.15.0", -@@ -685,8 +656,6 @@ dependencies = [ - "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" - "checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" - "checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" --"checksum hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "961de220ec9a91af2e1e5bd80d02109155695e516771762381ef8581317066e0" --"checksum hex-literal-impl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9d4c5c844e2fee0bf673d54c2c177f1713b3d2af2ff6e666b49cb7572e6cf42d" - "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" - "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -@@ -698,7 +667,6 @@ dependencies = [ - "checksum num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273" - "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" --"checksum proc-macro-hack 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e688f31d92ffd7c1ddc57a1b4e6d773c0f2a14ee437a4b0a4f5a69c80eb221c8" - "checksum proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e98a83a9f9b331f54b924e68a66acb1bb35cb01fb0a23645139967abefb697e8" - "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" - "checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" -diff --git a/bellman/Cargo.toml b/bellman/Cargo.toml -index 4f125b4..6a72152 100644 ---- a/bellman/Cargo.toml -+++ b/bellman/Cargo.toml -@@ -24,7 +24,6 @@ rand_core = "0.5" - byteorder = "1" - - [dev-dependencies] --hex-literal = "0.2" - rand = "0.7" - rand_xorshift = "0.2" - sha2 = "0.8" -diff --git a/zcash_primitives/Cargo.toml b/zcash_primitives/Cargo.toml -index c83ecf1..6674144 100644 ---- a/zcash_primitives/Cargo.toml -+++ b/zcash_primitives/Cargo.toml -@@ -28,7 +28,6 @@ rand_core = "0.5.1" - sha2 = "0.8" - - [dev-dependencies] --hex-literal = "0.2" - rand_xorshift = "0.2" - - [badges] diff --git a/src/.cargo/config.offline b/src/.cargo/config.offline new file mode 100644 index 000000000..a6339df37 --- /dev/null +++ b/src/.cargo/config.offline @@ -0,0 +1,5 @@ +[source.crates-io] +replace-with = "vendored-sources" + +[source.vendored-sources] +# The directory for this source is set to RUST_VENDORED_SOURCES by src/Makefile.am diff --git a/src/Makefile.am b/src/Makefile.am index bad284155..a7d50acc8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,6 +29,7 @@ endif BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS) +BITCOIN_INCLUDES += -I$(srcdir)/rust/include BITCOIN_INCLUDES += -I$(srcdir)/secp256k1/include BITCOIN_INCLUDES += -I$(srcdir)/univalue/include @@ -37,6 +38,11 @@ LIBBITCOIN_COMMON=libbitcoin_common.a LIBBITCOIN_CLI=libbitcoin_cli.a LIBBITCOIN_UTIL=libbitcoin_util.a LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a +if TARGET_WINDOWS +LIBRUSTZCASH=rust/target/$(RUST_TARGET)/release/rustzcash.lib +else +LIBRUSTZCASH=rust/target/$(RUST_TARGET)/release/librustzcash.a +endif LIBSECP256K1=secp256k1/libsecp256k1.la LIBUNIVALUE=univalue/libunivalue.la LIBZCASH=libzcash.a @@ -54,6 +60,33 @@ if ENABLE_WALLET LIBBITCOIN_WALLET=libbitcoin_wallet.a endif +RUST_ENV_VARS = RUSTC="$(RUSTC)" TERM=dumb +RUST_BUILD_OPTS = --release --target $(RUST_TARGET) + +if ENABLE_ONLINE_RUST +# Ensure that .cargo/config does not exist +CARGO_CONFIGURED = .cargo/.configured-for-online +$(CARGO_CONFIGURED): + $(AM_V_at)rm -f .cargo/.configured-for-offline .cargo/config + $(AM_V_at)touch $@ + +else +# Enable dependency vendoring +RUST_BUILD_OPTS += --locked --offline + +CARGO_CONFIGURED = .cargo/.configured-for-offline +$(CARGO_CONFIGURED): .cargo/config.offline + $(AM_V_at)rm -f .cargo/.configured-for-online + $(AM_V_at)cp $< .cargo/config + $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >>.cargo/config + $(AM_V_at)touch $@ +endif + +cargo-build: $(CARGO_CONFIGURED) + $(RUST_ENV_VARS) $(CARGO) build $(RUST_BUILD_OPTS) --manifest-path $(srcdir)/rust/Cargo.toml + +$(LIBRUSTZCASH): cargo-build + $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*) $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) @@ -102,7 +135,7 @@ LIBZCASH_H = \ zcash/util.h \ zcash/Zcash.h -.PHONY: FORCE check-symbols check-security +.PHONY: FORCE cargo-build check-symbols check-security # bitcoin core # BITCOIN_CORE_H = \ addressindex.h \ @@ -449,6 +482,7 @@ zcashd_LDADD = \ $(LIBBITCOIN_PROTON) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH) \ + $(LIBRUSTZCASH) \ $(LIBLEVELDB) \ $(LIBMEMENV) \ $(LIBSECP256K1) @@ -484,6 +518,7 @@ zcash_cli_LDADD = \ $(CRYPTO_LIBS) \ $(EVENT_LIBS) \ $(LIBZCASH) \ + $(LIBRUSTZCASH) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH_LIBS) # @@ -505,6 +540,7 @@ zcash_tx_LDADD = \ $(LIBBITCOIN_UTIL) \ $(LIBSECP256K1) \ $(LIBZCASH) \ + $(LIBRUSTZCASH) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH_LIBS) @@ -567,6 +603,8 @@ DISTCLEANFILES = obj/build.h EXTRA_DIST = leveldb clean-local: + $(CARGO) clean --manifest-path $(srcdir)/rust/Cargo.toml + rm -f .cargo/config .cargo/.configured-for-online .cargo/.configured-for-offline -$(MAKE) -C leveldb clean -$(MAKE) -C secp256k1 clean -$(MAKE) -C univalue clean diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index 555853942..5a8356aa5 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -29,7 +29,7 @@ bench_bench_bitcoin_LDADD = \ $(LIBMEMENV) \ $(LIBSECP256K1) \ $(LIBZCASH) \ - $(LIBSNARK) + $(LIBRUSTZCASH) if ENABLE_ZMQ bench_bench_bitcoin_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) diff --git a/src/Makefile.gtest.include b/src/Makefile.gtest.include index 7782fa206..6f0545109 100644 --- a/src/Makefile.gtest.include +++ b/src/Makefile.gtest.include @@ -63,7 +63,7 @@ if ENABLE_WALLET zcash_gtest_LDADD += $(LIBBITCOIN_WALLET) endif -zcash_gtest_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) +zcash_gtest_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBZCASH) $(LIBRUSTZCASH) $(LIBZCASH_LIBS) if ENABLE_PROTON zcash_gtest_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 5f77ec0d4..8c5421034 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -127,7 +127,7 @@ test_test_bitcoin_LDADD += $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_C $(LIBLEVELDB) $(LIBMEMENV) $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS) test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -test_test_bitcoin_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) +test_test_bitcoin_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(LIBZCASH) $(LIBRUSTZCASH) $(LIBZCASH_LIBS) test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static if ENABLE_ZMQ From 5fe41654bfa0298c920631d45098ae74a12d2832 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 4 Feb 2020 12:55:35 +0000 Subject: [PATCH 7/9] Move root of Rust crate into repo root This enables IDE integration to work (which requires the Cargo.toml to be in the repo root). "make clean" no longer runs "cargo clean", because IDE integrations hold locks on files within the Rust build directory, and an error inside "cargo clean" error would prevent "make clean" from completing (and removing other files). --- {src/.cargo => .cargo}/config.offline | 0 .gitignore | 6 +++--- src/rust/Cargo.lock => Cargo.lock | 0 src/rust/Cargo.toml => Cargo.toml | 2 +- src/rust/rust-toolchain => rust-toolchain | 0 src/Makefile.am | 21 ++++++++++----------- 6 files changed, 14 insertions(+), 15 deletions(-) rename {src/.cargo => .cargo}/config.offline (100%) rename src/rust/Cargo.lock => Cargo.lock (100%) rename src/rust/Cargo.toml => Cargo.toml (95%) rename src/rust/rust-toolchain => rust-toolchain (100%) diff --git a/src/.cargo/config.offline b/.cargo/config.offline similarity index 100% rename from src/.cargo/config.offline rename to .cargo/config.offline diff --git a/.gitignore b/.gitignore index 6ce5e4ded..3a976fd49 100644 --- a/.gitignore +++ b/.gitignore @@ -73,9 +73,9 @@ src/univalue/gen Makefile # Rust -src/.cargo/.configured-for-* -src/.cargo/config -src/rust/target +.cargo/.configured-for-* +.cargo/config +target/ # Unit-tests Makefile.test diff --git a/src/rust/Cargo.lock b/Cargo.lock similarity index 100% rename from src/rust/Cargo.lock rename to Cargo.lock diff --git a/src/rust/Cargo.toml b/Cargo.toml similarity index 95% rename from src/rust/Cargo.toml rename to Cargo.toml index e94dc9d83..5d99b89d7 100644 --- a/src/rust/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ edition = "2018" [lib] name = "rustzcash" -path = "src/rustzcash.rs" +path = "src/rust/src/rustzcash.rs" crate-type = ["staticlib"] [dependencies] diff --git a/src/rust/rust-toolchain b/rust-toolchain similarity index 100% rename from src/rust/rust-toolchain rename to rust-toolchain diff --git a/src/Makefile.am b/src/Makefile.am index a7d50acc8..81acc739e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,9 +39,9 @@ LIBBITCOIN_CLI=libbitcoin_cli.a LIBBITCOIN_UTIL=libbitcoin_util.a LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a if TARGET_WINDOWS -LIBRUSTZCASH=rust/target/$(RUST_TARGET)/release/rustzcash.lib +LIBRUSTZCASH=$(top_builddir)/target/$(RUST_TARGET)/release/rustzcash.lib else -LIBRUSTZCASH=rust/target/$(RUST_TARGET)/release/librustzcash.a +LIBRUSTZCASH=$(top_builddir)/target/$(RUST_TARGET)/release/librustzcash.a endif LIBSECP256K1=secp256k1/libsecp256k1.la LIBUNIVALUE=univalue/libunivalue.la @@ -65,25 +65,25 @@ RUST_BUILD_OPTS = --release --target $(RUST_TARGET) if ENABLE_ONLINE_RUST # Ensure that .cargo/config does not exist -CARGO_CONFIGURED = .cargo/.configured-for-online +CARGO_CONFIGURED = $(top_srcdir)/.cargo/.configured-for-online $(CARGO_CONFIGURED): - $(AM_V_at)rm -f .cargo/.configured-for-offline .cargo/config + $(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-offline $(top_srcdir)/.cargo/config $(AM_V_at)touch $@ else # Enable dependency vendoring RUST_BUILD_OPTS += --locked --offline -CARGO_CONFIGURED = .cargo/.configured-for-offline -$(CARGO_CONFIGURED): .cargo/config.offline - $(AM_V_at)rm -f .cargo/.configured-for-online - $(AM_V_at)cp $< .cargo/config - $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >>.cargo/config +CARGO_CONFIGURED = $(top_srcdir)/.cargo/.configured-for-offline +$(CARGO_CONFIGURED): $(top_srcdir)/.cargo/config.offline + $(AM_V_at)rm -f $(top_srcdir)/.cargo/.configured-for-online + $(AM_V_at)cp $< $(top_srcdir)/.cargo/config + $(AM_V_at)echo "directory = \"$(RUST_VENDORED_SOURCES)\"" >>$(top_srcdir)/.cargo/config $(AM_V_at)touch $@ endif cargo-build: $(CARGO_CONFIGURED) - $(RUST_ENV_VARS) $(CARGO) build $(RUST_BUILD_OPTS) --manifest-path $(srcdir)/rust/Cargo.toml + $(RUST_ENV_VARS) $(CARGO) build $(RUST_BUILD_OPTS) --manifest-path $(top_srcdir)/Cargo.toml $(LIBRUSTZCASH): cargo-build @@ -603,7 +603,6 @@ DISTCLEANFILES = obj/build.h EXTRA_DIST = leveldb clean-local: - $(CARGO) clean --manifest-path $(srcdir)/rust/Cargo.toml rm -f .cargo/config .cargo/.configured-for-online .cargo/.configured-for-offline -$(MAKE) -C leveldb clean -$(MAKE) -C secp256k1 clean From a04acde9706ac40562516f7278a691990fa8e5a3 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 4 Feb 2020 15:37:10 +0000 Subject: [PATCH 8/9] depends: Remove unused vendored crates --- depends/packages/crate_bech32.mk | 15 --------------- depends/packages/crate_rand_os.mk | 15 --------------- depends/packages/crate_sapling_crypto.mk | 16 ---------------- depends/packages/crate_zip32.mk | 16 ---------------- depends/packages/packages.mk | 2 -- 5 files changed, 64 deletions(-) delete mode 100644 depends/packages/crate_bech32.mk delete mode 100644 depends/packages/crate_rand_os.mk delete mode 100644 depends/packages/crate_sapling_crypto.mk delete mode 100644 depends/packages/crate_zip32.mk diff --git a/depends/packages/crate_bech32.mk b/depends/packages/crate_bech32.mk deleted file mode 100644 index 588457932..000000000 --- a/depends/packages/crate_bech32.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_bech32 -$(package)_crate_name=bech32 -$(package)_version=0.7.1 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=9e0089c35ab7c6f2bc55ab23f769913f0ac65b1023e7e74638a1f43128dd5df2 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depends/packages/crate_rand_os.mk b/depends/packages/crate_rand_os.mk deleted file mode 100644 index 9965f2447..000000000 --- a/depends/packages/crate_rand_os.mk +++ /dev/null @@ -1,15 +0,0 @@ -package=crate_rand_os -$(package)_crate_name=rand_os -$(package)_version=0.2.1 -$(package)_download_path=https://static.crates.io/crates/$($(package)_crate_name) -$(package)_file_name=$($(package)_crate_name)-$($(package)_version).crate -$(package)_sha256_hash=ddb525a78d3a0b0e05b6fe0f7df14d7a4dc957944c7b403911ba5a0f1c694967 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depends/packages/crate_sapling_crypto.mk b/depends/packages/crate_sapling_crypto.mk deleted file mode 100644 index 2da5e2406..000000000 --- a/depends/packages/crate_sapling_crypto.mk +++ /dev/null @@ -1,16 +0,0 @@ -package=crate_sapling_crypto -$(package)_crate_name=sapling-crypto -$(package)_download_path=https://github.com/zcash-hackworks/$($(package)_crate_name)/archive/ -$(package)_file_name=$(package)-$($(package)_git_commit).tar.gz -$(package)_download_file=$($(package)_git_commit).tar.gz -$(package)_sha256_hash=ae3a122b1f1ce97b4e80e0e8542e19aa1516e99e6c72875688c886af1a881558 -$(package)_git_commit=21084bde2019c04bd34208e63c3560fe2c02fb0e -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_unpackaged_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depends/packages/crate_zip32.mk b/depends/packages/crate_zip32.mk deleted file mode 100644 index e47f1fb94..000000000 --- a/depends/packages/crate_zip32.mk +++ /dev/null @@ -1,16 +0,0 @@ -package=crate_zip32 -$(package)_crate_name=zip32 -$(package)_download_path=https://github.com/zcash-hackworks/$($(package)_crate_name)/archive/ -$(package)_file_name=$(package)-$($(package)_git_commit).tar.gz -$(package)_download_file=$($(package)_git_commit).tar.gz -$(package)_sha256_hash=b0b011ea96524f0d918a44c7ab8a3dec6270879d1ff03d7dbda6c676d25caa7e -$(package)_git_commit=176470ef41583b5bd0bd749bd1b61d417aa8ec79 -$(package)_crate_versioned_name=$($(package)_crate_name) - -define $(package)_preprocess_cmds - $(call generate_unpackaged_crate_checksum,$(package)) -endef - -define $(package)_stage_cmds - $(call vendor_crate_source,$(package)) -endef diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index dc247e84c..62e597897 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -5,7 +5,6 @@ rust_crates := \ crate_arrayref \ crate_arrayvec \ crate_autocfg \ - crate_bech32 \ crate_bellman \ crate_bit_vec \ crate_blake2b_simd \ @@ -55,7 +54,6 @@ rust_crates := \ crate_rand_chacha \ crate_rand_core \ crate_rand_hc \ - crate_rand_os \ crate_rand_xorshift \ crate_rand \ crate_rustc_version \ From 684e62e9039d4c8b1a80edc219519d353d64adbb Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 12 Mar 2020 00:50:45 +1300 Subject: [PATCH 9/9] Fix Rust static library linking for Windows builds The library renaming step is necessary because the naming convention used by rustc does not match the naming convention for libtool/MinGW. --- configure.ac | 1 + src/Makefile.am | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 9958a3783..66bb96316 100644 --- a/configure.ac +++ b/configure.ac @@ -821,6 +821,7 @@ fi RUST_LIBS="" case $host in *mingw*) + RUST_LIBS="$RUST_LIBS -luserenv" ;; *) RUST_LIBS="$RUST_LIBS -ldl" diff --git a/src/Makefile.am b/src/Makefile.am index 81acc739e..8dfd66524 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -38,11 +38,7 @@ LIBBITCOIN_COMMON=libbitcoin_common.a LIBBITCOIN_CLI=libbitcoin_cli.a LIBBITCOIN_UTIL=libbitcoin_util.a LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a -if TARGET_WINDOWS -LIBRUSTZCASH=$(top_builddir)/target/$(RUST_TARGET)/release/rustzcash.lib -else LIBRUSTZCASH=$(top_builddir)/target/$(RUST_TARGET)/release/librustzcash.a -endif LIBSECP256K1=secp256k1/libsecp256k1.la LIBUNIVALUE=univalue/libunivalue.la LIBZCASH=libzcash.a @@ -85,7 +81,19 @@ endif cargo-build: $(CARGO_CONFIGURED) $(RUST_ENV_VARS) $(CARGO) build $(RUST_BUILD_OPTS) --manifest-path $(top_srcdir)/Cargo.toml +if TARGET_WINDOWS +LIBRUSTZCASH_WIN=$(top_builddir)/target/$(RUST_TARGET)/release/rustzcash.lib + +$(LIBRUSTZCASH_WIN): cargo-build + +# This ensures that the Rust library is correctly linked in by libtool. +# See https://github.com/rust-lang/rust/issues/69904 for the underlying cause. +$(LIBRUSTZCASH): $(LIBRUSTZCASH_WIN) + $(AM_V_at)cp $< $@ + +else $(LIBRUSTZCASH): cargo-build +endif $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*) $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)