MCPcopy Create free account
hub / github.com/ElementsProject/elements / FUZZ_TARGET_INIT

Function FUZZ_TARGET_INIT

src/test/fuzz/key.cpp:35–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35FUZZ_TARGET_INIT(key, initialize_key)
36{
37 const CKey key = [&] {
38 CKey k;
39 k.Set(buffer.begin(), buffer.end(), true);
40 return k;
41 }();
42 if (!key.IsValid()) {
43 return;
44 }
45
46 {
47 assert(key.begin() + key.size() == key.end());
48 assert(key.IsCompressed());
49 assert(key.size() == 32);
50 assert(DecodeSecret(EncodeSecret(key)) == key);
51 }
52
53 {
54 CKey invalid_key;
55 assert(!(invalid_key == key));
56 assert(!invalid_key.IsCompressed());
57 assert(!invalid_key.IsValid());
58 assert(invalid_key.size() == 0);
59 }
60
61 {
62 CKey uncompressed_key;
63 uncompressed_key.Set(buffer.begin(), buffer.end(), false);
64 assert(!(uncompressed_key == key));
65 assert(!uncompressed_key.IsCompressed());
66 assert(key.size() == 32);
67 assert(uncompressed_key.begin() + uncompressed_key.size() == uncompressed_key.end());
68 assert(uncompressed_key.IsValid());
69 }
70
71 {
72 CKey copied_key;
73 copied_key.Set(key.begin(), key.end(), key.IsCompressed());
74 assert(copied_key == key);
75 }
76
77 {
78 CKey negated_key = key;
79 negated_key.Negate();
80 assert(negated_key.IsValid());
81 assert(!(negated_key == key));
82
83 negated_key.Negate();
84 assert(negated_key == key);
85 }
86
87 const uint256 random_uint256 = Hash(buffer);
88
89 {
90 CKey child_key;
91 ChainCode child_chaincode;
92 const bool ok = key.Derive(child_key, child_chaincode, 0, random_uint256);

Callers

nothing calls this directly

Calls 15

DecodeSecretFunction · 0.85
EncodeSecretFunction · 0.85
HexToPubKeyFunction · 0.85
GetAllDestinationsForKeyFunction · 0.85
GetScriptForRawPubKeyFunction · 0.85
GetScriptForMultisigFunction · 0.85
IsSolvableFunction · 0.85
IsSegWitOutputFunction · 0.85
IsStandardFunction · 0.85
SolverFunction · 0.85
GetDestinationForKeyFunction · 0.85
IsValidDestinationFunction · 0.85

Tested by

no test coverage detected