Skip to content

Commit 0939af0

Browse files
committed
merge bitcoin#21185: Remove expensive and redundant muhash from crypto fuzz target
1 parent 08f9c11 commit 0939af0

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

src/test/fuzz/crypto.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include <crypto/hmac_sha256.h>
66
#include <crypto/hmac_sha512.h>
7-
#include <crypto/muhash.h>
87
#include <crypto/ripemd160.h>
98
#include <crypto/sha1.h>
109
#include <crypto/sha256.h>
@@ -40,7 +39,6 @@ FUZZ_TARGET(crypto)
4039
CSHA512 sha512;
4140
SHA3_256 sha3;
4241
CSipHasher sip_hasher{fuzzed_data_provider.ConsumeIntegral<uint64_t>(), fuzzed_data_provider.ConsumeIntegral<uint64_t>()};
43-
MuHash3072 muhash;
4442

4543
while (--limit_max_ops >= 0 && fuzzed_data_provider.ConsumeBool()) {
4644
CallOneOf(
@@ -67,12 +65,6 @@ FUZZ_TARGET(crypto)
6765
(void)Hash160(data);
6866
(void)Hash160(data.begin(), data.end());
6967
(void)sha512.Size();
70-
71-
if (fuzzed_data_provider.ConsumeBool()) {
72-
muhash *= MuHash3072(data);
73-
} else {
74-
muhash /= MuHash3072(data);
75-
}
7668
},
7769
[&] {
7870
(void)hash160.Reset();
@@ -82,7 +74,6 @@ FUZZ_TARGET(crypto)
8274
(void)sha256.Reset();
8375
(void)sha3.Reset();
8476
(void)sha512.Reset();
85-
muhash = MuHash3072();
8677
},
8778
[&] {
8879
CallOneOf(
@@ -126,10 +117,6 @@ FUZZ_TARGET(crypto)
126117
[&] {
127118
data.resize(SHA3_256::OUTPUT_SIZE);
128119
sha3.Finalize(data);
129-
},
130-
[&] {
131-
uint256 out;
132-
muhash.Finalize(out);
133120
});
134121
});
135122
}

src/test/fuzz/muhash.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ FUZZ_TARGET(muhash)
4141
muhash.Finalize(out2);
4242

4343
assert(out == out2);
44+
MuHash3072 muhash3;
45+
muhash3 *= muhash;
46+
uint256 out3;
47+
muhash3.Finalize(out3);
48+
assert(out == out3);
4449

4550
// Test that removing all added elements brings the object back to it's initial state
4651
muhash /= muhash;
@@ -50,4 +55,9 @@ FUZZ_TARGET(muhash)
5055
muhash2.Finalize(out2);
5156

5257
assert(out == out2);
58+
59+
muhash3.Remove(data);
60+
muhash3.Remove(data2);
61+
muhash3.Finalize(out3);
62+
assert(out == out3);
5363
}

0 commit comments

Comments
 (0)