Skip to content

Commit 34bf9dd

Browse files
committed
Fuzz tests for CPubKey<->EllSwift
1 parent 5072b2c commit 34bf9dd

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/test/fuzz/key.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
#include <script/signingprovider.h>
1717
#include <script/standard.h>
1818
#include <streams.h>
19+
#include <test/fuzz/FuzzedDataProvider.h>
1920
#include <test/fuzz/fuzz.h>
2021
#include <util/strencodings.h>
2122

23+
#include <array>
2224
#include <cassert>
2325
#include <cstdint>
2426
#include <numeric>
@@ -306,3 +308,21 @@ FUZZ_TARGET_INIT(key, initialize_key)
306308
}
307309
}
308310
}
311+
312+
FUZZ_TARGET_INIT(ellswift, initialize_key)
313+
{
314+
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
315+
auto pubkey_bytes = fuzzed_data_provider.ConsumeBytes<uint8_t>(CPubKey::COMPRESSED_SIZE);
316+
pubkey_bytes.resize(CPubKey::COMPRESSED_SIZE);
317+
CPubKey pubkey(pubkey_bytes.begin(), pubkey_bytes.end());
318+
319+
if (!pubkey.IsFullyValid()) {
320+
return;
321+
}
322+
323+
auto rnd32 = fuzzed_data_provider.ConsumeBytes<uint8_t>(32);
324+
rnd32.resize(32);
325+
std::array<uint8_t, 32> rnd32_array;
326+
std::copy(rnd32.begin(), rnd32.end(), rnd32_array.begin());
327+
auto ellswift_pubkey = pubkey.EllSwiftEncode(rnd32_array);
328+
}

0 commit comments

Comments
 (0)