Bitcoin Core  25.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;
15  key.MakeNewKey(true);
17  uint256 entropy = GetRandHash();
19  bench.batch(1).unit("pubkey").run([&] {
20  auto ret = key.EllSwiftCreate(MakeByteSpan(entropy));
21  /* Use the first 32 bytes of the ellswift encoded public key as next private key. */
22  key.Set(UCharCast(, UCharCast( + 32, true);
23  assert(key.IsValid());
24  /* Use the last 32 bytes of the ellswift encoded public key as next entropy. */
25  std::copy(ret.begin() + 32, ret.begin() + 64, MakeWritableByteSpan(entropy).begin());
26  });
28  ECC_Stop();
29 }
int ret
Definition: key.cpp:428
Definition: key.cpp:445
An encapsulated private key.
Definition: key.h:33
bool IsValid() const
Check whether this private key is valid.
Definition: key.h:99
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
Definition: key.cpp:161
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
Definition: key.h:79
EllSwiftPubKey EllSwiftCreate(Span< const std::byte > entropy) const
Create an ellswift-encoded public key for this key, with specified entropy.
Definition: key.cpp:335
Main entry point to nanobench's benchmarking facility.
Definition: nanobench.h:623
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Definition: nanobench.h:1230
Bench & batch(T b) noexcept
Sets the batch size.
Definition: nanobench.h:1254
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)
Definition: bench.h:47
uint256 GetRandHash() noexcept
Definition: random.cpp:573
unsigned char * UCharCast(char *c)
Definition: span.h:270
Span< const std::byte > MakeByteSpan(V &&v) noexcept
Definition: span.h:259
Span< std::byte > MakeWritableByteSpan(V &&v) noexcept
Definition: span.h:264