#36286 crypto: Fix MuHash3072 division by itself
https://github.com/bitcoin/bitcoin/pull/36286 · · +9/-1 in 3 files, 1 commits · labels: Utils/log/libs
Goal
- Fix calculation bugs when dividing a MuHash3072 object by itself
- Ensures mathematical correctness in cryptographic utility operations
Fixes an aliasing bug in `MuHash3072::operator/=` when an object divides itself. Copies the divisor's numerator before modifying `m_numerator`, and updates unit and fuzz tests to exercise self-division when the denominator is not 1.
Problem: When executing `x /= x`, `operator/=` mutates `m_numerator` during step one and then reads the mutated value during step two, yielding an incorrect result when the denominator is not 1. No production node code currently divides a MuHash object by itself, but the mathematical operation is incorrect.
Category: Utilities (logging, arguments, libraries) (#35 of 66)
P3 · bug fix
- P3 because it fixes a latent calculation bug in a cryptographic primitive
- No production code currently performs self-division, leaving active nodes unaffected
P3 because it fixes a latent calculation bug in a cryptographic primitive without active production impact. Author fjahr notes: 'No code in the node/index divides MuHash objects by themselves, so runnings nodes are not affected.'
Membership: Changes cryptographic primitive code in src/crypto/muhash.cpp
Factors: security/stability 1, bug 1, performance 0, user value 0, leverage 1
Reviewability: Ready
- Ready to review
- The change is tiny, CI passes, and no changes are pending
The change is tiny, CI passes, and no changes are pending.
Author status: active
Agreement: Crickets
- No reviews or discussion yet
- PR was recently opened and has received no feedback so far
No discussion or reviews yet
PR was just opened and has received no reviews or comments.
Review verdicts (DrahtBot): 0
Files
7 lines under test/bench/ci.
- src/test/crypto_tests.cpp +6/-0
- src/crypto/muhash.cpp +2/-1
- src/test/fuzz/muhash.cpp +1/-0
Card
Fixes an aliasing bug in MuHash3072::operator/= when an object divides itself. Previously, modifying the numerator in the first step corrupted the subsequent denominator multiplication, causing x /= x to fail unless the denominator was 1. The author notes that no node or index code currently divides MuHash objects by themselves, so existing node operation is not affected. The PR is a minimal 9-line diff with unit and fuzz tests, and has not yet received review.