From 4e12b4e90a68010b303d40b41e07fc99be375b03 Mon Sep 17 00:00:00 2001 From: Hazel OHearn Date: Wed, 22 Jun 2022 17:34:34 -0300 Subject: [PATCH] Add OrchardDomain::for_nullifier and CompactAction::from_parts --- src/note_encryption.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/note_encryption.rs b/src/note_encryption.rs index 7aed1831..9ef73c26 100644 --- a/src/note_encryption.rs +++ b/src/note_encryption.rs @@ -92,6 +92,11 @@ impl OrchardDomain { rho: *act.nullifier(), } } + + /// Constructs a domain from a nullifier. + pub fn for_nullifier(nullifier: Nullifier) -> Self { + OrchardDomain { rho: nullifier } + } } impl Domain for OrchardDomain { @@ -307,6 +312,23 @@ impl ShieldedOutput for CompactAction { } } +impl CompactAction { + /// Create a CompactAction from its constituent parts + pub fn from_parts( + nullifier: Nullifier, + cmx: ExtractedNoteCommitment, + ephemeral_key: EphemeralKeyBytes, + enc_ciphertext: [u8; 52], + ) -> Self { + Self { + nullifier, + cmx, + ephemeral_key, + enc_ciphertext, + } + } +} + #[cfg(test)] mod tests { use rand::rngs::OsRng;