2021-11-03 10:08:51 -07:00
|
|
|
// Copyright (c) 2022-2023 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 <bench/bench.h>
|
|
|
|
|
|
|
|
#include <key.h>
|
|
|
|
#include <random.h>
|
|
|
|
|
|
|
|
static void EllSwiftCreate(benchmark::Bench& bench)
|
|
|
|
{
|
2024-05-07 08:54:19 -04:00
|
|
|
ECC_Context ecc_context{};
|
2021-11-03 10:08:51 -07:00
|
|
|
|
2023-09-12 03:35:40 +02:00
|
|
|
CKey key = GenerateRandomKey();
|
2021-11-03 10:08:51 -07:00
|
|
|
uint256 entropy = GetRandHash();
|
|
|
|
|
|
|
|
bench.batch(1).unit("pubkey").run([&] {
|
2023-06-26 12:12:20 -04:00
|
|
|
auto ret = key.EllSwiftCreate(MakeByteSpan(entropy));
|
2021-11-03 10:08:51 -07:00
|
|
|
/* Use the first 32 bytes of the ellswift encoded public key as next private key. */
|
2024-04-06 15:46:53 +01:00
|
|
|
key.Set(ret.data(), ret.data() + 32, true);
|
2021-11-03 10:08:51 -07:00
|
|
|
assert(key.IsValid());
|
|
|
|
/* Use the last 32 bytes of the ellswift encoded public key as next entropy. */
|
2023-06-26 12:12:20 -04:00
|
|
|
std::copy(ret.begin() + 32, ret.begin() + 64, MakeWritableByteSpan(entropy).begin());
|
2021-11-03 10:08:51 -07:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
BENCHMARK(EllSwiftCreate, benchmark::PriorityLevel::HIGH);
|