Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<D, O, const CIPHERTEXT_SIZE: usize> ShieldedOutput<D, CIPHERTEXT_SIZE> for &O`
where `D: Domain, O: ShieldedOutput<D, CIPHERTEXT_SIZE>`

### Changed
- **Breaking change:** removed the constants `COMPACT_NOTE_SIZE`,
`NOTE_PLAINTEXT_SIZE`, and `ENC_CIPHERTEXT_SIZE` as they are now
Expand All @@ -27,14 +31,18 @@ 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
- `zcash_note_encryption::try_output_recovery_with_pkd_esk`

## [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
Expand All @@ -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.
Expand Down
31 changes: 29 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,13 @@ pub trait ShieldedOutput<D: Domain> {
/// 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>;
Expand Down Expand Up @@ -389,6 +394,28 @@ pub trait ShieldedOutput<D: Domain> {
}
}

impl<D, O> ShieldedOutput<D> for &O
where
D: Domain,
O: ShieldedOutput<D>,
{
fn ephemeral_key(&self) -> EphemeralKeyBytes {
(*self).ephemeral_key()
}

fn cmstar(&self) -> &<D as Domain>::ExtractedCommitment {
(*self).cmstar()
}

fn enc_ciphertext(&self) -> Option<&<D as Domain>::NoteCiphertextBytes> {
(*self).enc_ciphertext()
}

fn enc_ciphertext_compact(&self) -> <D as Domain>::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
Expand Down