From 0fa30fcd0c3326e071dc2b97ae3049554263e261 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Sun, 21 Jun 2026 12:19:35 -0500 Subject: [PATCH] backend: use unaligned PRG output for 32-bit value 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) Co-Authored-By: Codex --- emp-ag2pc/backend/triple_pool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emp-ag2pc/backend/triple_pool.h b/emp-ag2pc/backend/triple_pool.h index f9fc545..fa23f6e 100644 --- a/emp-ag2pc/backend/triple_pool.h +++ b/emp-ag2pc/backend/triple_pool.h @@ -399,7 +399,7 @@ class TriplePool { block S = RO("AG2PC RO", zero_block) .absorb(io->get_digest()).absorb(sib->get_digest()).squeeze_block(); uint32_t raw; - { PRG prg2(&S); prg2.random_data(&raw, sizeof(uint32_t)); } + { PRG prg2(&S); prg2.random_data_unaligned(&raw, sizeof(uint32_t)); } int r_k = (int)(raw % (uint32_t)L); bucket_one_layer(am, ak, sac_mac.data(), sac_key.data(), L, r_k); }