Add OrchardDomain::for_nullifier and CompactAction::from_parts

This commit is contained in:
Hazel OHearn 2022-06-22 17:34:34 -03:00
parent 8aba4c59fd
commit 4e12b4e90a
No known key found for this signature in database
GPG Key ID: 8B008A957E71F0F8
1 changed files with 22 additions and 0 deletions

View File

@ -92,6 +92,11 @@ impl OrchardDomain {
rho: *act.nullifier(),
}
}
/// Constructs a domain from a nullifier.
pub fn for_nullifier<T>(nullifier: Nullifier) -> Self {
OrchardDomain { rho: nullifier }
}
}
impl Domain for OrchardDomain {
@ -307,6 +312,23 @@ impl ShieldedOutput<OrchardDomain, COMPACT_NOTE_SIZE> 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;