![]() |
Dash Core
0.12.2.1
P2P Digital Currency
|
#include <key.h>
Public Member Functions | |
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... | |
CPrivKey | GetPrivKey () const |
CPubKey | GetPubKey () const |
bool | Sign (const uint256 &hash, std::vector< unsigned char > &vchSig, uint32_t test_case=0) const |
bool | SignCompact (const uint256 &hash, std::vector< unsigned char > &vchSig) const |
bool | Derive (CKey &keyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode &cc) const |
Derive BIP32 child key. More... | |
bool | VerifyPubKey (const CPubKey &vchPubKey) const |
bool | Load (CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck) |
Load private key and check that public key matches. More... | |
Static Public Member Functions | |
static bool | CheckSignatureElement (const unsigned char *vch, int len, bool half) |
Check whether an element of a signature (r or s) is valid. More... | |
Static Private Member Functions | |
static bool | Check (const unsigned char *vch) |
Check whether the 32-byte array pointed to be vch is valid keydata. More... | |
Private Attributes | |
bool | fValid |
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... | |
Friends | |
bool | operator== (const CKey &a, const CKey &b) |
|
inline |
|
inline |
|
inline |
Definition at line 96 of file key.h.
Referenced by Derive(), CExtKey::Encode(), GetPrivKey(), GetPubKey(), Load(), CBitcoinSecret::SetKey(), SetPrivKey(), Sign(), and SignCompact().
|
staticprivate |
Check whether the 32-byte array pointed to be vch is valid keydata.
Definition at line 122 of file key.cpp.
Referenced by MakeNewKey(), and Set().
|
static |
Check whether an element of a signature (r or s) is valid.
|
inline |
CPrivKey CKey::GetPrivKey | ( | ) | const |
Convert the private key to a CPrivKey (serialized OpenSSL private key data). This is expensive.
Definition at line 143 of file key.cpp.
Referenced by CWallet::AddKeyPubKey().
CPubKey CKey::GetPubKey | ( | ) | const |
Compute the public key from a private key. This is expensive.
Definition at line 156 of file key.cpp.
Referenced by Derive(), CExtKey::Derive(), CWallet::DeriveNewChildKey(), CWallet::GenerateNewKey(), CMessageSigner::GetKeysFromSecret(), CWallet::GetOutpointAndKeysFromOutput(), and CExtKey::Neuter().
|
inline |
Check whether the public key corresponding to this private key is (to be) compressed.
Definition at line 103 of file key.h.
Referenced by Derive(), and CBitcoinSecret::SetKey().
|
inline |
Check whether this private key is valid.
Definition at line 100 of file key.h.
Referenced by Derive(), and CBitcoinSecret::SetKey().
void CKey::MakeNewKey | ( | bool | fCompressed | ) |
Generate a new private key using a cryptographic PRNG.
Definition at line 126 of file key.cpp.
Referenced by CWallet::GenerateNewKey(), and masternode().
|
inline |
Initialize using begin and end iterators to byte data.
Definition at line 79 of file key.h.
Referenced by CExtKey::Decode(), CBitcoinSecret::GetKey(), and CExtKey::SetMaster().
bool CKey::SetPrivKey | ( | const CPrivKey & | vchPrivKey, |
bool | fCompressed | ||
) |
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.
Definition at line 169 of file key.cpp.
Referenced by VerifyPubKey().
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.
|
inline |
Simple read-only vector-like interface.
Definition at line 95 of file key.h.
Referenced by CExtKey::Encode(), end(), and CBitcoinSecret::SetKey().
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 184 of file key.cpp.
Referenced by CWallet::DeriveNewChildKey(), CWallet::GenerateNewKey(), and Load().
|
private |
Whether the public key corresponding to this private key is (to be) compressed.
Definition at line 43 of file key.h.
Referenced by Derive(), GetPrivKey(), GetPubKey(), IsCompressed(), Load(), MakeNewKey(), Set(), SetPrivKey(), SignCompact(), and VerifyPubKey().
|
private |
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 40 of file key.h.
Referenced by Derive(), GetPrivKey(), GetPubKey(), IsValid(), Load(), MakeNewKey(), Set(), SetPrivKey(), Sign(), SignCompact(), and size().
|
private |