diff --git a/CHANGELOG.md b/CHANGELOG.md index e329e12..ce54830 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this library adheres to Rust's notion of [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- A blanket `impl ShieldedOutput for &O` + where `D: Domain, O: ShieldedOutput` + ### Changed - **Breaking change:** removed the constants `COMPACT_NOTE_SIZE`, `NOTE_PLAINTEXT_SIZE`, and `ENC_CIPHERTEXT_SIZE` as they are now @@ -27,6 +31,10 @@ and this library adheres to Rust's notion of `Option` of a reference instead of a copy. - Added a new `note_bytes` module with helper trait and struct to deal with note bytes data with abstracted underlying array size. +- `ShieldedOutput` has added method `cmstar`, which exposes the + `ExtractedCommitment` of the shielded output directly, in addition to the + byte encoding exposed by `ShieldedOutput::cmstar_bytes`. This is useful for + further generalizing scanning code. ## [0.4.1] - 2024-12-06 ### Added @@ -34,7 +42,7 @@ and this library adheres to Rust's notion of ## [0.4.0] - 2023-06-06 ### Changed -- The `esk` and `ephemeral_key` arguments have been removed from +- The `esk` and `ephemeral_key` arguments have been removed from `Domain::parse_note_plaintext_without_memo_ovk`. It is therefore no longer necessary (or possible) to ensure that `ephemeral_key` is derived from `esk` and the diversifier within the note plaintext. We have analyzed the safety of @@ -46,7 +54,7 @@ and this library adheres to Rust's notion of ## [0.3.0] - 2023-03-22 ### Changed - The `recipient` parameter has been removed from `Domain::note_plaintext_bytes`. -- The `recipient` parameter has been removed from `NoteEncryption::new`. Since +- The `recipient` parameter has been removed from `NoteEncryption::new`. Since the `Domain::Note` type is now expected to contain information about the recipient of the note, there is no longer any need to pass this information in via the encryption context. diff --git a/src/lib.rs b/src/lib.rs index 8b8a60d..23d5563 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -356,8 +356,13 @@ pub trait ShieldedOutput { /// Exposes the `ephemeral_key` field of the output. fn ephemeral_key(&self) -> EphemeralKeyBytes; - /// Exposes the `cmu_bytes` or `cmx_bytes` field of the output. - fn cmstar_bytes(&self) -> D::ExtractedCommitmentBytes; + /// Exposes the `cmu` or `cmx` field of the output. + fn cmstar(&self) -> &D::ExtractedCommitment; + + /// Exposes the `cmu_bytes` or `cmx_bytes` representation of the output. + fn cmstar_bytes(&self) -> D::ExtractedCommitmentBytes { + D::ExtractedCommitmentBytes::from(self.cmstar()) + } /// Exposes the note ciphertext of the output. Returns `None` if the output is compact. fn enc_ciphertext(&self) -> Option<&D::NoteCiphertextBytes>; @@ -389,6 +394,28 @@ pub trait ShieldedOutput { } } +impl ShieldedOutput for &O +where + D: Domain, + O: ShieldedOutput, +{ + fn ephemeral_key(&self) -> EphemeralKeyBytes { + (*self).ephemeral_key() + } + + fn cmstar(&self) -> &::ExtractedCommitment { + (*self).cmstar() + } + + fn enc_ciphertext(&self) -> Option<&::NoteCiphertextBytes> { + (*self).enc_ciphertext() + } + + fn enc_ciphertext_compact(&self) -> ::CompactNoteCiphertextBytes { + (*self).enc_ciphertext_compact() + } +} + /// A struct containing context required for encrypting Sapling and Orchard notes. /// /// This struct provides a safe API for encrypting Sapling and Orchard notes. In particular, it