Bitcoin Core
28.99.0
P2P Digital Currency
src
bench
ellswift.cpp
Go to the documentation of this file.
1
// Copyright (c) 2022-2023 The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <
bench/bench.h
>
6
#include <
key.h
>
7
#include <
pubkey.h
>
8
#include <random.h>
9
#include <
span.h
>
10
#include <
uint256.h
>
11
12
#include <algorithm>
13
#include <cassert>
14
15
static
void
EllSwiftCreate
(
benchmark::Bench
& bench)
16
{
17
ECC_Context
ecc_context
{};
18
19
CKey
key =
GenerateRandomKey
();
20
uint256
entropy =
GetRandHash
();
21
22
bench.
batch
(1).
unit
(
"pubkey"
).
run
([&] {
23
auto
ret
= key.
EllSwiftCreate
(
MakeByteSpan
(entropy));
24
/* Use the first 32 bytes of the ellswift encoded public key as next private key. */
25
key.
Set
(
ret
.data(),
ret
.data() + 32,
true
);
26
assert
(key.
IsValid
());
27
/* Use the last 32 bytes of the ellswift encoded public key as next entropy. */
28
std::copy(
ret
.begin() + 32,
ret
.begin() + 64,
MakeWritableByteSpan
(entropy).begin());
29
});
30
}
31
32
BENCHMARK
(
EllSwiftCreate
,
benchmark::PriorityLevel::HIGH
);
bench.h
ret
int ret
Definition:
bitcoin-cli.cpp:1354
ecc_context
ECC_Context ecc_context
Definition:
bitcoin-wallet.cpp:135
CKey
An encapsulated private key.
Definition:
key.h:35
CKey::IsValid
bool IsValid() const
Check whether this private key is valid.
Definition:
key.h:123
CKey::Set
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
Definition:
key.h:103
CKey::EllSwiftCreate
EllSwiftPubKey EllSwiftCreate(Span< const std::byte > entropy) const
Create an ellswift-encoded public key for this key, with specified entropy.
Definition:
key.cpp:311
ECC_Context
RAII class initializing and deinitializing global state for elliptic curve support.
Definition:
key.h:322
ankerl::nanobench::Bench
Main entry point to nanobench's benchmarking facility.
Definition:
nanobench.h:627
ankerl::nanobench::Bench::run
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition:
nanobench.h:1234
ankerl::nanobench::Bench::batch
Bench & batch(T b) noexcept
Sets the batch size.
Definition:
nanobench.h:1258
ankerl::nanobench::Bench::unit
Bench & unit(char const *unit)
Sets the operation unit.
uint256
256-bit opaque blob.
Definition:
uint256.h:190
EllSwiftCreate
static void EllSwiftCreate(benchmark::Bench &bench)
Definition:
ellswift.cpp:15
BENCHMARK
BENCHMARK(EllSwiftCreate, benchmark::PriorityLevel::HIGH)
GenerateRandomKey
CKey GenerateRandomKey(bool compressed) noexcept
Definition:
key.cpp:352
key.h
benchmark::HIGH
@ HIGH
Definition:
bench.h:48
pubkey.h
GetRandHash
uint256 GetRandHash() noexcept
Generate a random uint256.
Definition:
random.h:454
span.h
MakeByteSpan
Span< const std::byte > MakeByteSpan(V &&v) noexcept
Definition:
span.h:270
MakeWritableByteSpan
Span< std::byte > MakeWritableByteSpan(V &&v) noexcept
Definition:
span.h:275
uint256.h
assert
assert(!tx.IsCoinBase())
Generated on Wed Dec 18 2024 20:00:09 for Bitcoin Core by
1.9.4