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

Function FUZZ_TARGET_INIT

src/test/fuzz/message.cpp:26–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26FUZZ_TARGET_INIT(message, initialize_message)
27{
28 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
29 const std::string random_message = fuzzed_data_provider.ConsumeRandomLengthString(1024);
30 {
31 const std::vector<uint8_t> random_bytes = ConsumeRandomLengthByteVector(fuzzed_data_provider);
32 CKey private_key;
33 private_key.Set(random_bytes.begin(), random_bytes.end(), fuzzed_data_provider.ConsumeBool());
34 std::string signature;
35 const bool message_signed = MessageSign(private_key, random_message, signature);
36 if (private_key.IsValid()) {
37 assert(message_signed);
38 const MessageVerificationResult verification_result = MessageVerify(EncodeDestination(PKHash(private_key.GetPubKey().GetID())), signature, random_message);
39 assert(verification_result == MessageVerificationResult::OK);
40 }
41 }
42 {
43 (void)MessageHash(random_message);
44 (void)MessageVerify(fuzzed_data_provider.ConsumeRandomLengthString(1024), fuzzed_data_provider.ConsumeRandomLengthString(1024), random_message);
45 (void)SigningResultString(fuzzed_data_provider.PickValueInArray({SigningResult::OK, SigningResult::PRIVATE_KEY_NOT_AVAILABLE, SigningResult::SIGNING_FAILED}));
46 }
47}

Callers

nothing calls this directly

Calls 15

MessageSignFunction · 0.85
MessageVerifyFunction · 0.85
EncodeDestinationFunction · 0.85
PKHashClass · 0.85
MessageHashFunction · 0.85
SigningResultStringFunction · 0.85
ConsumeBoolMethod · 0.80
PickValueInArrayMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected