Bitcoin Core 28.99.0
P2P Digital Currency
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
KeyPair Class Reference

KeyPair. More...

#include <key.h>

Public Member Functions

 KeyPair () noexcept=default
 
 KeyPair (KeyPair &&) noexcept=default
 
KeyPairoperator= (KeyPair &&) noexcept=default
 
KeyPairoperator= (const KeyPair &other)
 
 KeyPair (const KeyPair &other)
 
bool SignSchnorr (const uint256 &hash, Span< unsigned char > sig, const uint256 &aux) const
 
bool IsValid () const
 Check whether this keypair is valid. More...
 

Private Types

using KeyType = std::array< unsigned char, 96 >
 

Private Member Functions

 KeyPair (const CKey &key, const uint256 *merkle_root)
 
void MakeKeyPairData ()
 
void ClearKeyPairData ()
 

Private Attributes

secure_unique_ptr< KeyTypem_keypair
 

Friends

KeyPair CKey::ComputeKeyPair (const uint256 *merkle_root) const
 

Detailed Description

KeyPair.

Wraps a secp256k1_keypair type, an opaque data structure for holding a secret and public key. This is intended for BIP340 keys and allows us to easily determine if the secret key needs to be negated by checking the parity of the public key. This class primarily intended for passing secret keys to libsecp256k1 functions expecting a secp256k1_keypair. For all other cases, CKey should be preferred.

A KeyPair can be created from a CKey with an optional merkle_root tweak (per BIP342). See CKey::ComputeKeyPair for more details.

Definition at line 267 of file key.h.

Member Typedef Documentation

◆ KeyType

using KeyPair::KeyType = std::array<unsigned char, 96>
private

Definition at line 297 of file key.h.

Constructor & Destructor Documentation

◆ KeyPair() [1/4]

KeyPair::KeyPair ( )
defaultnoexcept

◆ KeyPair() [2/4]

KeyPair::KeyPair ( KeyPair &&  )
defaultnoexcept

◆ KeyPair() [3/4]

KeyPair::KeyPair ( const KeyPair other)
inline

Definition at line 286 of file key.h.

◆ KeyPair() [4/4]

KeyPair::KeyPair ( const CKey key,
const uint256 merkle_root 
)
private

Definition at line 409 of file key.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ ClearKeyPairData()

void KeyPair::ClearKeyPairData ( )
inlineprivate

Definition at line 305 of file key.h.

Here is the caller graph for this function:

◆ IsValid()

bool KeyPair::IsValid ( ) const
inline

Check whether this keypair is valid.

Definition at line 292 of file key.h.

Here is the caller graph for this function:

◆ MakeKeyPairData()

void KeyPair::MakeKeyPairData ( )
inlineprivate

Definition at line 300 of file key.h.

Here is the caller graph for this function:

◆ operator=() [1/2]

KeyPair & KeyPair::operator= ( const KeyPair other)
inline

Definition at line 273 of file key.h.

Here is the call graph for this function:

◆ operator=() [2/2]

KeyPair & KeyPair::operator= ( KeyPair &&  )
defaultnoexcept

◆ SignSchnorr()

bool KeyPair::SignSchnorr ( const uint256 hash,
Span< unsigned char >  sig,
const uint256 aux 
) const

Definition at line 426 of file key.cpp.

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

Friends And Related Function Documentation

◆ CKey::ComputeKeyPair

KeyPair CKey::ComputeKeyPair ( const uint256 merkle_root) const
friend

Member Data Documentation

◆ m_keypair

secure_unique_ptr<KeyType> KeyPair::m_keypair
private

Definition at line 298 of file key.h.


The documentation for this class was generated from the following files: