Bitcoin Core  26.99.0
P2P Digital Currency
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
5 #include <bench/bench.h>
7 #include <key.h>
8 #include <random.h>
10 static void EllSwiftCreate(benchmark::Bench& bench)
11 {
12  ECC_Start();
14  CKey key = GenerateRandomKey();
15  uint256 entropy = GetRandHash();
17  bench.batch(1).unit("pubkey").run([&] {
18  auto ret = key.EllSwiftCreate(MakeByteSpan(entropy));
19  /* Use the first 32 bytes of the ellswift encoded public key as next private key. */
20  key.Set(UCharCast(, UCharCast( + 32, true);
21  assert(key.IsValid());
22  /* Use the last 32 bytes of the ellswift encoded public key as next entropy. */
23  std::copy(ret.begin() + 32, ret.begin() + 64, MakeWritableByteSpan(entropy).begin());
24  });
26  ECC_Stop();
27 }
int ret
Definition: key.cpp:435
Definition: key.cpp:452
An encapsulated private key.
Definition: key.h:33
bool IsValid() const
Check whether this private key is valid.
Definition: key.h:119
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
Definition: key.h:99
EllSwiftPubKey EllSwiftCreate(Span< const std::byte > entropy) const
Create an ellswift-encoded public key for this key, with specified entropy.
Definition: key.cpp:336
Main entry point to nanobench's benchmarking facility.
Definition: nanobench.h:627
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition: nanobench.h:1234
Bench & batch(T b) noexcept
Sets the batch size.
Definition: nanobench.h:1258
Bench & unit(char const *unit)
Sets the operation unit.
256-bit opaque blob.
Definition: uint256.h:106
static void EllSwiftCreate(benchmark::Bench &bench)
Definition: ellswift.cpp:10
BENCHMARK(EllSwiftCreate, benchmark::PriorityLevel::HIGH)
CKey GenerateRandomKey(bool compressed) noexcept
Definition: key.cpp:372
Definition: bench.h:47
uint256 GetRandHash() noexcept
Definition: random.cpp:650
unsigned char * UCharCast(char *c)
Definition: span.h:288
Span< const std::byte > MakeByteSpan(V &&v) noexcept
Definition: span.h:277
Span< std::byte > MakeWritableByteSpan(V &&v) noexcept
Definition: span.h:282