Skip to content

Commit

Permalink
Adopt str4d's suggestion.
Browse files Browse the repository at this point in the history
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
  • Loading branch information
daira committed Feb 17, 2025
1 parent b9c2120 commit a07c889
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ and this library adheres to Rust's notion of

## [Unreleased]
### Added
- `zcash_spec::PrfExpand::{REGISTERED_ZIP32_CHILD, with_tag}` (for tagged ZIP 32
child derivation).
- `zcash_spec::PrfExpand::REGISTERED_ZIP32_CHILD` (for tagged ZIP 32 child
derivation).

## [0.1.2] - 2024-10-01
### Added
Expand Down
20 changes: 5 additions & 15 deletions src/prf_expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ impl PrfExpand<([u8; 32], [u8; 4])> {
pub const SPROUT_ZIP32_CHILD: Self = Self::new(0x80);
pub const ORCHARD_ZIP32_CHILD: Self = Self::new(0x81);
pub const ARBITRARY_ZIP32_CHILD: Self = Self::new(0xAB);
pub const REGISTERED_ZIP32_CHILD: Self = Self::new(0xAC);
}
impl PrfExpand<([u8; 32], [u8; 32])> {
pub const ORCHARD_DK_OVK: Self = Self::new(0x82);
Expand All @@ -109,22 +110,11 @@ impl PrfExpand<([u8; 96], [u8; 32], [u8; 4])> {
}
with_inputs!(a, A, b, B, c, C);

impl PrfExpand<([u8; 32], [u8; 4])> {
impl PrfExpand<([u8; 32], [u8; 4], [u8; 1], &[u8])> {
pub const REGISTERED_ZIP32_CHILD: Self = Self::new(0xAC);

/// Expands the given secret key in this domain, with additional `lead`
/// and `tag` inputs.
pub fn with_tag(
self,
c_par: &[u8],
sk_par: &[u8; 32],
i: &[u8; 4],
lead: Option<u8>,
tag: &[u8],
) -> [u8; 64] {
match lead {
None => self.apply(c_par, &[sk_par, i, tag]),
Some(b) => self.apply(c_par, &[sk_par, i, &[b], tag]),
}
/// Expands the given secret key in this domain.
pub fn with(self, sk: &[u8], a: &[u8; 32], b: &[u8; 4], c: &[u8; 1], d: &[u8]) -> [u8; 64] {
self.apply(sk, &[a, b, c, d])
}
}

0 comments on commit a07c889

Please sign in to comment.