Address various clippy warnings/errors in zcash_primitives

This commit is contained in:
Jack Grigg 2019-08-02 11:25:00 +01:00
parent d65fe2cda9
commit 3a8efd9e67
No known key found for this signature in database
GPG Key ID: 9E8255172BBF9898
18 changed files with 97 additions and 107 deletions

View File

@ -13,7 +13,7 @@ pub struct BlockHash(pub [u8; 32]);
impl fmt::Display for BlockHash { impl fmt::Display for BlockHash {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut data = self.0.clone(); let mut data = self.0;
data.reverse(); data.reverse();
formatter.write_str(&hex::encode(data)) formatter.write_str(&hex::encode(data))
} }

View File

@ -60,10 +60,7 @@ impl Node {
indices.extend(a.indices.iter()); indices.extend(a.indices.iter());
indices indices
}; };
Node { Node { hash, indices }
hash: hash,
indices: indices,
}
} }
fn from_children_ref(a: &Node, b: &Node, trim: usize) -> Self { fn from_children_ref(a: &Node, b: &Node, trim: usize) -> Self {
@ -82,10 +79,7 @@ impl Node {
indices.extend(b.indices.iter()); indices.extend(b.indices.iter());
indices.extend(a.indices.iter()); indices.extend(a.indices.iter());
} }
Node { Node { hash, indices }
hash: hash,
indices: indices,
}
} }
fn indices_before(&self, other: &Node) -> bool { fn indices_before(&self, other: &Node) -> bool {
@ -141,7 +135,7 @@ fn expand_array(vin: &[u8], bit_len: usize, byte_pad: usize) -> Vec<u8> {
let mut j = 0; let mut j = 0;
for b in vin { for b in vin {
acc_value = (acc_value << 8) | *b as u32; acc_value = (acc_value << 8) | u32::from(*b);
acc_bits += 8; acc_bits += 8;
// When we have bit_len or more bits in the accumulator, write the next // When we have bit_len or more bits in the accumulator, write the next
@ -197,7 +191,7 @@ fn distinct_indices(a: &Node, b: &Node) -> bool {
} }
} }
} }
return true; true
} }
fn validate_subtrees(p: &Params, a: &Node, b: &Node) -> bool { fn validate_subtrees(p: &Params, a: &Node, b: &Node) -> bool {
@ -222,7 +216,7 @@ pub fn is_valid_solution_iterative(
nonce: &[u8], nonce: &[u8],
indices: &[u32], indices: &[u32],
) -> bool { ) -> bool {
let p = Params { n: n, k: k }; let p = Params { n, k };
let mut state = initialise_state(p.n, p.k, p.hash_output()); let mut state = initialise_state(p.n, p.k, p.hash_output());
state.update(input); state.update(input);
@ -249,7 +243,7 @@ pub fn is_valid_solution_iterative(
} }
assert!(rows.len() == 1); assert!(rows.len() == 1);
return rows[0].is_zero(hash_len); rows[0].is_zero(hash_len)
} }
fn tree_validator(p: &Params, state: &Blake2bState, indices: &[u32]) -> Option<Node> { fn tree_validator(p: &Params, state: &Blake2bState, indices: &[u32]) -> Option<Node> {
@ -281,7 +275,7 @@ pub fn is_valid_solution_recursive(
nonce: &[u8], nonce: &[u8],
indices: &[u32], indices: &[u32],
) -> bool { ) -> bool {
let p = Params { n: n, k: k }; let p = Params { n, k };
let mut state = initialise_state(p.n, p.k, p.hash_output()); let mut state = initialise_state(p.n, p.k, p.hash_output());
state.update(input); state.update(input);
@ -297,7 +291,7 @@ pub fn is_valid_solution_recursive(
} }
pub fn is_valid_solution(n: u32, k: u32, input: &[u8], nonce: &[u8], soln: &[u8]) -> bool { pub fn is_valid_solution(n: u32, k: u32, input: &[u8], nonce: &[u8], soln: &[u8]) -> bool {
let p = Params { n: n, k: k }; let p = Params { n, k };
let indices = indices_from_minimal(soln, p.collision_bit_length()); let indices = indices_from_minimal(soln, p.collision_bit_length());
// Recursive validation is faster // Recursive validation is faster

View File

@ -2,31 +2,31 @@
/// This is chosen to be some random string that we couldn't have anticipated when we designed /// This is chosen to be some random string that we couldn't have anticipated when we designed
/// the algorithm, for rigidity purposes. /// the algorithm, for rigidity purposes.
/// We deliberately use an ASCII hex string of 32 bytes here. /// We deliberately use an ASCII hex string of 32 bytes here.
pub const GH_FIRST_BLOCK: &'static [u8; 64] = pub const GH_FIRST_BLOCK: &[u8; 64] =
b"096b36a5804bfacef1691e173c366a47ff5ba84a44f26ddd7e8d9f79d5b42df0"; b"096b36a5804bfacef1691e173c366a47ff5ba84a44f26ddd7e8d9f79d5b42df0";
// BLAKE2s invocation personalizations // BLAKE2s invocation personalizations
/// BLAKE2s Personalization for CRH^ivk = BLAKE2s(ak | nk) /// BLAKE2s Personalization for CRH^ivk = BLAKE2s(ak | nk)
pub const CRH_IVK_PERSONALIZATION: &'static [u8; 8] = b"Zcashivk"; pub const CRH_IVK_PERSONALIZATION: &[u8; 8] = b"Zcashivk";
/// BLAKE2s Personalization for PRF^nf = BLAKE2s(nk | rho) /// BLAKE2s Personalization for PRF^nf = BLAKE2s(nk | rho)
pub const PRF_NF_PERSONALIZATION: &'static [u8; 8] = b"Zcash_nf"; pub const PRF_NF_PERSONALIZATION: &[u8; 8] = b"Zcash_nf";
// Group hash personalizations // Group hash personalizations
/// BLAKE2s Personalization for Pedersen hash generators. /// BLAKE2s Personalization for Pedersen hash generators.
pub const PEDERSEN_HASH_GENERATORS_PERSONALIZATION: &'static [u8; 8] = b"Zcash_PH"; pub const PEDERSEN_HASH_GENERATORS_PERSONALIZATION: &[u8; 8] = b"Zcash_PH";
/// BLAKE2s Personalization for the group hash for key diversification /// BLAKE2s Personalization for the group hash for key diversification
pub const KEY_DIVERSIFICATION_PERSONALIZATION: &'static [u8; 8] = b"Zcash_gd"; pub const KEY_DIVERSIFICATION_PERSONALIZATION: &[u8; 8] = b"Zcash_gd";
/// BLAKE2s Personalization for the spending key base point /// BLAKE2s Personalization for the spending key base point
pub const SPENDING_KEY_GENERATOR_PERSONALIZATION: &'static [u8; 8] = b"Zcash_G_"; pub const SPENDING_KEY_GENERATOR_PERSONALIZATION: &[u8; 8] = b"Zcash_G_";
/// BLAKE2s Personalization for the proof generation key base point /// BLAKE2s Personalization for the proof generation key base point
pub const PROOF_GENERATION_KEY_BASE_GENERATOR_PERSONALIZATION: &'static [u8; 8] = b"Zcash_H_"; pub const PROOF_GENERATION_KEY_BASE_GENERATOR_PERSONALIZATION: &[u8; 8] = b"Zcash_H_";
/// BLAKE2s Personalization for the value commitment generator for the value /// BLAKE2s Personalization for the value commitment generator for the value
pub const VALUE_COMMITMENT_GENERATOR_PERSONALIZATION: &'static [u8; 8] = b"Zcash_cv"; pub const VALUE_COMMITMENT_GENERATOR_PERSONALIZATION: &[u8; 8] = b"Zcash_cv";
/// BLAKE2s Personalization for the nullifier position generator (for computing rho) /// BLAKE2s Personalization for the nullifier position generator (for computing rho)
pub const NULLIFIER_POSITION_IN_TREE_GENERATOR_PERSONALIZATION: &'static [u8; 8] = b"Zcash_J_"; pub const NULLIFIER_POSITION_IN_TREE_GENERATOR_PERSONALIZATION: &[u8; 8] = b"Zcash_J_";

View File

@ -132,9 +132,9 @@ impl<E: JubjubEngine> Point<E, Unknown> {
t.mul_assign(&y); t.mul_assign(&y);
Some(Point { Some(Point {
x: x, x,
y: y, y,
t: t, t,
z: E::Fr::one(), z: E::Fr::one(),
_marker: PhantomData, _marker: PhantomData,
}) })
@ -277,8 +277,8 @@ impl<E: JubjubEngine, Subgroup> Point<E, Subgroup> {
Point { Point {
x: u, x: u,
y: v, y: v,
t: t, t,
z: z, z,
_marker: PhantomData, _marker: PhantomData,
} }
} }
@ -412,7 +412,7 @@ impl<E: JubjubEngine, Subgroup> Point<E, Subgroup> {
b.mul_assign(&other.y); b.mul_assign(&other.y);
// C = d * t1 * t2 // C = d * t1 * t2
let mut c = params.edwards_d().clone(); let mut c = *params.edwards_d();
c.mul_assign(&self.t); c.mul_assign(&self.t);
c.mul_assign(&other.t); c.mul_assign(&other.t);

View File

@ -321,8 +321,8 @@ impl Field for Fs {
loop { loop {
let mut tmp = { let mut tmp = {
let mut repr = [0u64; 4]; let mut repr = [0u64; 4];
for i in 0..4 { for limb in &mut repr {
repr[i] = rng.next_u64(); *limb = rng.next_u64();
} }
Fs(FsRepr(repr)) Fs(FsRepr(repr))
}; };

View File

@ -199,9 +199,9 @@ impl JubjubBls12 {
) )
.unwrap(), .unwrap(),
// A = 40962 // A = 40962
montgomery_a: montgomery_a, montgomery_a,
// 2A = 2.A // 2A = 2.A
montgomery_2a: montgomery_2a, montgomery_2a,
// scaling factor = sqrt(4 / (a - d)) // scaling factor = sqrt(4 / (a - d))
scale: Fr::from_str( scale: Fr::from_str(
"17814886934372412843466061268024708274627479829237077604635722030778476050649", "17814886934372412843466061268024708274627479829237077604635722030778476050649",

View File

@ -64,12 +64,12 @@ impl<E: JubjubEngine> Point<E, Unknown> {
y.negate(); y.negate();
} }
return Some(Point { Some(Point {
x: x, x,
y: y, y,
infinity: false, infinity: false,
_marker: PhantomData, _marker: PhantomData,
}); })
} }
None => None, None => None,
} }
@ -88,9 +88,8 @@ impl<E: JubjubEngine> Point<E, Unknown> {
let x = E::Fr::random(rng); let x = E::Fr::random(rng);
let sign = rng.next_u32() % 2 != 0; let sign = rng.next_u32() % 2 != 0;
match Self::get_for_x(x, sign, params) { if let Some(p) = Self::get_for_x(x, sign, params) {
Some(p) => return p, return p;
None => {}
} }
} }
} }
@ -214,7 +213,7 @@ impl<E: JubjubEngine, Subgroup> Point<E, Subgroup> {
let mut delta = E::Fr::one(); let mut delta = E::Fr::one();
{ {
let mut tmp = params.montgomery_a().clone(); let mut tmp = *params.montgomery_a();
tmp.mul_assign(&self.x); tmp.mul_assign(&self.x);
tmp.double(); tmp.double();
delta.add_assign(&tmp); delta.add_assign(&tmp);

View File

@ -10,11 +10,11 @@ use blake2b_simd::{Hash as Blake2bHash, Params as Blake2bParams};
use ff::{PrimeField, PrimeFieldRepr}; use ff::{PrimeField, PrimeFieldRepr};
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
pub const PRF_EXPAND_PERSONALIZATION: &'static [u8; 16] = b"Zcash_ExpandSeed"; pub const PRF_EXPAND_PERSONALIZATION: &[u8; 16] = b"Zcash_ExpandSeed";
/// PRF^expand(sk, t) := BLAKE2b-512("Zcash_ExpandSeed", sk || t) /// PRF^expand(sk, t) := BLAKE2b-512("Zcash_ExpandSeed", sk || t)
pub fn prf_expand(sk: &[u8], t: &[u8]) -> Blake2bHash { pub fn prf_expand(sk: &[u8], t: &[u8]) -> Blake2bHash {
prf_expand_vec(sk, &vec![t]) prf_expand_vec(sk, &[t])
} }
pub fn prf_expand_vec(sk: &[u8], ts: &[&[u8]]) -> Blake2bHash { pub fn prf_expand_vec(sk: &[u8], ts: &[&[u8]]) -> Blake2bHash {
@ -111,7 +111,7 @@ impl<E: JubjubEngine> Clone for FullViewingKey<E> {
ak: self.vk.ak.clone(), ak: self.vk.ak.clone(),
nk: self.vk.nk.clone(), nk: self.vk.nk.clone(),
}, },
ovk: self.ovk.clone(), ovk: self.ovk,
} }
} }
} }

View File

@ -486,8 +486,10 @@ impl<Node: Hashable> CommitmentTreeWitness<Node> {
// Given the position, let's finish constructing the authentication // Given the position, let's finish constructing the authentication
// path // path
let mut tmp = position; let mut tmp = position;
for i in 0..depth { for entry in auth_path.iter_mut() {
auth_path[i].as_mut().map(|p| p.1 = (tmp & 1) == 1); if let Some(p) = entry {
p.1 = (tmp & 1) == 1;
}
tmp >>= 1; tmp >>= 1;
} }

View File

@ -19,8 +19,8 @@ use std::str;
use crate::{keys::OutgoingViewingKey, JUBJUB}; use crate::{keys::OutgoingViewingKey, JUBJUB};
pub const KDF_SAPLING_PERSONALIZATION: &'static [u8; 16] = b"Zcash_SaplingKDF"; pub const KDF_SAPLING_PERSONALIZATION: &[u8; 16] = b"Zcash_SaplingKDF";
pub const PRF_OCK_PERSONALIZATION: &'static [u8; 16] = b"Zcash_Derive_ock"; pub const PRF_OCK_PERSONALIZATION: &[u8; 16] = b"Zcash_Derive_ock";
const COMPACT_NOTE_SIZE: usize = ( const COMPACT_NOTE_SIZE: usize = (
1 + // version 1 + // version
@ -85,7 +85,7 @@ impl Default for Memo {
impl PartialEq for Memo { impl PartialEq for Memo {
fn eq(&self, rhs: &Memo) -> bool { fn eq(&self, rhs: &Memo) -> bool {
&self.0[..] == &rhs.0[..] self.0[..] == rhs.0[..]
} }
} }

View File

@ -97,10 +97,7 @@ impl<E: JubjubEngine> ViewingKey<E> {
diversifier.g_d(params).map(|g_d| { diversifier.g_d(params).map(|g_d| {
let pk_d = g_d.mul(self.ivk(), params); let pk_d = g_d.mul(self.ivk(), params);
PaymentAddress { PaymentAddress { pk_d, diversifier }
pk_d: pk_d,
diversifier: diversifier,
}
}) })
} }
} }
@ -145,9 +142,9 @@ impl<E: JubjubEngine> PaymentAddress<E> {
params: &E::Params, params: &E::Params,
) -> Option<Note<E>> { ) -> Option<Note<E>> {
self.g_d(params).map(|g_d| Note { self.g_d(params).map(|g_d| Note {
value: value, value,
r: randomness, r: randomness,
g_d: g_d, g_d,
pk_d: self.pk_d.clone(), pk_d: self.pk_d.clone(),
}) })
} }

View File

@ -37,9 +37,9 @@ pub fn merkle_hash(depth: usize, lhs: &FrRepr, rhs: &FrRepr) -> FrRepr {
pedersen_hash::<Bls12, _>( pedersen_hash::<Bls12, _>(
Personalization::MerkleTree(depth), Personalization::MerkleTree(depth),
lhs.iter() lhs.iter()
.map(|&x| x) .copied()
.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().copied().take(Fr::NUM_BITS as usize)),
&JUBJUB, &JUBJUB,
) )
.into_xy() .into_xy()

View File

@ -70,7 +70,7 @@ impl Vector {
F: Fn(&mut R) -> io::Result<E>, F: Fn(&mut R) -> io::Result<E>,
{ {
let count = CompactSize::read(&mut reader)?; let count = CompactSize::read(&mut reader)?;
(0..count).into_iter().map(|_| func(&mut reader)).collect() (0..count).map(|_| func(&mut reader)).collect()
} }
pub fn write<W: Write, E, F>(mut writer: W, vec: &[E], func: F) -> io::Result<()> pub fn write<W: Write, E, F>(mut writer: W, vec: &[E], func: F) -> io::Result<()>

View File

@ -153,7 +153,7 @@ impl TransactionMetadata {
/// they added (via the first call to [`Builder::add_sapling_spend`]) is the first /// they added (via the first call to [`Builder::add_sapling_spend`]) is the first
/// [`SpendDescription`] in the transaction. /// [`SpendDescription`] in the transaction.
pub fn spend_index(&self, n: usize) -> Option<usize> { pub fn spend_index(&self, n: usize) -> Option<usize> {
self.spend_indices.get(n).map(|i| *i) self.spend_indices.get(n).copied()
} }
/// Returns the index within the transaction of the [`OutputDescription`] corresponding /// Returns the index within the transaction of the [`OutputDescription`] corresponding
@ -164,7 +164,7 @@ impl TransactionMetadata {
/// they added (via the first call to [`Builder::add_sapling_output`]) is the first /// they added (via the first call to [`Builder::add_sapling_output`]) is the first
/// [`OutputDescription`] in the transaction. /// [`OutputDescription`] in the transaction.
pub fn output_index(&self, n: usize) -> Option<usize> { pub fn output_index(&self, n: usize) -> Option<usize> {
self.output_indices.get(n).map(|i| *i) self.output_indices.get(n).copied()
} }
} }
@ -414,7 +414,7 @@ impl<R: RngCore + CryptoRng> Builder<R> {
self.mtx.shielded_spends.push(SpendDescription { self.mtx.shielded_spends.push(SpendDescription {
cv, cv,
anchor: anchor, anchor,
nullifier, nullifier,
rk, rk,
zkproof, zkproof,

View File

@ -166,12 +166,10 @@ impl SpendDescription {
writer.write_all(&self.zkproof)?; writer.write_all(&self.zkproof)?;
match self.spend_auth_sig { match self.spend_auth_sig {
Some(sig) => sig.write(&mut writer), Some(sig) => sig.write(&mut writer),
None => { None => Err(io::Error::new(
return Err(io::Error::new( io::ErrorKind::InvalidInput,
io::ErrorKind::InvalidInput, "Missing spend auth signature",
"Missing spend auth signature", )),
));
}
} }
} }
} }
@ -347,23 +345,20 @@ impl JSDescription {
.map(|mac| reader.read_exact(mac)) .map(|mac| reader.read_exact(mac))
.collect::<io::Result<()>>()?; .collect::<io::Result<()>>()?;
let proof = match use_groth { let proof = if use_groth {
true => { // Consensus rules (§4.3):
// Consensus rules (§4.3): // - Canonical encoding is enforced in librustzcash_sprout_verify()
// - Canonical encoding is enforced in librustzcash_sprout_verify() // - Proof validity is enforced in librustzcash_sprout_verify()
// - Proof validity is enforced in librustzcash_sprout_verify() let mut proof = [0; GROTH_PROOF_SIZE];
let mut proof = [0; GROTH_PROOF_SIZE]; reader.read_exact(&mut proof)?;
reader.read_exact(&mut proof)?; SproutProof::Groth(proof)
SproutProof::Groth(proof) } else {
} // Consensus rules (§4.3):
false => { // - Canonical encoding is enforced by PHGRProof in zcashd
// Consensus rules (§4.3): // - Proof validity is enforced by JSDescription::Verify() in zcashd
// - Canonical encoding is enforced by PHGRProof in zcashd let mut proof = [0; PHGR_PROOF_SIZE];
// - Proof validity is enforced by JSDescription::Verify() in zcashd reader.read_exact(&mut proof)?;
let mut proof = [0; PHGR_PROOF_SIZE]; SproutProof::PHGR(proof)
reader.read_exact(&mut proof)?;
SproutProof::PHGR(proof)
}
}; };
let mut ciphertexts = [[0; 601]; ZC_NUM_JS_OUTPUTS]; let mut ciphertexts = [[0; 601]; ZC_NUM_JS_OUTPUTS];

View File

@ -29,7 +29,7 @@ pub struct TxId(pub [u8; 32]);
impl fmt::Display for TxId { impl fmt::Display for TxId {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut data = self.0.clone(); let mut data = self.0;
data.reverse(); data.reverse();
formatter.write_str(&hex::encode(data)) formatter.write_str(&hex::encode(data))
} }
@ -164,9 +164,10 @@ impl Transaction {
let overwintered = (header >> 31) == 1; let overwintered = (header >> 31) == 1;
let version = header & 0x7FFFFFFF; let version = header & 0x7FFFFFFF;
let version_group_id = match overwintered { let version_group_id = if overwintered {
true => reader.read_u32::<LittleEndian>()?, reader.read_u32::<LittleEndian>()?
false => 0, } else {
0
}; };
let is_overwinter_v3 = overwintered let is_overwinter_v3 = overwintered
@ -185,9 +186,10 @@ impl Transaction {
let vin = Vector::read(&mut reader, TxIn::read)?; let vin = Vector::read(&mut reader, TxIn::read)?;
let vout = Vector::read(&mut reader, TxOut::read)?; let vout = Vector::read(&mut reader, TxOut::read)?;
let lock_time = reader.read_u32::<LittleEndian>()?; let lock_time = reader.read_u32::<LittleEndian>()?;
let expiry_height = match is_overwinter_v3 || is_sapling_v4 { let expiry_height = if is_overwinter_v3 || is_sapling_v4 {
true => reader.read_u32::<LittleEndian>()?, reader.read_u32::<LittleEndian>()?
false => 0, } else {
0
}; };
let (value_balance, shielded_spends, shielded_outputs) = if is_sapling_v4 { let (value_balance, shielded_spends, shielded_outputs) = if is_sapling_v4 {
@ -223,9 +225,10 @@ impl Transaction {
}; };
let binding_sig = let binding_sig =
match is_sapling_v4 && !(shielded_spends.is_empty() && shielded_outputs.is_empty()) { if is_sapling_v4 && !(shielded_spends.is_empty() && shielded_outputs.is_empty()) {
true => Some(Signature::read(&mut reader)?), Some(Signature::read(&mut reader)?)
false => None, } else {
None
}; };
Transaction::from_data(TransactionData { Transaction::from_data(TransactionData {

View File

@ -9,13 +9,13 @@ use super::{
}; };
use crate::legacy::Script; use crate::legacy::Script;
const ZCASH_SIGHASH_PERSONALIZATION_PREFIX: &'static [u8; 12] = b"ZcashSigHash"; const ZCASH_SIGHASH_PERSONALIZATION_PREFIX: &[u8; 12] = b"ZcashSigHash";
const ZCASH_PREVOUTS_HASH_PERSONALIZATION: &'static [u8; 16] = b"ZcashPrevoutHash"; const ZCASH_PREVOUTS_HASH_PERSONALIZATION: &[u8; 16] = b"ZcashPrevoutHash";
const ZCASH_SEQUENCE_HASH_PERSONALIZATION: &'static [u8; 16] = b"ZcashSequencHash"; const ZCASH_SEQUENCE_HASH_PERSONALIZATION: &[u8; 16] = b"ZcashSequencHash";
const ZCASH_OUTPUTS_HASH_PERSONALIZATION: &'static [u8; 16] = b"ZcashOutputsHash"; const ZCASH_OUTPUTS_HASH_PERSONALIZATION: &[u8; 16] = b"ZcashOutputsHash";
const ZCASH_JOINSPLITS_HASH_PERSONALIZATION: &'static [u8; 16] = b"ZcashJSplitsHash"; const ZCASH_JOINSPLITS_HASH_PERSONALIZATION: &[u8; 16] = b"ZcashJSplitsHash";
const ZCASH_SHIELDED_SPENDS_HASH_PERSONALIZATION: &'static [u8; 16] = b"ZcashSSpendsHash"; const ZCASH_SHIELDED_SPENDS_HASH_PERSONALIZATION: &[u8; 16] = b"ZcashSSpendsHash";
const ZCASH_SHIELDED_OUTPUTS_HASH_PERSONALIZATION: &'static [u8; 16] = b"ZcashSOutputHash"; const ZCASH_SHIELDED_OUTPUTS_HASH_PERSONALIZATION: &[u8; 16] = b"ZcashSOutputHash";
pub const SIGHASH_ALL: u32 = 1; pub const SIGHASH_ALL: u32 = 1;
const SIGHASH_NONE: u32 = 2; const SIGHASH_NONE: u32 = 2;

View File

@ -16,8 +16,8 @@ use crate::{
JUBJUB, JUBJUB,
}; };
pub const ZIP32_SAPLING_MASTER_PERSONALIZATION: &'static [u8; 16] = b"ZcashIP32Sapling"; pub const ZIP32_SAPLING_MASTER_PERSONALIZATION: &[u8; 16] = b"ZcashIP32Sapling";
pub const ZIP32_SAPLING_FVFP_PERSONALIZATION: &'static [u8; 16] = b"ZcashSaplingFVFP"; pub const ZIP32_SAPLING_FVFP_PERSONALIZATION: &[u8; 16] = b"ZcashSaplingFVFP";
// Common helper functions // Common helper functions
@ -83,9 +83,9 @@ impl ChildIndex {
} }
fn to_index(&self) -> u32 { fn to_index(&self) -> u32 {
match self { match *self {
&ChildIndex::Hardened(i) => i + (1 << 31), ChildIndex::Hardened(i) => i + (1 << 31),
&ChildIndex::NonHardened(i) => i, ChildIndex::NonHardened(i) => i,
} }
} }
} }