diff --git a/CHANGELOG.md b/CHANGELOG.md index dfc144e09..cbf8cda7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,14 @@ visibility of methods and struct for the `unstable-frost` feature. - Added `SpendValidatingKey` serialization and deserialization from bytes visibility under the `unstable-frost` feature - `orchard::keys::SpendValidatingKey` +- Added `from_sk_and_ask::keys::FullViewingKey::from_sk_and_ask` under the +`unstable-frost` feature flag +- Added `from_sk_and_ask::keys::FullViewingKey::from_checked_parts` under the +`unstable-frost` feature flag + +### Modified +- `CommitIvkRandomness` is pub for `unstable-frost` feature +- `NullifierDerivingKey` is pub for `unstable-frost` feature ## [0.8.0] - 2024-03-25 diff --git a/src/keys.rs b/src/keys.rs index 4becf1150..aa8b62d66 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -223,6 +223,7 @@ impl SpendValidatingKey { /// [`Note`]: crate::note::Note /// [orchardkeycomponents]: https://zips.z.cash/protocol/nu5.pdf#orchardkeycomponents #[derive(Copy, Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "unstable-frost", visibility::make(pub))] pub(crate) struct NullifierDerivingKey(pallas::Base); impl NullifierDerivingKey { @@ -264,6 +265,7 @@ impl NullifierDerivingKey { /// /// [orchardkeycomponents]: https://zips.z.cash/protocol/nu5.pdf#orchardkeycomponents #[derive(Copy, Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "unstable-frost", visibility::make(pub))] pub(crate) struct CommitIvkRandomness(pallas::Scalar); impl From<&SpendingKey> for CommitIvkRandomness { @@ -331,6 +333,36 @@ impl From for SpendValidatingKey { } impl FullViewingKey { + /// Creates a `FullViewingKey` from a `SpendingKey` and `SpendValidatingKey`. + /// This is necessary for FROST key management. + /// + /// Note: See [FROST Book - Technical details](https://frost.zfnd.org/zcash/technical-details.html) + #[cfg(feature = "unstable-frost")] + pub fn from_sk_and_ask(sk: &SpendingKey, ask: SpendValidatingKey) -> FullViewingKey { + FullViewingKey { + ak: ask, + nk: NullifierDerivingKey::from(sk), + rivk: CommitIvkRandomness::from(sk), + } + } + + /// Creates a `FullViewingKey` from its checked parts. This is necessary for FROST + /// key management in order to avoid centralizing spend authority in a backup scheme. + /// + /// Note: See [FROST Book - Technical details - Backing Up Key Shares](https://frost.zfnd.org/zcash/technical-details.html) + #[cfg(feature = "unstable-frost")] + pub fn from_checked_parts( + ask: SpendValidatingKey, + nk: NullifierDerivingKey, + rivk: CommitIvkRandomness, + ) -> FullViewingKey { + FullViewingKey { + ak: ask, + nk, + rivk, + } + } + pub(crate) fn nk(&self) -> &NullifierDerivingKey { &self.nk }