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

adjust to zcash_note_encryption changes #2

Merged
merged 10 commits into from
Jul 31, 2024

Conversation

dmidem
Copy link

@dmidem dmidem commented Jul 30, 2024

This PR synchronizes the sapling-crypto repository with the updates from PR #2 in the zcash_note_encryption repository. The changes include:

  • 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.
  • Defines and uses new associated types in the Domain trait: NotePlaintextBytes, NoteCiphertextBytes, CompactNotePlaintextBytes, CompactNoteCiphertextBytes
  • Uses the NoteBytes trait and NoteBytesData structure from zcash_note_encryption.

Note

This PR uses the resolve_zcash_pr2_issues branch of zcash_note_encryption. Before merging this PR, PR #10 needs to be merged into the zsa1 branch of zcash_note_encryption. Additionally, this sapling-crypto PR branch should be updated to use the zsa1 branch of zcash_note_encryption.

Cargo.toml Outdated
@@ -102,3 +102,6 @@ harness = false
[[bench]]
name = "pedersen_hash"
harness = false

[patch.crates-io]
zcash_note_encryption = { version = "0.4", git = "https://github.com/QED-it/zcash_note_encryption", branch = "resolve_zcash_pr2_issues" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we going to merge zcash_note_encryption first and use zsa1 here?

Choose a reason for hiding this comment

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

yes

))
}

fn parse_note_plaintext_bytes(plaintext: &[u8]) -> Option<Self::NotePlaintextBytes> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like the word "parse" here, but that's super minor concern

Copy link
Author

Choose a reason for hiding this comment

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

The idea of having these functions with such names comes from str4d's review comment. Because our initial approach using the From trait did not provide information about errors (and a possible TryFrom replacement did not align with their approach of using Option instead of Error).

There's also an interesting question from @PaulLaux in the corresponding orchard PR review: QED-it/orchard#111 (comment). Now, I am reconsidering whether we really need to implement these functions in bothorchard and sapling-crypto. We could implement them directly in the zcash_note_encryption crate using the new from_slice and from_slice_with_tag methods of the NoteBytes crate (I have described this approach in response to @PaulLaux's review in that orchard PR).

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.

  • remove both FIXME comments.
  • Let's merge zcash_note_encryption and change to zsa1 branch.

src/bundle.rs Outdated
}

fn enc_ciphertext_compact(&self) -> <SaplingDomain as Domain>::CompactNoteCiphertextBytes {
todo!()

Choose a reason for hiding this comment

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

unimplemented!("This function is not required for sapling")
seems like a better option

Copy link
Author

Choose a reason for hiding this comment

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

Updated.

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.

some minor comments and same question for parse_note_..() functions.

@@ -208,7 +214,8 @@ impl Domain for SaplingDomain {

input[COMPACT_NOTE_SIZE..NOTE_PLAINTEXT_SIZE].copy_from_slice(&memo[..]);

NotePlaintextBytes(input)
// FIXME: avoid unwrap usage

Choose a reason for hiding this comment

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

remove comment

Copy link
Author

Choose a reason for hiding this comment

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

Done.

}

fn enc_ciphertext_compact(&self) -> <SaplingDomain as Domain>::CompactNoteCiphertextBytes {
// FIXME: avoid unwrap usage

Choose a reason for hiding this comment

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

remove comment

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@dmidem
Copy link
Author

dmidem commented Jul 30, 2024

some minor comments and same question for parse_note_..() functions.

Replied about parse_note_..() functions in the orchard PR review: QED-it/orchard#111 (comment)

@dmidem dmidem merged commit e19f4d9 into zsa1 Jul 31, 2024
@dmidem dmidem deleted the zcne_resolve_zcash_pr2_issues_sync branch July 31, 2024 11:12
@PaulLaux PaulLaux changed the title Synchronize with updates in zcash_note_encryption made for zcash PR #2 adjust to zcash_note_encryption changes Aug 1, 2024
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.

3 participants