-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2021 The Bitcoin Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include <chainparams.h> | ||
#include <key.h> | ||
#include <util/bip324.h> | ||
#include <test/fuzz/fuzz.h> | ||
#include <test/fuzz/FuzzedDataProvider.h> | ||
|
||
void initialize_chainparams() | ||
{ | ||
SelectParams(CBaseChainParams::REGTEST); | ||
} | ||
|
||
FUZZ_TARGET_INIT(bip324, initialize_chainparams) | ||
{ | ||
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; | ||
|
||
ECDHSecret ecdh_secret; | ||
ecdh_secret.resize(ECDH_SECRET_SIZE); | ||
auto ecdh_secret_bytes = fuzzed_data_provider.ConsumeBytes<uint8_t>(ECDH_SECRET_SIZE); | ||
ecdh_secret_bytes.resize(ECDH_SECRET_SIZE); | ||
|
||
memcpy(ecdh_secret.data(), ecdh_secret_bytes.data(), ECDH_SECRET_SIZE); | ||
|
||
auto initiator_hdata_len = fuzzed_data_provider.ConsumeIntegralInRange(0, 4096); | ||
auto initiator_hdata = fuzzed_data_provider.ConsumeBytes<uint8_t>(initiator_hdata_len); | ||
|
||
auto responder_hdata_len = fuzzed_data_provider.ConsumeIntegralInRange(0, 4096); | ||
auto responder_hdata = fuzzed_data_provider.ConsumeBytes<uint8_t>(responder_hdata_len); | ||
|
||
BIP324Keys bip324_keys{std::move(ecdh_secret), initiator_hdata, responder_hdata}; | ||
} | ||
|