backend: use unaligned PRG output for 32-bit bucket coin#41
Merged
Conversation
layered_bucket_into_acc draws the per-layer cyclic-shift coin into a stack uint32_t. PRG::random_data requires its destination to be 16-byte aligned, but a uint32_t object is not guaranteed to satisfy that alignment, and Debug builds abort on emp-tool's alignment assert. Use PRG::random_data_unaligned for this 4-byte draw. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-Authored-By: Codex <codex@openai.com>
Member
|
Thanks! |
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.
Summary
This fixes a Debug-build abort in
TriplePool::layered_bucket_into_accby usingPRG::random_data_unalignedfor the per-layer cyclic-shift coin draw.The code draws four bytes into a stack
uint32_t raw.PRG::random_datarequires its destination pointer to be 16-byte aligned, but auint32_tobject is not guaranteed to satisfy that alignment. Debug builds hit emp-tool's alignment assert and abort.The fix changes this 4-byte draw from
random_datatorandom_data_unaligned, which is the API intended for destinations without 16-byte alignment.Details
layered_bucket_into_accderives a public per-layer cyclic-shift coin by hashing the channel digests into a seed block, initializing a localPRG, and drawing auint32_tused asraw % L.Before:
After:
This preserves the protocol behavior while removing the invalid alignment assumption. Release builds may not abort because the check is an assert, but the old call still violated the
PRG::random_dataprecondition.Reproduction
The failure reproduces on the parent commit with a Debug build:
The fixed commit passes the same test under the same build configuration.
Validation
The fixed commit passes these Debug tests:
Crash log from the parent commit
Backtrace from the parent commit