Skip to content

Commit

Permalink
Add APIs for trial decrypting PCZT outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
str4d committed Dec 16, 2024
1 parent 4fc9b5e commit 9e585ac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to Rust's notion of
### Added
- Support for Partially-Created Zcash Transactions:
- `orchard::builder::Builder::build_for_pczt`
- `orchard::note_encryption`:
- `OrchardDomain::for_pczt_action`
- `impl ShieldedOutput<OrchardDomain, ENC_CIPHERTEXT_SIZE> for orchard::pczt::Action`
- `orchard::pczt` module.
- `orchard::bundle::EffectsOnly`
- `orchard::tree::MerklePath::{position, auth_path}`
Expand Down
21 changes: 21 additions & 0 deletions src/note_encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ impl OrchardDomain {
Self { rho: act.rho() }
}

/// Constructs a domain that can be used to trial-decrypt a PCZT action's output note.
pub fn for_pczt_action(act: &crate::pczt::Action) -> Self {
Self {
rho: Rho::from_nf_old(act.spend().nullifier),
}
}

/// Constructs a domain that can be used to trial-decrypt this action's output note.
pub fn for_compact_action(act: &CompactAction) -> Self {
Self { rho: act.rho() }
Expand Down Expand Up @@ -266,6 +273,20 @@ impl<T> ShieldedOutput<OrchardDomain, ENC_CIPHERTEXT_SIZE> for Action<T> {
}
}

impl ShieldedOutput<OrchardDomain, ENC_CIPHERTEXT_SIZE> for crate::pczt::Action {
fn ephemeral_key(&self) -> EphemeralKeyBytes {
EphemeralKeyBytes(self.output().encrypted_note().epk_bytes)
}

fn cmstar_bytes(&self) -> [u8; 32] {
self.output().cmx().to_bytes()
}

fn enc_ciphertext(&self) -> &[u8; ENC_CIPHERTEXT_SIZE] {
&self.output().encrypted_note().enc_ciphertext
}
}

/// A compact Action for light clients.
#[derive(Clone)]
pub struct CompactAction {
Expand Down

0 comments on commit 9e585ac

Please sign in to comment.