Skip to content

Commit 1e7eda9

Browse files
committed
Fuzz tests for CPubKey<->EllSwift
1 parent b497cca commit 1e7eda9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/test/fuzz/key.cpp

+18
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,19 @@ FUZZ_TARGET_INIT(key, initialize_key)
306308
}
307309
}
308310
}
311+
312+
FUZZ_TARGET_INIT(ellswift, initialize_key)
313+
{
314+
FuzzedDataProvider fdp{buffer.data(), buffer.size()};
315+
auto key_bytes = fdp.ConsumeBytes<uint8_t>(32);
316+
key_bytes.resize(32);
317+
CKey key;
318+
key.Set(key_bytes.begin(), key_bytes.end(), fdp.ConsumeBool());
319+
320+
auto rnd32 = fdp.ConsumeBytes<uint8_t>(32);
321+
rnd32.resize(32);
322+
std::array<uint8_t, 32> rnd32_array;
323+
std::copy(rnd32.begin(), rnd32.end(), rnd32_array.begin());
324+
325+
(void)key.EllSwiftEncode(rnd32_array);
326+
}

0 commit comments

Comments
 (0)