cargo fmt 1.31.1

This commit is contained in:
Jack Grigg 2019-01-03 21:52:06 +00:00
parent e378229bdd
commit 1a1c77536d
No known key found for this signature in database
GPG Key ID: 1B8D649257DB0829
4 changed files with 25 additions and 21 deletions

View File

@ -149,8 +149,7 @@ fn expand_array(vin: &[u8], bit_len: usize, byte_pad: usize) -> Vec<u8> {
vout[j + x] = (( vout[j + x] = ((
// Big-endian // Big-endian
acc_value >> (acc_bits + (8 * (out_width - x - 1))) acc_value >> (acc_bits + (8 * (out_width - x - 1)))
) ) & (
& (
// Apply bit_len_mask across byte boundaries // Apply bit_len_mask across byte boundaries
(bit_len_mask >> (8 * (out_width - x - 1))) & 0xFF (bit_len_mask >> (8 * (out_width - x - 1))) & 0xFF
)) as u8; )) as u8;

View File

@ -324,9 +324,10 @@ pub extern "system" fn librustzcash_merkle_hash(
.take(Fr::NUM_BITS as usize) .take(Fr::NUM_BITS as usize)
.chain(rhs.iter().map(|&x| x).take(Fr::NUM_BITS as usize)), .chain(rhs.iter().map(|&x| x).take(Fr::NUM_BITS as usize)),
&JUBJUB, &JUBJUB,
).into_xy() )
.0 .into_xy()
.into_repr(); .0
.into_repr();
// Should be okay, caller is responsible for ensuring the pointer // Should be okay, caller is responsible for ensuring the pointer
// is a valid pointer to 32 bytes that can be mutated. // is a valid pointer to 32 bytes that can be mutated.
@ -914,7 +915,8 @@ pub extern "system" fn librustzcash_sprout_prove(
unsafe { &SPROUT_GROTH16_PARAMS_PATH } unsafe { &SPROUT_GROTH16_PARAMS_PATH }
.as_ref() .as_ref()
.expect("parameters should have been initialized"), .expect("parameters should have been initialized"),
).expect("couldn't load Sprout groth16 parameters file"); )
.expect("couldn't load Sprout groth16 parameters file");
let mut sprout_fs = BufReader::with_capacity(1024 * 1024, sprout_fs); let mut sprout_fs = BufReader::with_capacity(1024 * 1024, sprout_fs);
@ -1077,8 +1079,7 @@ pub extern "system" fn librustzcash_sapling_spend_sig(
// Compute the signature's message for rk/spend_auth_sig // Compute the signature's message for rk/spend_auth_sig
let mut data_to_be_signed = [0u8; 64]; let mut data_to_be_signed = [0u8; 64];
rk.0 rk.0.write(&mut data_to_be_signed[0..32])
.write(&mut data_to_be_signed[0..32])
.expect("message buffer should be 32 bytes"); .expect("message buffer should be 32 bytes");
(&mut data_to_be_signed[32..64]).copy_from_slice(&(unsafe { &*sighash })[..]); (&mut data_to_be_signed[32..64]).copy_from_slice(&(unsafe { &*sighash })[..]);
@ -1198,7 +1199,8 @@ pub extern "system" fn librustzcash_sapling_spend_proof(
unsafe { SAPLING_SPEND_PARAMS.as_ref() }.unwrap(), unsafe { SAPLING_SPEND_PARAMS.as_ref() }.unwrap(),
unsafe { SAPLING_SPEND_VK.as_ref() }.unwrap(), unsafe { SAPLING_SPEND_VK.as_ref() }.unwrap(),
&JUBJUB, &JUBJUB,
).expect("proving should not fail"); )
.expect("proving should not fail");
// Write value commitment to caller // Write value commitment to caller
value_commitment value_commitment

View File

@ -109,11 +109,12 @@ fn single_output_hash(tx_out: &TxOut) -> Vec<u8> {
fn joinsplits_hash(tx: &TransactionData) -> Vec<u8> { fn joinsplits_hash(tx: &TransactionData) -> Vec<u8> {
let mut data = Vec::with_capacity( let mut data = Vec::with_capacity(
tx.joinsplits.len() * if tx.version < SAPLING_TX_VERSION { tx.joinsplits.len()
1802 // JSDescription with PHGR13 proof * if tx.version < SAPLING_TX_VERSION {
} else { 1802 // JSDescription with PHGR13 proof
1698 // JSDescription with Groth16 proof } else {
}, 1698 // JSDescription with Groth16 proof
},
); );
for js in &tx.joinsplits { for js in &tx.joinsplits {
js.write(&mut data).unwrap(); js.write(&mut data).unwrap();

View File

@ -92,13 +92,13 @@ impl<E: JubjubEngine> ExpandedSpendingKey<E> {
pub fn read<R: Read>(mut reader: R) -> io::Result<Self> { pub fn read<R: Read>(mut reader: R) -> io::Result<Self> {
let mut ask_repr = <E::Fs as PrimeField>::Repr::default(); let mut ask_repr = <E::Fs as PrimeField>::Repr::default();
ask_repr.read_le(&mut reader)?; ask_repr.read_le(&mut reader)?;
let ask = let ask = E::Fs::from_repr(ask_repr)
E::Fs::from_repr(ask_repr).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
let mut nsk_repr = <E::Fs as PrimeField>::Repr::default(); let mut nsk_repr = <E::Fs as PrimeField>::Repr::default();
nsk_repr.read_le(&mut reader)?; nsk_repr.read_le(&mut reader)?;
let nsk = let nsk = E::Fs::from_repr(nsk_repr)
E::Fs::from_repr(nsk_repr).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;
let mut ovk = [0; 32]; let mut ovk = [0; 32];
reader.read_exact(&mut ovk)?; reader.read_exact(&mut ovk)?;
@ -324,9 +324,11 @@ impl DiversifierKey {
// Return (j, d_j) if valid, else increment j and try again // Return (j, d_j) if valid, else increment j and try again
match d_j.g_d::<Bls12>(&JUBJUB) { match d_j.g_d::<Bls12>(&JUBJUB) {
Some(_) => return Ok((j, d_j)), Some(_) => return Ok((j, d_j)),
None => if j.increment().is_err() { None => {
return Err(()); if j.increment().is_err() {
}, return Err(());
}
}
} }
} }
} }