Bitcoin Core 31.99.0
P2P Digital Currency
Classes | Typedefs | Functions | Variables
key.h File Reference
#include <pubkey.h>
#include <script/keyorigin.h>
#include <serialize.h>
#include <support/allocators/secure.h>
#include <uint256.h>
#include <optional>
#include <stdexcept>
#include <utility>
#include <vector>
Include dependency graph for key.h:

Go to the source code of this file.

Classes

class  CKey
 An encapsulated private key. More...
 
struct  CExtKey
 
class  KeyPair
 KeyPair. More...
 
class  ECC_Context
 RAII class initializing and deinitializing global state for elliptic curve support. More...
 

Typedefs

typedef struct secp256k1_context_struct secp256k1_context
 
typedef std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
 CPrivKey is a serialized private key, with all parameters included (SIZE bytes) More...
 
using ECDHSecret = std::array< std::byte, ECDH_SECRET_SIZE >
 

Functions

CKey GenerateRandomKey (bool compressed=true) noexcept
 
std::optional< std::pair< CExtKey, KeyOriginInfo > > DeriveExtKey (const CExtKey &ext_key, const std::vector< uint32_t > &path)
 Get extended key and origin info for a given path. More...
 
bool ECC_InitSanityCheck ()
 Check that required EC support is available at runtime. More...
 
secp256k1_contextGetSecp256k1SignContext ()
 Access the secp256k1 context used for signing and MuSig2 nonce generation. More...
 

Variables

constexpr size_t ECDH_SECRET_SIZE = CSHA256::OUTPUT_SIZE
 Size of ECDH shared secrets. More...
 

Typedef Documentation

◆ CPrivKey

typedef std::vector<unsigned char, secure_allocator<unsigned char> > CPrivKey

CPrivKey is a serialized private key, with all parameters included (SIZE bytes)

Definition at line 28 of file key.h.

◆ ECDHSecret

using ECDHSecret = std::array<std::byte, ECDH_SECRET_SIZE>

Definition at line 34 of file key.h.

◆ secp256k1_context

Definition at line 22 of file key.h.

Function Documentation

◆ DeriveExtKey()

std::optional< std::pair< CExtKey, KeyOriginInfo > > DeriveExtKey ( const CExtKey ext_key,
const std::vector< uint32_t > &  path 
)

Get extended key and origin info for a given path.

Parameters
[in]ext_keyThe extended private key to derive from
[in]pathThe BIP 32 path
Returns
the resulting extended private key and origin info

Definition at line 369 of file key.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ECC_InitSanityCheck()

bool ECC_InitSanityCheck ( )

Check that required EC support is available at runtime.

Definition at line 456 of file key.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateRandomKey()

CKey GenerateRandomKey ( bool  compressed = true)
noexcept

Definition at line 354 of file key.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSecp256k1SignContext()

secp256k1_context * GetSecp256k1SignContext ( )

Access the secp256k1 context used for signing and MuSig2 nonce generation.

Definition at line 462 of file key.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ ECDH_SECRET_SIZE

constexpr size_t ECDH_SECRET_SIZE = CSHA256::OUTPUT_SIZE
inlineconstexpr

Size of ECDH shared secrets.

Definition at line 31 of file key.h.