Skip to content

feat: merge-train/fairies#21543

Merged
AztecBot merged 3 commits into
nextfrom
merge-train/fairies
Mar 13, 2026
Merged

feat: merge-train/fairies#21543
AztecBot merged 3 commits into
nextfrom
merge-train/fairies

Conversation

@AztecBot

@AztecBot AztecBot commented Mar 13, 2026

Copy link
Copy Markdown
Collaborator

BEGIN_COMMIT_OVERRIDE
feat: support emitting messages from utilities (#21422)
fix: handle empty or malformed logs during message processing (#21192)
END_COMMIT_OVERRIDE

mverzilli and others added 2 commits March 13, 2026 17:49
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

@ludamad ludamad left a comment

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.

🤖 Auto-approved

@AztecBot AztecBot added this pull request to the merge queue Mar 13, 2026
@AztecBot

Copy link
Copy Markdown
Collaborator Author

🤖 Auto-merge enabled after 4 hours of inactivity. This PR will be merged automatically once all checks pass.

Merged via the queue into next with commit 10aa50f Mar 13, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants