-
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
Synchronize Orchard with updates from zcash_note_encryption for zcash PR #2 issues resolve #111
Conversation
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.
added minor comments and a question
@@ -25,7 +25,11 @@ impl<A, D: OrchardDomainCommon> ShieldedOutput<OrchardDomain<D>> for Action<A, D | |||
} | |||
|
|||
fn enc_ciphertext_compact(&self) -> D::CompactNoteCiphertextBytes { | |||
self.encrypted_note().enc_ciphertext.as_ref()[..D::COMPACT_NOTE_SIZE].into() | |||
// FIXME: can use unwrap here? |
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.
yes
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.
Got it, removed the comment.
fn enc_ciphertext_compact(&self) -> D::CompactNoteCiphertextBytes { | ||
self.enc_ciphertext | ||
// FIXME: can use unwrap here? |
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.
yes
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.
Got it, removed the comment.
@@ -70,8 +74,10 @@ impl<D: OrchardDomainCommon> ShieldedOutput<OrchardDomain<D>> for CompactAction< | |||
None | |||
} | |||
|
|||
// FIXME: shouldn't it return None like enc_ciphertext does? |
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.
no, enc_ciphertext
should not be used for Orchard. It was used only by sapling.
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.
Got it, removed the comment.
src/note_encryption/domain.rs
Outdated
fn parse_note_plaintext_bytes(plaintext: &[u8]) -> Option<Self::NotePlaintextBytes> { | ||
Self::NotePlaintextBytes::from_slice(plaintext) | ||
} | ||
|
||
fn parse_note_ciphertext_bytes( | ||
output: &[u8], | ||
tag: [u8; AEAD_TAG_SIZE], | ||
) -> Option<Self::NoteCiphertextBytes> { | ||
Self::NoteCiphertextBytes::from_slice_with_tag(output, tag) | ||
} | ||
|
||
fn parse_compact_note_plaintext_bytes( | ||
plaintext: &[u8], | ||
) -> Option<Self::CompactNotePlaintextBytes> { | ||
Self::CompactNotePlaintextBytes::from_slice(plaintext) | ||
} |
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.
What is the point in adding this if not being used?
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.
The idea of introducing these functions came from str4d's review comment. Although these functions are not used in the orchard
or sapling-crypto
crates directly, they are used in the zcash_note_encryption
crate: zcash_note_encryption
delegates the implementation of these functions to upper-level crates, and then use them.
Therefore, I added them to the Domain
trait as methods and then implemented them in both orchard
and sapling-crypto
crates.
However, as it turns out, the implementation is the same for both crates and relies solely on the NoteBytes
trait methods. Given this, we can simplify the code by moving these function implementations directly to the Domain
trait in the zcash_note_encryption
crate.
I have tested this change, and it works correctly. I can proceed with moving the implementation (here and in sapling-crypto
) if everyone agrees.
… to reduce changes in PR
Orchard has been synced with the changes from PR #10 in the
zcash_note_encryption
repository. This update includes the following changes:parse_note_plaintext_bytes
,parse_note_ciphertext_bytes
, andparse_compact_note_plaintext_bytes
methods of theDomain
trait fromzcash_note_encryption
.NoteBytes
trait andNoteBytesData
structure fromzcash_note_encryption
instead of having local definitions and implementations.Note
This PR uses the
resolve_zcash_pr2_issues
branch ofzcash_note_encryption
inCargo.toml
. Before merging this PR, PR #10 needs to be merged into thezsa1
branch ofzcash_note_encryption
. Then, this Orchard PR branch should be updated to use thezsa1
branch ofzcash_note_encryption
befor merging this PR.