Bitcoin Core 32.99.0
P2P Digital Currency
Loading...
Searching...
No Matches
ellswift.cpp
Go to the documentation of this file.
1// Copyright (c) 2022-present 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#include <util/check.h>
12
13#include <algorithm>
14#include <span>
15
17{
19
20 CKey key = GenerateRandomKey();
22
23 bench.batch(1).unit("pubkey").run([&] {
25 /* Use the first 32 bytes of the ellswift encoded public key as next private key. */
26 key.Set(ret.data(), ret.data() + 32, true);
27 assert(key.IsValid());
28 /* Use the last 32 bytes of the ellswift encoded public key as next entropy. */
29 std::copy(ret.begin() + 32, ret.begin() + 64, MakeWritableByteSpan(entropy).begin());
30 });
31}
32
#define BENCHMARK(n)
Definition bench.h:69
int ret
ECC_Context ecc_context
An encapsulated private key.
Definition key.h:46
bool IsValid() const
Check whether this private key is valid.
Definition key.h:134
EllSwiftPubKey EllSwiftCreate(std::span< const std::byte > entropy) const
Create an ellswift-encoded public key for this key, with specified entropy.
Definition key.cpp:313
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
Definition key.h:114
RAII class initializing and deinitializing global state for elliptic curve support.
Definition key.h:364
Main entry point to nanobench's benchmarking facility.
Definition nanobench.h:649
256-bit opaque blob.
Definition uint256.h:196
static void EllSwiftCreate(benchmark::Bench &bench)
Definition ellswift.cpp:16
CKey GenerateRandomKey(bool compressed) noexcept
Definition key.cpp:354
uint256 GetRandHash() noexcept
Generate a random uint256.
Definition random.h:463
auto MakeByteSpan(const V &v) noexcept
Definition span.h:84
auto MakeWritableByteSpan(V &&v) noexcept
Definition span.h:89
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:82
assert(!tx.IsCoinBase())