feat: merge-train/fairies#21543
Merged
Merged
Conversation
Makes it possible to emit offchain messages by making the corresponding oracle available to utilities, and bubbling the relevant information all the way up to the wallet/aztecjs results. Closes F-427
## Problem `AES128::decrypt` in `aes128.nr` currently panics at 5 points when given malformed ciphertext or wrong-key data. During message discovery (`do_sync_state`), a panic in `decrypt` crashes the entire sync process rather than gracefully skipping the unprocessable log. Additionally, `do_sync_state` itself panics when it encounters empty logs, since it unconditionally indexes into the log without checking its length first. ### Panic points in `decrypt` 1. **Empty ciphertext** -- `ciphertext.get(0)` panics when the `BoundedVec` is empty. 2. **Short header plaintext** -- `header_plaintext.get(0)` / `.get(1)` panic when the AES decrypt oracle returns fewer than 2 bytes (e.g. wrong-key PKCS#7 stripping produces an empty result). 3. **Invalid ciphertext length** -- `BoundedVec::from_parts(ciphertext_with_padding, ciphertext_length)` panics when the 2-byte header decodes to a length exceeding `MESSAGE_PLAINTEXT_SIZE_IN_BYTES` (e.g. 65535 from corrupted data). 4. **Invalid plaintext length** -- `fields_from_bytes` asserts `bytes.len() % 32 == 0`, panicking when the decrypted body has a non-aligned length (e.g. 33 bytes). 5. **Field overflow** -- `fields_from_bytes` asserts each 32-byte chunk fits within the BN254 field modulus, panicking when decrypted bytes exceed it (e.g. `0xFF` repeated 32 times). ### Panic in `do_sync_state` `do_sync_state` processes every pending tagged log without validating its size. It would panic when `pending_tagged_log.log.get(0)` was called on empty logs ## Important for reviewers I recommend using "hide whitespace" config when reviewing file changes, since it would make the changes easier to understand Fixes F-356 Fixes F-191
Collaborator
Author
|
🤖 Auto-merge enabled after 4 hours of inactivity. This PR will be merged automatically once all checks pass. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
BEGIN_COMMIT_OVERRIDE
feat: support emitting messages from utilities (#21422)
fix: handle empty or malformed logs during message processing (#21192)
END_COMMIT_OVERRIDE