Skip to content

Commit

Permalink
Merge branch 'master' into blake2_simd
Browse files Browse the repository at this point in the history
  • Loading branch information
str4d authored Jul 18, 2019
2 parents d1ce674 + 5e3409e commit 8361674
Show file tree
Hide file tree
Showing 10 changed files with 1,271 additions and 104 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 9 additions & 26 deletions librustzcash/src/rustzcash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern crate zcash_proofs;

extern crate lazy_static;

use ff::{BitIterator, PrimeField, PrimeFieldRepr};
use ff::{PrimeField, PrimeFieldRepr};
use pairing::bls12_381::{Bls12, Fr, FrRepr};

use sapling_crypto::{
Expand All @@ -23,7 +23,6 @@ use sapling_crypto::{
fs::{Fs, FsRepr},
FixedGenerators, JubjubEngine, JubjubParams, PrimeOrder, ToUniform, Unknown,
},
pedersen_hash::{pedersen_hash, Personalization},
redjubjub::{self, Signature},
};

Expand Down Expand Up @@ -58,10 +57,15 @@ use std::ffi::OsString;
use std::os::windows::ffi::OsStringExt;

use sapling_crypto::primitives::{ProofGenerationKey, ViewingKey};
use zcash_primitives::{note_encryption::sapling_ka_agree, sapling::spend_sig, zip32, JUBJUB};
use zcash_primitives::{
merkle_tree::CommitmentTreeWitness,
note_encryption::sapling_ka_agree,
sapling::{merkle_hash, spend_sig},
zip32, JUBJUB,
};
use zcash_proofs::{
load_parameters,
sapling::{CommitmentTreeWitness, SaplingProvingContext, SaplingVerificationContext},
sapling::{SaplingProvingContext, SaplingVerificationContext},
};

pub mod equihash;
Expand Down Expand Up @@ -255,28 +259,7 @@ pub extern "system" fn librustzcash_merkle_hash(
// size of the representation
let b_repr = read_le(unsafe { &(&*b)[..] });

let mut lhs = [false; 256];
let mut rhs = [false; 256];

for (a, b) in lhs.iter_mut().rev().zip(BitIterator::new(a_repr)) {
*a = b;
}

for (a, b) in rhs.iter_mut().rev().zip(BitIterator::new(b_repr)) {
*a = b;
}

let tmp = pedersen_hash::<Bls12, _>(
Personalization::MerkleTree(depth),
lhs.iter()
.map(|&x| x)
.take(Fr::NUM_BITS as usize)
.chain(rhs.iter().map(|&x| x).take(Fr::NUM_BITS as usize)),
&JUBJUB,
)
.into_xy()
.0
.into_repr();
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.
Expand Down
1 change: 1 addition & 0 deletions zcash_primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use sapling_crypto::jubjub::JubjubBls12;

pub mod block;
pub mod keys;
pub mod merkle_tree;
pub mod note_encryption;
pub mod sapling;
mod serialize;
Expand Down
Loading

0 comments on commit 8361674

Please sign in to comment.