OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
keys.cpp
Go to the documentation of this file.
1// Copyright (c) 2021 MIT Digital Currency Initiative,
2// Federal Reserve Bank of Boston
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#include "keys.hpp"
7
8#include <cassert>
9#include <secp256k1_schnorrsig.h>
10
11namespace cbdc {
13 -> pubkey_t {
14 secp256k1_keypair keypair{};
15 [[maybe_unused]] const auto create_ret
16 = ::secp256k1_keypair_create(ctx, &keypair, privkey.data());
17 assert(create_ret == 1);
18
19 secp256k1_xonly_pubkey xpub{};
20 [[maybe_unused]] const auto xonly_ret
21 = ::secp256k1_keypair_xonly_pub(ctx, &xpub, nullptr, &keypair);
22 assert(xonly_ret == 1);
23
24 pubkey_t pubkey;
25 [[maybe_unused]] const auto ser_ret
26 = ::secp256k1_xonly_pubkey_serialize(ctx, pubkey.data(), &xpub);
27 assert(ser_ret == 1);
28 return pubkey;
29 }
30}
struct secp256k1_context_struct secp256k1_context
Definition keys.hpp:14
std::array< unsigned char, pubkey_len > privkey_t
A private key of a public/private keypair.
Definition keys.hpp:23
auto pubkey_from_privkey(const privkey_t &privkey, secp256k1_context *ctx) -> pubkey_t
Generates a public key from the specified private key.
Definition keys.cpp:12
std::array< unsigned char, pubkey_len > pubkey_t
A public key of a public/private keypair.
Definition keys.hpp:25