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

benches: fix hash benches to measure full hash

Public commit record

What the developer wrote

Authored by jrakibi

76/100 · Adequate
benches: fix hash benches to measure full hash

The current hash benchmarks create the engine once and then repeatedly call
`engine.input()` on the same engine. This does not measure a full hash
operation per iteration (create engine -> `input()` -> `finalize()`).

The previous benchmark numbers are optimistic, especially for small
inputs, and does not reflect real cost of hashing.

I ran a before/after comparison for sha256:
On master:
- 10 bytes: 9.5514 ns
- 1024 bytes: 532.90 ns
- 65536 bytes: 34.533 us
This PR:
- 10 bytes: 51.360 ns
- 1024 bytes: 553.34 ns
- 65536 bytes: 33.796 us

On small inputs the old benchmark was around 5x too optimistic.
(for larger inputs the difference is small)

Discussed in https://github.com/rust-bitcoin/rust-bitcoin/pull/5604#issuecomment-3866577775
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This change only fixes how hash performance is measured in benchmark tests. It does not change any real hashing code that users or applications rely on, so it has no security impact on the library itself.

Recommended action

No security action needed; this is a benchmark-only correctness improvement.

Security signals we found

No strong security signals were identified.

Risk score

Why this scored 15/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 0/15
Confidence 10/10
Evidence quality 5/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.