Skip to content

Commit ffff84a

Browse files
author
MarcoFalke
committed
fuzz: Remove expensive and redundant muhash from crypto fuzz target
1 parent 8d6994f commit ffff84a

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>
@@ -36,7 +35,6 @@ FUZZ_TARGET(crypto)
3635
CSHA512 sha512;
3736
SHA3_256 sha3;
3837
CSipHasher sip_hasher{fuzzed_data_provider.ConsumeIntegral<uint64_t>(), fuzzed_data_provider.ConsumeIntegral<uint64_t>()};
39-
MuHash3072 muhash;
4038

4139
while (fuzzed_data_provider.ConsumeBool()) {
4240
CallOneOf(
@@ -63,12 +61,6 @@ FUZZ_TARGET(crypto)
6361
(void)Hash(data);
6462
(void)Hash160(data);
6563
(void)sha512.Size();
66-
67-
if (fuzzed_data_provider.ConsumeBool()) {
68-
muhash *= MuHash3072(data);
69-
} else {
70-
muhash /= MuHash3072(data);
71-
}
7264
},
7365
[&] {
7466
(void)hash160.Reset();
@@ -78,7 +70,6 @@ FUZZ_TARGET(crypto)
7870
(void)sha256.Reset();
7971
(void)sha3.Reset();
8072
(void)sha512.Reset();
81-
muhash = MuHash3072();
8273
},
8374
[&] {
8475
CallOneOf(
@@ -122,10 +113,6 @@ FUZZ_TARGET(crypto)
122113
[&] {
123114
data.resize(SHA3_256::OUTPUT_SIZE);
124115
sha3.Finalize(data);
125-
},
126-
[&] {
127-
uint256 out;
128-
muhash.Finalize(out);
129116
});
130117
});
131118
}

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)