AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 62 Bitcoin

hashes: Fix sha3_256 incremental hashing

Public commit record

What the developer wrote

Authored by Liam Aharon

78/100 · Adequate
hashes: Fix sha3_256 incremental hashing

The previous implementation incorrectly applies padding at the end of
every `input()` call, treating each data chunk as a standalone message.
This resulted in hashing `Pad(a) || Pad(b)` instead of `Pad(a || b)`.

Refactor `HashEngine`'s `input()` to buffer partial blocks instead of
padding and absorbing them immediately.

Move padding logic into `finalize()` so it is applied exactly once at
the end of the stream.

Add a regression test for incremental input.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes a bug in the SHA3-256 hashing code in rust-bitcoin. Previously, when data was fed in chunks (rather than all at once), the code incorrectly added end-of-message padding after every chunk. That produced the wrong hash for any multi-chunk input. The fix buffers partial blocks and only applies padding once at the end. The commit adds a regression test that hashes byte-by-byte and compares the result to the known correct output.

Recommended action

Upgrade to the fixed version. If you used SHA3-256 in rust-bitcoin to hash data supplied in multiple input() calls, recompute and compare those hashes against a correct implementation; any multi-chunk hashes produced before this fix are incorrect and should not be trusted for integrity checks, signatures, or consensus.

Security signals we found

01

Incorrect cryptographic output for incremental hashing

02

Padding applied per input() call instead of once at finalization

03

Domain-separation padding moved to finalize()

04

Regression test added for byte-by-byte incremental hashing

Risk score

Why this scored 62/100

Our methodology →
Potential impact 18/30
Exploitability 12/25
Stealth signal 10/15
Affected reach 10/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.