File tree 1 file changed +28
-0
lines changed
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 16
16
#include < script/signingprovider.h>
17
17
#include < script/standard.h>
18
18
#include < streams.h>
19
+ #include < test/fuzz/FuzzedDataProvider.h>
19
20
#include < test/fuzz/fuzz.h>
20
21
#include < util/strencodings.h>
21
22
23
+ #include < array>
22
24
#include < cassert>
23
25
#include < cstdint>
24
26
#include < numeric>
@@ -306,3 +308,29 @@ FUZZ_TARGET_INIT(key, initialize_key)
306
308
}
307
309
}
308
310
}
311
+
312
+ FUZZ_TARGET_INIT (ellsq, 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 ellsq_pubkey = pubkey.EllSqEncode (rnd32_array);
328
+
329
+ assert (ellsq_pubkey.has_value ());
330
+ assert (ellsq_pubkey->size () == ELLSQ_ENCODED_SIZE);
331
+
332
+ CPubKey decoded_pubkey{ellsq_pubkey.value ()};
333
+ assert (decoded_pubkey.IsFullyValid ());
334
+
335
+ assert (pubkey == decoded_pubkey);
336
+ }
You can’t perform that action at this time.
0 commit comments