(cleanup) Make the internals of `zip32::DiversifierKey` private

This commit is contained in:
Kris Nuttycombe 2022-09-08 11:09:43 -06:00
parent 8439f1a4f7
commit 7b7288c750
3 changed files with 7 additions and 4 deletions

View File

@ -17,7 +17,8 @@ and this library adheres to Rust's notion of
- `ExtendedSpendingKey::{from_bytes, to_bytes}`
- Added in `zcash_primitives::zip32`
- `ChainCode::as_bytes`
- `DiversifierIndex::as_bytes`
- `DiversifierKey::{from_bytes, as_bytes}`
- `DiversifierIndex::{as_bytes}`
- `ExtendedSpendingKey::{from_bytes, to_bytes}`
- Implementations of `From<u32>` and `From<u64>` for `DiversifierIndex`
@ -27,6 +28,8 @@ and this library adheres to Rust's notion of
- The signature of `zcash_primitives::sapling::Note::nf` has changed to
take just a `NullifierDerivingKey` (the only capability it actually required)
rather than the full `ViewingKey` as its first argument.
- Made the internals of `zip32::DiversifierKey` private; use `from_bytes` and
`as_bytes` on this type instead.
## [0.7.0] - 2022-06-24
### Changed

View File

@ -233,7 +233,7 @@ impl DiversifiableFullViewingKey {
pub fn from_bytes(bytes: &[u8; 128]) -> Option<Self> {
FullViewingKey::read(&bytes[..96]).ok().map(|fvk| Self {
fvk,
dk: zip32::DiversifierKey(bytes[96..].try_into().unwrap()),
dk: zip32::DiversifierKey::from_bytes(bytes[96..].try_into().unwrap()),
})
}
@ -243,7 +243,7 @@ impl DiversifiableFullViewingKey {
self.fvk
.write(&mut bytes[..96])
.expect("slice should be the correct length");
bytes[96..].copy_from_slice(&self.dk.0);
bytes[96..].copy_from_slice(&self.dk.as_bytes()[..]);
bytes
}

View File

@ -179,7 +179,7 @@ impl DiversifierIndex {
/// A key used to derive diversifiers for a particular child key
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct DiversifierKey(pub [u8; 32]);
pub struct DiversifierKey([u8; 32]);
impl DiversifierKey {
pub fn master(sk_m: &[u8]) -> Self {