Derive internal full viewing key.

This commit is contained in:
therealyingtong 2022-01-06 23:11:37 +08:00
parent 2412e83400
commit 99119f04fa
1 changed files with 16 additions and 0 deletions

View File

@ -418,6 +418,22 @@ impl FullViewingKey {
Some(FullViewingKey { ak, nk, rivk })
}
/// Derives an internal full viewing key from a full viewing key, as specified in [ZIP32][orchardinternalfullviewingkey]
///
/// [orchardinternalfullviewingkey]: https://zips.z.cash/zip-0032#orchard-internal-key-derivation
pub fn derive_internal(&self) -> Option<Self> {
let k = self.rivk().to_bytes();
let rivk_internal = PrfExpand::OrchardRivkInternal
.with_ad_slices(&k, &[&self.ak.clone().to_bytes(), &self.nk().to_bytes()]);
let rivk_internal = CommitIvkRandomness::from_bytes(&rivk_internal)?;
Some(FullViewingKey {
ak: self.ak.clone(),
nk: self.nk,
rivk: rivk_internal,
})
}
}
/// A key that provides the capability to derive a sequence of diversifiers.