orchard: move IncomingViewingKey::from([u8; 32]) to a ::from_bytes([u8; 32], Newtwork)

This commit is contained in:
Deirdre Connolly 2021-04-05 13:22:42 -04:00 committed by Deirdre Connolly
parent 8d357faf73
commit 72491df4ff
1 changed files with 10 additions and 11 deletions

View File

@ -468,17 +468,6 @@ impl fmt::Display for IncomingViewingKey {
}
}
impl From<[u8; 32]> for IncomingViewingKey {
/// Generate an _IncomingViewingKey_ from existing bytes.
fn from(bytes: [u8; 32]) -> Self {
Self {
// TODO: handle setting the Network better.
network: Network::default(),
scalar: pallas::Scalar::from_bytes(&bytes).unwrap(),
}
}
}
impl From<FullViewingKey> for IncomingViewingKey {
/// Commit^ivk_rivk(ak, nk) :=
/// SinsemillaShortCommit_rcm ("z.cash:Orchard-CommitIvk", I2LEBSP_l(ak) || I2LEBSP_l(nk)) mod r_P
@ -542,6 +531,16 @@ impl PartialEq<[u8; 32]> for IncomingViewingKey {
}
}
impl IncomingViewingKey {
/// Generate an _IncomingViewingKey_ from existing bytes and a network variant.
fn from_bytes(bytes: [u8; 32], network: Network) -> Self {
Self {
network,
scalar: pallas::Scalar::from_bytes(&bytes).unwrap(),
}
}
}
/// Magic human-readable strings used to identify what networks Orchard full
/// viewing keys are associated with when encoded/decoded with bech32.
///