You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: make Hash duplex sponge portable across pointer widths
`Hash<D>::squeeze` and `squeeze_end` fold the squeeze block-counter and the
read-length into the hash state via `usize::to_be_bytes()`. `usize` is 8 bytes
on 64-bit targets and 4 bytes on 32-bit (e.g. wasm32), so the absorbed bytes —
and therefore the squeezed output — differ by target. A 64-bit prover and a
32-bit verifier then derive different Fiat-Shamir challenges, breaking
verification (this surfaced verifying a 64-bit-produced transcript inside a
wasm32 verifier).
Encode both counters as fixed-width `u64`. On 64-bit this is byte-identical to
the previous output (`i as u64 == i`), so existing transcripts/vectors are
unchanged; only 32-bit output changes, now matching 64-bit. The permutation
`DuplexSponge` is unaffected — its `usize` fields are buffer indices, never
absorbed.
Add a multi-block squeeze known-answer test (counter increments past 0, plus a
squeeze_end) that pins the output; running it on both a 64-bit and a 32-bit
target guards the portability property.
0 commit comments