Remove `PartialEq, PartialOrd` impls from `{Extended}SpendingKey`

This commit is contained in:
Jack Grigg 2021-11-30 23:25:35 +00:00
parent 674ceb54c8
commit 37f1bba998
2 changed files with 10 additions and 19 deletions

View File

@ -32,7 +32,7 @@ const ZIP32_PURPOSE: u32 = 32;
/// Defined in [Zcash Protocol Spec § 4.2.3: Orchard Key Components][orchardkeycomponents].
///
/// [orchardkeycomponents]: https://zips.z.cash/protocol/nu5.pdf#orchardkeycomponents
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Debug, Copy, Clone)]
pub struct SpendingKey([u8; 32]);
impl ConstantTimeEq for SpendingKey {

View File

@ -112,16 +112,6 @@ impl ConstantTimeEq for ExtendedSpendingKey {
}
}
impl std::cmp::PartialEq for ExtendedSpendingKey {
fn eq(&self, rhs: &ExtendedSpendingKey) -> bool {
self.depth == rhs.depth
&& self.parent_fvk_tag == rhs.parent_fvk_tag
&& self.child_index == rhs.child_index
&& self.chain_code == rhs.chain_code
&& self.sk == rhs.sk
}
}
#[allow(non_snake_case)]
impl ExtendedSpendingKey {
/// Returns the spending key of the child key corresponding to
@ -240,16 +230,17 @@ mod tests {
let xsk_m = ExtendedSpendingKey::master(&seed).unwrap();
let xsk_5h = xsk_m.derive_child(5.try_into().unwrap()).unwrap();
assert_eq!(
ExtendedSpendingKey::from_path(&seed, &[5.try_into().unwrap()]).unwrap(),
xsk_5h
);
assert!(bool::from(
ExtendedSpendingKey::from_path(&seed, &[5.try_into().unwrap()])
.unwrap()
.ct_eq(&xsk_5h)
));
let xsk_5h_7 = xsk_5h.derive_child(7.try_into().unwrap()).unwrap();
assert_eq!(
assert!(bool::from(
ExtendedSpendingKey::from_path(&seed, &[5.try_into().unwrap(), 7.try_into().unwrap()])
.unwrap(),
xsk_5h_7
);
.unwrap()
.ct_eq(&xsk_5h_7)
));
}
}