Resolve Issues from PR #2 in zcash/zcash_note_encryption repository#10
Merged
Resolve Issues from PR #2 in zcash/zcash_note_encryption repository#10
Conversation
* Add NoteBytes * Implement concat manually for wasm * Fix slice bounds in concat * Fmt * Split interface and implementation of NoteBytes * Add new method to NoteBytes --------- Co-authored-by: alexeykoren <2365507+alexeykoren@users.noreply.github.com>
…rom ShieldedOutput methods)
PaulLaux
approved these changes
Jul 30, 2024
PaulLaux
left a comment
There was a problem hiding this comment.
approved with some minor comments. Please update orchard and sapling crypto after merge
src/lib.rs
Outdated
Comment on lines
+370
to
+372
| // FIXME: we can't return a ref to NoteCiphertextBytes as it's not a member of self or | ||
| // a static object in saplic-crypto crate (but it is a mamber of self in orchard crate) | ||
| // Should we really need to return Option here? |
src/lib.rs
Outdated
Comment on lines
+376
to
+378
| // FIXME: we can't return a ref to CompactNoteCiphertextBytes as it's not a member of self or | ||
| // a static object neither in orchard nor in saplic-crypto crate | ||
| // FIXME: Should we return Option<...> instead? |
There was a problem hiding this comment.
replace comment with
// FIXME: Should we return `Option<D::CompactNoteCiphertextBytes>` or `&D::CompactNoteCiphertextBytes` instead? (complexity)
src/lib.rs
Outdated
| let (plaintext, tail) = enc_ciphertext.split_at(tag_loc); | ||
|
|
||
| let (plaintext, tail) = enc_ciphertext.split_at_mut(tag_loc); | ||
| let tag: [u8; AEAD_TAG_SIZE] = tail.try_into().expect("tag is correct length"); |
src/lib.rs
Outdated
| .encrypt_in_place_detached([0u8; 12][..].into(), &[], output) | ||
| .unwrap(); | ||
| D::NoteCiphertextBytes::from((output, tag.as_ref())) | ||
| D::parse_note_ciphertext_bytes(output, tag.into()).expect("output is correct length") |
src/note_bytes.rs
Outdated
| return None; | ||
| } | ||
|
|
||
| let mut data: [u8; N] = [0; N]; |
src/lib.rs
Outdated
| } | ||
| } | ||
|
|
||
| // FIXME: rename to split_ciphertext_at_tag? make it a method of ShieldedOutput trait? |
| output: &[u8], | ||
| tag: [u8; TAG_SIZE], | ||
| ) -> Option<NoteBytesData<N>> { | ||
| let expected_output_len = N.checked_sub(TAG_SIZE)?; |
dmidem
added a commit
to QED-it/orchard
that referenced
this pull request
Jul 31, 2024
… PR #2 issues resolve (#111) Orchard has been synced with the changes from [PR #10](QED-it/zcash_note_encryption#10) in the `zcash_note_encryption` repository. This update includes the following changes: - Implements new `parse_note_plaintext_bytes`, `parse_note_ciphertext_bytes`, and `parse_compact_note_plaintext_bytes` methods of the `Domain` trait from `zcash_note_encryption`. - Uses the `NoteBytes` trait and `NoteBytesData` structure from `zcash_note_encryption` instead of having local definitions and implementations. ### Note This PR uses the `resolve_zcash_pr2_issues` branch of `zcash_note_encryption` in `Cargo.toml`. Before merging this PR, [PR #10](zcash/zcash_note_encryption#10) needs to be merged into the `zsa1` branch of `zcash_note_encryption`. Then, this Orchard PR branch should be updated to use the `zsa1` branch of `zcash_note_encryption` befor merging this PR. --------- Co-authored-by: Dmitry Demin <dmitry@qed-it.com>
PaulLaux
pushed a commit
that referenced
this pull request
Aug 13, 2025
Add `ShieldedOutput::cmstar`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses the issues and suggestions raised in PR #2 of the
zcash/zcash_note_encryptionrepository. The changes made in this branch include:Reintroduced constants such as
COMPACT_NOTE_SIZE,NOTE_PLAINTEXT_SIZE, andENC_CIPHERTEXT_SIZE.Introduced a new
NoteBytestrait to handle fixed-size byte arrays used in note encryption. AddedNoteBytesDatagenerict structure and ImplementedNoteBytesforNoteBytesDatato encapsulate byte handling and parsing logic.Updated the
Domaintrait to use theNoteBytestrait forNotePlaintextBytes,NoteCiphertextBytes,CompactNotePlaintextBytes, andCompactNoteCiphertextBytes.Added new parsing methods (
parse_note_plaintext_bytes,parse_note_ciphertext_bytes,parse_compact_note_plaintext_bytes) to theDomaintrait to handle conversions safely. These methods replace the previous use ofFromtraits, which did not handle possible failures due to incorrect byte slice sizes. Updated the encryption and decryption functions to use these new parsing methods.Renamed
extract_memotosplit_plaintext_at_memoto better reflect its functionality.Refactored the
extract_tagfunction to work with the newNoteBytestrait and renamed it tosplit_ciphertext_at_tag.Additional Notes
The
ShieldedOutputtrait methodsenc_ciphertextandenc_ciphertext_compactstill return copies instead of references due to implementation constraints. Further refactoring may be required to address this.