Add v2 memo plaintext ciphertext resolution#2555
Conversation
0ebd4dd to
f1b2599
Compare
Represent Orchard encrypted note plaintext as either ciphertext or stripped memo plaintext in the logical PCZT model, and resolve compact fields before Orchard role parsing. Co-Authored-By: OpenAI Codex <codex@openai.com>
f1b2599 to
d620dfa
Compare
| pub fn resolve_fields(&mut self) -> Result<(), ::orchard::pczt::ParseError> { | ||
| self.resolve_memo_plaintexts() | ||
| } |
There was a problem hiding this comment.
I want to add cv_net here in a follow-up PR.
| enc_ciphertext: EncCiphertext::Encrypted( | ||
| output.encrypted_note().enc_ciphertext.to_vec(), | ||
| ), |
There was a problem hiding this comment.
Intentional, as we don't need to deal with "was this a more compressed memo representation". That is purely a redaction-time and serialization time concern.
| action | ||
| .output | ||
| .resolve_memo_plaintext(note_version, spend.nullifier().to_bytes())?; |
There was a problem hiding this comment.
Make this an assign, not a mutative operation
There was a problem hiding this comment.
The advantage of making this a mutative operation is actually that we get to avoid an excess 512 byte memo allocation - this appears in constrained devices, so seems worth the mutative API trade-off.
Have Orchard memo recovery return the stripped MemoPlaintext representation directly, so redaction callers do not need to wrap recovered memo bytes themselves. Also tighten related rustdoc around memo plaintext recovery and redaction terminology. Co-Authored-By: OpenAI Codex <noreply@openai.com>
4225d46 to
94905a4
Compare
| } | ||
| } | ||
|
|
||
| /// A memo plaintext with all trailing zero bytes stripped. |
There was a problem hiding this comment.
It is important to note that there is an invariant that the plaintext maximum length (i.e. the size of the inner vector) is MEMO_SIZE. All constructors MUST verify this invariant, which is the case at the moment, as it is not enforced by the type.
The second constructor, from_stripped_bytes, can construct vectors of any size below MEMO_SIZE.
|
As requested by nuttycom, lets only merge this and next PR until #2539 is merged @dannywillems, we can still get PR approved / ready though |
dannywillems
left a comment
There was a problem hiding this comment.
Blocking merge until 2539 is merged, see #2555 (comment)
I didn't know. Explicitly requesting changes to avoid anyone else merging, in case of other async review/approvals. |
Require callers to construct the Encrypted variant explicitly so the encrypted-ciphertext and memo-plaintext representations remain visible at call sites. Co-Authored-By: OpenAI Codex <noreply@openai.com>
Clearing the merge block now that #2539 has merged.
Represent Orchard encrypted note plaintext as either ciphertext or stripped memo plaintext in the logical PCZT model, and resolve compact fields before Orchard role parsing.
We plan for more compact fields to get resolved like this before Orchard role parsing. So what I did was add a mutative "resolve_fields" function, for resolving fields that have been redacted, but are needed for Orchard calls.
We add a function in redactor to swap all Orchard ciphertexts with memo's, for all memo's that are decryptable via the action struct.
This saves us ~570 bytes/action in serialization to Keystone's, which is very significant. It halves the size relative to the state after making Anchor optional. This reduces ~4 QR frames per action, and were talking about 90-150 action flows.