An encapsulated private key.
More...
#include <key.h>
|
| | CKey () |
| | Construct an invalid private key. More...
|
| |
| | CKey (const CKey &secret) |
| | Copy constructor. This is necessary because of memlocking. More...
|
| |
| | ~CKey () |
| | Destructor (again necessary because of memlocking). More...
|
| |
| template<typename T > |
| void | Set (const T pbegin, const T pend, bool fCompressedIn) |
| | Initialize using begin and end iterators to byte data. More...
|
| |
| unsigned int | size () const |
| | Simple read-only vector-like interface. More...
|
| |
| const unsigned char * | begin () const |
| |
| const unsigned char * | end () const |
| |
| bool | IsValid () const |
| | Check whether this private key is valid. More...
|
| |
| bool | IsCompressed () const |
| | Check whether the public key corresponding to this private key is (to be) compressed. More...
|
| |
| bool | SetPrivKey (const CPrivKey &vchPrivKey, bool fCompressed) |
| | Initialize from a CPrivKey (serialized OpenSSL private key data). More...
|
| |
| void | MakeNewKey (bool fCompressed) |
| | Generate a new private key using a cryptographic PRNG. More...
|
| |
| uint256 | GetPrivKey_256 () |
| |
| CPrivKey | GetPrivKey () const |
| | Convert the private key to a CPrivKey (serialized OpenSSL private key data). More...
|
| |
| CPubKey | GetPubKey () const |
| | Compute the public key from a private key. More...
|
| |
| bool | Sign (const uint256 &hash, std::vector< unsigned char > &vchSig, uint32_t test_case=0) const |
| | Create a DER-serialized signature. More...
|
| |
| bool | SignCompact (const uint256 &hash, std::vector< unsigned char > &vchSig) const |
| | Create a compact signature (65 bytes), which allows reconstructing the used public key. More...
|
| |
| bool | Derive (CKey &keyChild, unsigned char ccChild[32], unsigned int nChild, const unsigned char cc[32]) const |
| | Derive BIP32 child key. More...
|
| |
| bool | VerifyPubKey (const CPubKey &vchPubKey) const |
| | Verify thoroughly whether a private key and a public key match. More...
|
| |
| bool | Load (CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck) |
| | Load private key and check that public key matches. More...
|
| |
|
| static bool | Check (const unsigned char *vch) |
| | Check whether the 32-byte array pointed to be vch is valid keydata. More...
|
| |
|
| bool | fValid |
| | Whether this private key is valid. More...
|
| |
| bool | fCompressed |
| | Whether the public key corresponding to this private key is (to be) compressed. More...
|
| |
| unsigned char | vch [32] |
| | The actual byte data. More...
|
| |
An encapsulated private key.
Definition at line 39 of file key.h.
◆ CKey() [1/2]
Construct an invalid private key.
Definition at line 57 of file key.h.
◆ CKey() [2/2]
| CKey::CKey |
( |
const CKey & |
secret | ) |
|
|
inline |
Copy constructor. This is necessary because of memlocking.
Definition at line 63 of file key.h.
◆ ~CKey()
Destructor (again necessary because of memlocking).
Definition at line 70 of file key.h.
◆ begin()
| const unsigned char* CKey::begin |
( |
| ) |
const |
|
inline |
◆ Check()
| bool CKey::Check |
( |
const unsigned char * |
vch | ) |
|
|
staticprivate |
Check whether the 32-byte array pointed to be vch is valid keydata.
Definition at line 35 of file key.cpp.
◆ CheckSignatureElement()
| static bool CKey::CheckSignatureElement |
( |
const unsigned char * |
vch, |
|
|
int |
len, |
|
|
bool |
half |
|
) |
| |
|
static |
Check whether an element of a signature (r or s) is valid.
◆ Derive()
| bool CKey::Derive |
( |
CKey & |
keyChild, |
|
|
unsigned char |
ccChild[32], |
|
|
unsigned int |
nChild, |
|
|
const unsigned char |
cc[32] |
|
) |
| const |
Derive BIP32 child key.
Definition at line 159 of file key.cpp.
◆ end()
| const unsigned char* CKey::end |
( |
| ) |
const |
|
inline |
◆ GetPrivKey()
Convert the private key to a CPrivKey (serialized OpenSSL private key data).
This is expensive.
Definition at line 66 of file key.cpp.
◆ GetPrivKey_256()
◆ GetPubKey()
Compute the public key from a private key.
This is expensive.
Definition at line 79 of file key.cpp.
◆ IsCompressed()
| bool CKey::IsCompressed |
( |
| ) |
const |
|
inline |
Check whether the public key corresponding to this private key is (to be) compressed.
Definition at line 107 of file key.h.
◆ IsValid()
| bool CKey::IsValid |
( |
| ) |
const |
|
inline |
Check whether this private key is valid.
Definition at line 104 of file key.h.
◆ Load()
| bool CKey::Load |
( |
CPrivKey & |
privkey, |
|
|
CPubKey & |
vchPubKey, |
|
|
bool |
fSkipCheck = false |
|
) |
| |
Load private key and check that public key matches.
Definition at line 146 of file key.cpp.
◆ MakeNewKey()
| void CKey::MakeNewKey |
( |
bool |
fCompressed | ) |
|
Generate a new private key using a cryptographic PRNG.
Definition at line 40 of file key.cpp.
◆ Set()
template<typename T >
| void CKey::Set |
( |
const T |
pbegin, |
|
|
const T |
pend, |
|
|
bool |
fCompressedIn |
|
) |
| |
|
inline |
Initialize using begin and end iterators to byte data.
Definition at line 83 of file key.h.
◆ SetPrivKey()
| bool CKey::SetPrivKey |
( |
const CPrivKey & |
vchPrivKey, |
|
|
bool |
fCompressed |
|
) |
| |
Initialize from a CPrivKey (serialized OpenSSL private key data).
Definition at line 49 of file key.cpp.
◆ Sign()
| bool CKey::Sign |
( |
const uint256 & |
hash, |
|
|
std::vector< unsigned char > & |
vchSig, |
|
|
uint32_t |
test_case = 0 |
|
) |
| const |
Create a DER-serialized signature.
The test_case parameter tweaks the deterministic nonce, and is only for testing. It should be zero for normal use.
Definition at line 91 of file key.cpp.
◆ SignCompact()
| bool CKey::SignCompact |
( |
const uint256 & |
hash, |
|
|
std::vector< unsigned char > & |
vchSig |
|
) |
| const |
Create a compact signature (65 bytes), which allows reconstructing the used public key.
The format is one header byte, followed by two times 32 bytes for the serialized r and s values. The header byte: 0x1B = first key with even y, 0x1C = first key with odd y, 0x1D = second key with even y, 0x1E = second key with odd y, add 0x04 for compressed keys.
Definition at line 126 of file key.cpp.
◆ size()
| unsigned int CKey::size |
( |
| ) |
const |
|
inline |
Simple read-only vector-like interface.
Definition at line 99 of file key.h.
◆ VerifyPubKey()
| bool CKey::VerifyPubKey |
( |
const CPubKey & |
vchPubKey | ) |
const |
Verify thoroughly whether a private key and a public key match.
This is done using a different mechanism than just regenerating it.
Definition at line 111 of file key.cpp.
◆ operator==
| bool operator== |
( |
const CKey & |
a, |
|
|
const CKey & |
b |
|
) |
| |
|
friend |
Definition at line 75 of file key.h.
◆ fCompressed
Whether the public key corresponding to this private key is (to be) compressed.
Definition at line 47 of file key.h.
◆ fValid
Whether this private key is valid.
We check for correctness when modifying the key data, so fValid should always correspond to the actual state.
Definition at line 44 of file key.h.
◆ vch
| unsigned char CKey::vch[32] |
|
private |
The actual byte data.
Definition at line 50 of file key.h.
The documentation for this class was generated from the following files: