From 22dd30f9c97f2bfa477355e99a8e54707f2c3db4 Mon Sep 17 00:00:00 2001 From: Francisco Gindre Date: Wed, 31 Jul 2024 09:51:36 -0300 Subject: [PATCH] [#1477] Allow Orchard-only UFVK be created from an Orchard FVK closes #1477 closes #1476 --- zcash_keys/CHANGELOG.md | 6 +++++- zcash_keys/Cargo.toml | 3 +++ zcash_keys/src/keys.rs | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/zcash_keys/CHANGELOG.md b/zcash_keys/CHANGELOG.md index 38b70e9fba..6fcc42d3a7 100644 --- a/zcash_keys/CHANGELOG.md +++ b/zcash_keys/CHANGELOG.md @@ -6,8 +6,12 @@ and this library adheres to Rust's notion of ## [Unreleased] ### Notable changes -- `zcash_keys` now supports TEX (transparent-source-only) addresses as specified +- `zcash_keys`: + - Now supports TEX (transparent-source-only) addresses as specified in [ZIP 320](https://zips.z.cash/zip-0320). + - Has an `unstable-frost` feature for FROST implementors to use when + API changes are needed specifically for the FROST threshold signatures + use case. ### Added - `zcash_keys::address::Address::try_from_zcash_address` diff --git a/zcash_keys/Cargo.toml b/zcash_keys/Cargo.toml index 8065a60185..22a0643fd4 100644 --- a/zcash_keys/Cargo.toml +++ b/zcash_keys/Cargo.toml @@ -93,6 +93,9 @@ test-dependencies = [ #! ### Experimental features +## Exposes unstable APIs that are compatible with FROST key management +unstable-frost = ["orchard"] + ## Exposes unstable APIs. Their behaviour may change at any time. unstable = ["dep:byteorder"] diff --git a/zcash_keys/src/keys.rs b/zcash_keys/src/keys.rs index 51a39fec70..b2ccb83e78 100644 --- a/zcash_keys/src/keys.rs +++ b/zcash_keys/src/keys.rs @@ -658,6 +658,22 @@ impl UnifiedFullViewingKey { ) } + #[cfg(feature = "unstable-frost")] + pub fn from_orchard_fvk( + orchard: orchard::keys::FullViewingKey, + ) -> Result { + Self::from_checked_parts( + #[cfg(feature = "transparent-inputs")] + None, + #[cfg(feature = "sapling")] + None, + #[cfg(feature = "orchard")] + Some(orchard), + // We don't currently allow constructing new UFVKs with unknown items, but we store + // this to allow parsing such UFVKs. + vec![], + ) + } /// Construct a UFVK from its constituent parts, after verifying that UIVK derivation can /// succeed. fn from_checked_parts(