From 72491df4ff9e91ea8780677b2ad5bdbab831c4ce Mon Sep 17 00:00:00 2001 From: Deirdre Connolly Date: Mon, 5 Apr 2021 13:22:42 -0400 Subject: [PATCH] orchard: move IncomingViewingKey::from([u8; 32]) to a ::from_bytes([u8; 32], Newtwork) --- zebra-chain/src/orchard/keys.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/zebra-chain/src/orchard/keys.rs b/zebra-chain/src/orchard/keys.rs index cfe0c947..4e367da3 100644 --- a/zebra-chain/src/orchard/keys.rs +++ b/zebra-chain/src/orchard/keys.rs @@ -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 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. ///