Feature: note plaintext size generalization (draft - to create an updated descrition for the main PR) #16
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 continues the discussion from: zcash/librustzcash#746. Some things have changed, and we need an updated review to continue.
In order to support note encryption for ZSA, we suggest extending the current
zcash_note_encryption
implementation. Currently, theCOMPACT_NOTE_SIZE
is a constant; however, we need to support variable note sizes to include theAssetId
field for ZSA notes.Current state in
zcash_note_encryption
:and
Proposed changes:
We suggest converting these constants into new abstract types within the Domain trait:
NotePlaintextBytes
,NoteCiphertextBytes
,CompactNotePlaintextBytes
, andCompactNoteCiphertextBytes
. These types would then be implemented in theorchard
andsapling-crypto
crates.After the discussion of the first version of this PR, the following methods are also proposed to be added to the
Domain
trait to safely convert byte slices into these new types:parse_note_plaintext_bytes
,parse_note_ciphertext_bytes
, andparse_compact_note_plaintext_bytes
.Updated
Domain
trait:Here,
NoteBytes
is a helper trait designed to simplify and unify the definition and implementation of these new associated types.Additionally, constants will be removed from function signatures since they are not known at compilation time. For example:
will be replaced with:
Implementation:
We have provided our initial implementation, complemented by the appropriate changes in the
orchard
andsapling-crypto
crates. See the following modules for details:https://github.com/QED-it/orchard/blob/zsa1/src/note_encryption/domain.rs
https://github.com/QED-it/sapling-crypto/blob/zsa1/src/note_encryption.rs
Additionally, we made several minor updates in the
zcash_primitives
crate of QED-it's fork of thelibrustzcash
repository to align it with the described changes inzcash_note_encryption
,orchard
, andsapling-crypto crates
:https://github.com/QED-it/librustzcash/tree/zsa1/zcash_primitives