Fuzz test for CKey->EllSwift->CPubKey creation/decoding
Co-authored-by: Pieter Wuille <bitcoin-dev@wuille.net>
This commit is contained in:
1 parent
aae432a764
commit
c3ac9f5cf4
1 file changed
+21
@@ -15,10 +15,12 @@
|
|||||||
#include <script/signingprovider.h>
|
#include <script/signingprovider.h>
|
||||||
#include <script/standard.h>
|
#include <script/standard.h>
|
||||||
#include <streams.h>
|
#include <streams.h>
|
||||||
|
#include <test/fuzz/FuzzedDataProvider.h>
|
||||||
#include <test/fuzz/fuzz.h>
|
#include <test/fuzz/fuzz.h>
|
||||||
#include <util/chaintype.h>
|
#include <util/chaintype.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
@@ -303,3 +305,22 @@ FUZZ_TARGET_INIT(key, initialize_key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FUZZ_TARGET_INIT(ellswift_roundtrip, 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(), true);
|
||||||
|
if (!key.IsValid()) return;
|
||||||
|
|
||||||
|
auto ent32 = fdp.ConsumeBytes<std::byte>(32);
|
||||||
|
ent32.resize(32);
|
||||||
|
|
||||||
|
auto encoded_ellswift = key.EllSwiftCreate(ent32);
|
||||||
|
auto decoded_pubkey = encoded_ellswift.Decode();
|
||||||
|
|
||||||
|
assert(key.VerifyPubKey(decoded_pubkey));
|
||||||
|
}
|
||||||
Reference in new issue
Block a user