Skip to content

Commit

Permalink
Fuzz tests for CPubKey<->EllSwift
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv committed Sep 2, 2022
1 parent 1db9f78 commit 09ff1af
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test/fuzz/key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
#include <script/signingprovider.h>
#include <script/standard.h>
#include <streams.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <util/strencodings.h>

#include <array>
#include <cassert>
#include <cstdint>
#include <numeric>
Expand Down Expand Up @@ -304,3 +306,19 @@ FUZZ_TARGET_INIT(key, initialize_key)
}
}
}

FUZZ_TARGET_INIT(ellswift, initialize_key)
{
FuzzedDataProvider fdp{buffer.data(), buffer.size()};
auto key_bytes = fdp.ConsumeBytes<uint8_t>(32);
key_bytes.resize(32);
CKey key;
key.Set(key_bytes.begin(), key_bytes.end(), fdp.ConsumeBool());

auto rnd32 = fdp.ConsumeBytes<uint8_t>(32);
rnd32.resize(32);
std::array<uint8_t, 32> rnd32_array;
std::copy(rnd32.begin(), rnd32.end(), rnd32_array.begin());

(void)key.EllSwiftEncode(rnd32_array);
}

0 comments on commit 09ff1af

Please sign in to comment.