1717#include < streams.h>
1818#include < test/fuzz/FuzzedDataProvider.h>
1919#include < test/fuzz/fuzz.h>
20+ #include < test/fuzz/util.h>
2021#include < util/chaintype.h>
2122#include < util/strencodings.h>
2223
@@ -312,10 +313,7 @@ FUZZ_TARGET(ellswift_roundtrip, .init = initialize_key)
312313{
313314 FuzzedDataProvider fdp{buffer.data (), buffer.size ()};
314315
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 (), true );
316+ CKey key = ConsumePrivateKey (fdp, /* compressed=*/ true );
319317 if (!key.IsValid ()) return ;
320318
321319 auto ent32 = fdp.ConsumeBytes <std::byte>(32 );
@@ -332,17 +330,11 @@ FUZZ_TARGET(bip324_ecdh, .init = initialize_key)
332330 FuzzedDataProvider fdp{buffer.data (), buffer.size ()};
333331
334332 // We generate private key, k1.
335- auto rnd32 = fdp.ConsumeBytes <uint8_t >(32 );
336- rnd32.resize (32 );
337- CKey k1;
338- k1.Set (rnd32.begin (), rnd32.end (), true );
333+ CKey k1 = ConsumePrivateKey (fdp, /* compressed=*/ true );
339334 if (!k1.IsValid ()) return ;
340335
341336 // They generate private key, k2.
342- rnd32 = fdp.ConsumeBytes <uint8_t >(32 );
343- rnd32.resize (32 );
344- CKey k2;
345- k2.Set (rnd32.begin (), rnd32.end (), true );
337+ CKey k2 = ConsumePrivateKey (fdp, /* compressed=*/ true );
346338 if (!k2.IsValid ()) return ;
347339
348340 // We construct an ellswift encoding for our key, k1_ellswift.
0 commit comments