From 1a1c77536d824d7b6bd0eaf3e9888829a7a1f5dc Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 3 Jan 2019 21:52:06 +0000 Subject: [PATCH] cargo fmt 1.31.1 --- librustzcash/src/equihash.rs | 3 +-- librustzcash/src/rustzcash.rs | 16 +++++++++------- zcash_primitives/src/transaction/sighash.rs | 11 ++++++----- zip32/src/lib.rs | 16 +++++++++------- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/librustzcash/src/equihash.rs b/librustzcash/src/equihash.rs index 0509fc2..da2693b 100644 --- a/librustzcash/src/equihash.rs +++ b/librustzcash/src/equihash.rs @@ -149,8 +149,7 @@ fn expand_array(vin: &[u8], bit_len: usize, byte_pad: usize) -> Vec { vout[j + x] = (( // Big-endian acc_value >> (acc_bits + (8 * (out_width - x - 1))) - ) - & ( + ) & ( // Apply bit_len_mask across byte boundaries (bit_len_mask >> (8 * (out_width - x - 1))) & 0xFF )) as u8; diff --git a/librustzcash/src/rustzcash.rs b/librustzcash/src/rustzcash.rs index e04d526..b77b6b2 100644 --- a/librustzcash/src/rustzcash.rs +++ b/librustzcash/src/rustzcash.rs @@ -324,9 +324,10 @@ pub extern "system" fn librustzcash_merkle_hash( .take(Fr::NUM_BITS as usize) .chain(rhs.iter().map(|&x| x).take(Fr::NUM_BITS as usize)), &JUBJUB, - ).into_xy() - .0 - .into_repr(); + ) + .into_xy() + .0 + .into_repr(); // Should be okay, caller is responsible for ensuring the pointer // 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 } .as_ref() .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); @@ -1077,8 +1079,7 @@ pub extern "system" fn librustzcash_sapling_spend_sig( // Compute the signature's message for rk/spend_auth_sig let mut data_to_be_signed = [0u8; 64]; - rk.0 - .write(&mut data_to_be_signed[0..32]) + rk.0.write(&mut data_to_be_signed[0..32]) .expect("message buffer should be 32 bytes"); (&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_VK.as_ref() }.unwrap(), &JUBJUB, - ).expect("proving should not fail"); + ) + .expect("proving should not fail"); // Write value commitment to caller value_commitment diff --git a/zcash_primitives/src/transaction/sighash.rs b/zcash_primitives/src/transaction/sighash.rs index 7a0eb28..e5dcde0 100644 --- a/zcash_primitives/src/transaction/sighash.rs +++ b/zcash_primitives/src/transaction/sighash.rs @@ -109,11 +109,12 @@ fn single_output_hash(tx_out: &TxOut) -> Vec { fn joinsplits_hash(tx: &TransactionData) -> Vec { let mut data = Vec::with_capacity( - tx.joinsplits.len() * if tx.version < SAPLING_TX_VERSION { - 1802 // JSDescription with PHGR13 proof - } else { - 1698 // JSDescription with Groth16 proof - }, + tx.joinsplits.len() + * if tx.version < SAPLING_TX_VERSION { + 1802 // JSDescription with PHGR13 proof + } else { + 1698 // JSDescription with Groth16 proof + }, ); for js in &tx.joinsplits { js.write(&mut data).unwrap(); diff --git a/zip32/src/lib.rs b/zip32/src/lib.rs index 70173ea..5b322db 100644 --- a/zip32/src/lib.rs +++ b/zip32/src/lib.rs @@ -92,13 +92,13 @@ impl ExpandedSpendingKey { pub fn read(mut reader: R) -> io::Result { let mut ask_repr = ::Repr::default(); ask_repr.read_le(&mut reader)?; - let ask = - E::Fs::from_repr(ask_repr).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; + let ask = E::Fs::from_repr(ask_repr) + .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; let mut nsk_repr = ::Repr::default(); nsk_repr.read_le(&mut reader)?; - let nsk = - E::Fs::from_repr(nsk_repr).map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; + let nsk = E::Fs::from_repr(nsk_repr) + .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; let mut ovk = [0; 32]; reader.read_exact(&mut ovk)?; @@ -324,9 +324,11 @@ impl DiversifierKey { // Return (j, d_j) if valid, else increment j and try again match d_j.g_d::(&JUBJUB) { Some(_) => return Ok((j, d_j)), - None => if j.increment().is_err() { - return Err(()); - }, + None => { + if j.increment().is_err() { + return Err(()); + } + } } } }