Skip to content

Update zcash_note_encryption to support variable note plaintext and encrypted note ciphertext sizes (orchard compatible)#14

Closed
vivek-arte wants to merge 12 commits intozsa1from
update_note_plaintext_size_orchard_compatible
Closed

Update zcash_note_encryption to support variable note plaintext and encrypted note ciphertext sizes (orchard compatible)#14
vivek-arte wants to merge 12 commits intozsa1from
update_note_plaintext_size_orchard_compatible

Conversation

@vivek-arte
Copy link
Copy Markdown

This has been done by

  • removing the NotePlaintextBytes struct and creating new types for NotePlaintextBytes and CompactNotePlaintextBytes in the Domain trait. This allows each implementation to set its choice of these data structures.
  • adding the EncNoteCiphertextByes and CompactEncNoteCiphertextBytes types in the Domain trait. This replaces the use of byte arrays ([u8]) to represent encrypted note ciphertexts with the use of specific data structures that can be varied per implementation.
  • Various helper functions are added for access.
  • The core of the encryption and decryption that will vary based on the data structure being used has also been pulled into the Domain trait for independent implementation - this has been done with the aim of minimizing duplication of code.
  • The existing functions have been updated to work with the above changes.

Note that this is


fn separate_tag_from_ciphertext(enc_ciphertext: &Self::EncNoteCiphertextBytes) -> (Self::NotePlaintextBytes, [u8; AEAD_TAG_SIZE]);

fn convert_to_compact_plaintext_type(enc_ciphertext: &Self::CompactEncNoteCiphertextBytes) -> Self::CompactNotePlaintextBytes;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should be used as From and Into

/// `EphemeralSecretKey`.
fn extract_esk(out_plaintext: &OutPlaintextBytes) -> Option<Self::EphemeralSecretKey>;

fn separate_tag_from_ciphertext(enc_ciphertext: &Self::EncNoteCiphertextBytes) -> (Self::NotePlaintextBytes, [u8; AEAD_TAG_SIZE]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[u8; AEAD_TAG_SIZE] should have a struct

/// Exposes the note ciphertext of the output.
fn enc_ciphertext(&self) -> &[u8; CIPHERTEXT_SIZE];
/// Exposes the note ciphertext of the output. Returns `None` if the output is compact.
fn enc_ciphertext(&self) -> Option<D::EncNoteCiphertextBytes>;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

attempt to unify with CompactEncNoteCiphertextBytes.

…textBytes, wrapping the AEADBytes in a struct
@PaulLaux
Copy link
Copy Markdown
Collaborator

closed in favor of #18

@PaulLaux PaulLaux closed this Jan 24, 2023
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