mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-02-01 08:12:14 +00:00
cargo fmt 1.31.1
This commit is contained in:
parent
e378229bdd
commit
1a1c77536d
@ -149,8 +149,7 @@ fn expand_array(vin: &[u8], bit_len: usize, byte_pad: usize) -> Vec<u8> {
|
||||
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;
|
||||
|
@ -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
|
||||
|
@ -109,11 +109,12 @@ fn single_output_hash(tx_out: &TxOut) -> Vec<u8> {
|
||||
|
||||
fn joinsplits_hash(tx: &TransactionData) -> Vec<u8> {
|
||||
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();
|
||||
|
@ -92,13 +92,13 @@ impl<E: JubjubEngine> ExpandedSpendingKey<E> {
|
||||
pub fn read<R: Read>(mut reader: R) -> io::Result<Self> {
|
||||
let mut ask_repr = <E::Fs as PrimeField>::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 = <E::Fs as PrimeField>::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::<Bls12>(&JUBJUB) {
|
||||
Some(_) => return Ok((j, d_j)),
|
||||
None => if j.increment().is_err() {
|
||||
return Err(());
|
||||
},
|
||||
None => {
|
||||
if j.increment().is_err() {
|
||||
return Err(());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user