Refactor enc_ciphertext to return reference instead of copy#13
Conversation
These changes were discussed and suggested in PR zcash_note_encryption#2
src/lib.rs
Outdated
| use note_bytes::NoteBytes; | ||
|
|
||
| /// The size of a compact note for Sapling and Orchard Vanilla. | ||
| /// The size of a compact note for Sapling and pre-ZSA Orchard. |
There was a problem hiding this comment.
we don't want new term pre-ZSA Orchard.
... for Sapling and Orchard is fine (x2)
There was a problem hiding this comment.
Done (removed unused constants COMPACT_NOTE_SIZE, NOTE_PLAINTEXT_SIZE, ENC_CIPHERTEXT_SIZE with those comments).
src/lib.rs
Outdated
| 32; // esk | ||
| const AEAD_TAG_SIZE: usize = 16; | ||
| /// The size of an encrypted note plaintext for Sapling and pre-ZSA Orchard. | ||
| pub const ENC_CIPHERTEXT_SIZE: usize = NOTE_PLAINTEXT_SIZE + AEAD_TAG_SIZE; |
There was a problem hiding this comment.
remove COMPACT_NOTE_SIZE, NOTE_PLAINTEXT_SIZE, ENC_CIPHERTEXT_SIZE from this file.
These are domain specific values and should be part of the implementation.
CHANGELOG.md
Outdated
| - Updated the `enc_ciphertext` method of the `ShieldedOutput` trait to return an | ||
| `Option` of a reference instead of a copy. | ||
| - Moved the specific constants into the `Domain` trait implementations, while | ||
| keeping the original constants for backward compatibility. |
There was a problem hiding this comment.
I don't think we should keep the original constants. this might create confusion.
There was a problem hiding this comment.
Done (removed the constants and updated CHANGELOG accordingly).
…IPHERTEXT_SIZE, and update CHANGELOG accordingly
PaulLaux
left a comment
There was a problem hiding this comment.
please replace changelog to
- **Breaking change:** removed the constants `COMPACT_NOTE_SIZE`,
`NOTE_PLAINTEXT_SIZE`, and `ENC_CIPHERTEXT_SIZE` as they are now
implementation spesific (located in `orchard` and `sapling-crypto` crates).
- Generalized the note plaintext size to support variable sizes by adding the
abstract types `NotePlaintextBytes`, `NoteCiphertextBytes`,
`CompactNotePlaintextBytes`, and `CompactNoteCiphertextBytes` to the `Domain`
trait.
- Removed the separate `NotePlaintextBytes` type definition (as it is now an
associated type).
- Added new `parse_note_plaintext_bytes`, `parse_note_ciphertext_bytes`, and
`parse_compact_note_plaintext_bytes` methods to the `Domain` trait.
- Updated the `note_plaintext_bytes` method of the `Domain` trait to return the
`NotePlaintextBytes` associated type.
- Updated the `encrypt_note_plaintext` method of `NoteEncryption` to return the
`NoteCiphertextBytes` associated type of the `Domain` instead of the explicit
array.
- Updated the `enc_ciphertext` method of the `ShieldedOutput` trait to return an
`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.
Done. |
This PR updates the
ShieldedOutputtrait to return a reference from theenc_ciphertextmethod instead of a copy. This change was discussed and suggested in PR zcash#2 review.Other minor changes:
split_plaintext_at_memo.rust-toolchain.toml.COMPACT_NOTE_SIZE,NOTE_PLAINTEXT_SIZE,ENC_CIPHERTEXT_SIZE.CHANGELOG.md.