Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2020-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#include <chainparams.h>6#include <common/signmessage.h>7#include <key_io.h>8#include <test/fuzz/FuzzedDataProvider.h>9#include <test/fuzz/fuzz.h>10#include <test/fuzz/util.h>11#include <util/chaintype.h>12#include <util/strencodings.h>14#include <cassert>15#include <cstdint>16#include <iostream>17#include <string>18#include <vector>20void initialize_message()21{22static ECC_Context ecc_context{};23SelectParams(ChainType::REGTEST);24}26FUZZ_TARGET(message, .init = initialize_message)27{28FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());29const std::string random_message = fuzzed_data_provider.ConsumeRandomLengthString(1024);30{31CKey private_key = ConsumePrivateKey(fuzzed_data_provider);32std::string signature;33const bool message_signed = MessageSign(private_key, random_message, signature);34if (private_key.IsValid()) {35assert(message_signed);36const MessageVerificationResult verification_result = MessageVerify(EncodeDestination(PKHash(private_key.GetPubKey().GetID())), signature, random_message);37assert(verification_result == MessageVerificationResult::OK);38}39}40{41(void)MessageHash(random_message);42auto address = fuzzed_data_provider.ConsumeRandomLengthString(1024);43auto signature = fuzzed_data_provider.ConsumeRandomLengthString(1024);44(void)MessageVerify(address, signature, random_message);45(void)SigningResultString(fuzzed_data_provider.PickValueInArray({SigningResult::OK, SigningResult::PRIVATE_KEY_NOT_AVAILABLE, SigningResult::SIGNING_FAILED}));46}47}
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.