Skip to content
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

Return ref from enc ciphertext #3

Merged
merged 9 commits into from
Aug 19, 2024
Merged

Conversation

dmidem
Copy link

@dmidem dmidem commented Aug 8, 2024

This PR updates the ShieldedOutput implementation and OutputDescription struct to align with the recent changes in the zcash_note_encryption crate. Specifically, the enc_ciphertext method now returns a reference instead of a copy. Also, it changed enc_ciphertext storage in OutputDescription to NoteBytesData.

This change was discussed and suggested in PR zcash/zcash_note_encryption#2 review.

@dmidem dmidem requested a review from PaulLaux August 13, 2024 13:44
Copy link

@PaulLaux PaulLaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comments to simplify

src/bundle.rs Outdated
@@ -342,7 +343,7 @@ impl<Proof> OutputDescription<Proof> {
}

/// Returns the encrypted note ciphertext.
pub fn enc_ciphertext(&self) -> &[u8; ENC_CIPHERTEXT_SIZE] {
pub fn enc_ciphertext(&self) -> &<SaplingDomain as Domain>::NoteCiphertextBytes {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's stick to simply

 /// Returns the encrypted note ciphertext.
    pub fn enc_ciphertext(&self) -> &NoteBytesData<{ ENC_CIPHERTEXT_SIZE }> {
        &self.enc_ciphertext
    }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

src/bundle.rs Outdated
@@ -414,8 +415,8 @@ impl<A> ShieldedOutput<SaplingDomain> for OutputDescription<A> {
self.cmu.to_bytes()
}

fn enc_ciphertext(&self) -> Option<<SaplingDomain as Domain>::NoteCiphertextBytes> {
Some(NoteBytesData(self.enc_ciphertext))
fn enc_ciphertext(&self) -> Option<&<SaplingDomain as Domain>::NoteCiphertextBytes> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fn enc_ciphertext(&self) -> Option<&NoteBytesData<{ ENC_CIPHERTEXT_SIZE }>> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for row 442:
fn enc_ciphertext_compact(&self) -> NoteBytesData<{ COMPACT_NOTE_SIZE }> {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -351,7 +362,7 @@ impl ShieldedOutput<SaplingDomain> for CompactOutputDescription {
self.cmu.to_bytes()
}

fn enc_ciphertext(&self) -> Option<<SaplingDomain as Domain>::NoteCiphertextBytes> {
fn enc_ciphertext(&self) -> Option<&<SaplingDomain as Domain>::NoteCiphertextBytes> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link

@PaulLaux PaulLaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure we have the librustzcash required changes as well

@dmidem dmidem merged commit 99ad0a5 into zsa1 Aug 19, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants