-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor enc_ciphertext to return reference instead of copy #13
Conversation
These changes were discussed and suggested in PR zcash_note_encryption#2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor fixes are needed.
src/lib.rs
Outdated
@@ -44,28 +44,22 @@ pub mod note_bytes; | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't want new term pre-ZSA Orchard
.
... for Sapling and Orchard
is fine (x2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (removed unused constants COMPACT_NOTE_SIZE, NOTE_PLAINTEXT_SIZE, ENC_CIPHERTEXT_SIZE with those comments).
src/lib.rs
Outdated
/// The size of [`OutPlaintextBytes`]. | ||
pub const OUT_PLAINTEXT_SIZE: usize = 32 + // pk_d | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should keep the original constants. this might create confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (removed the constants and updated CHANGELOG accordingly).
…IPHERTEXT_SIZE, and update CHANGELOG accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
ShieldedOutput
trait to return a reference from theenc_ciphertext
method 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
.