Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
An encapsulated public key. More...
#include <pubkey.h>
Public Member Functions | |
CPubKey () | |
Construct an invalid public key. More... | |
template<typename T > | |
void | Set (const T pbegin, const T pend) |
Initialize a public key using begin/end iterators to byte data. More... | |
template<typename T > | |
CPubKey (const T pbegin, const T pend) | |
Construct a public key using begin/end iterators to byte data. More... | |
CPubKey (const std::vector< unsigned char > &_vch) | |
Construct a public key from a byte vector. More... | |
unsigned int | size () const |
Simple read-only vector-like interface to the pubkey data. More... | |
const unsigned char * | begin () const |
const unsigned char * | end () const |
const unsigned char & | operator[] (unsigned int pos) const |
template<typename Stream > | |
void | Serialize (Stream &s) const |
Implement serialization, as if this was a byte vector. More... | |
template<typename Stream > | |
void | Unserialize (Stream &s) |
CKeyID | GetID () const |
Get the KeyID of this public key (hash of its serialization) More... | |
uint256 | GetHash () const |
Get the 256-bit hash of this public key. More... | |
bool | IsValid () const |
bool | IsFullyValid () const |
fully validate whether this is a valid public key (more expensive than IsValid()) More... | |
bool | IsCompressed () const |
Check whether this is a compressed public key. More... | |
bool | Verify (const uint256 &hash, const std::vector< unsigned char > &vchSig) const |
Verify a DER signature (~72 bytes). More... | |
bool | RecoverCompact (const uint256 &hash, const std::vector< unsigned char > &vchSig) |
Recover a public key from a compact signature. More... | |
bool | Decompress () |
Turn this public key into an uncompressed public key. More... | |
bool | Derive (CPubKey &pubkeyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode &cc) const |
Derive BIP32 child pubkey. More... | |
Static Public Member Functions | |
static bool | CheckLowS (const std::vector< unsigned char > &vchSig) |
Check whether a signature is normalized (lower-S). More... | |
Static Public Attributes | |
static const unsigned int | PUBLIC_KEY_SIZE = 65 |
secp256k1: More... | |
static const unsigned int | COMPRESSED_PUBLIC_KEY_SIZE = 33 |
static const unsigned int | SIGNATURE_SIZE = 72 |
static const unsigned int | COMPACT_SIGNATURE_SIZE = 65 |
Private Member Functions | |
void | Invalidate () |
Set this key data to be invalid. More... | |
Static Private Member Functions | |
unsigned static int | GetLen (unsigned char chHeader) |
Compute the length of a pubkey with a given first byte. More... | |
Private Attributes | |
unsigned char | vch [PUBLIC_KEY_SIZE] |
see www.keylength.com script supports up to 75 for single byte push More... | |
Friends | |
bool | operator== (const CPubKey &a, const CPubKey &b) |
Comparator implementation. More... | |
bool | operator!= (const CPubKey &a, const CPubKey &b) |
bool | operator< (const CPubKey &a, const CPubKey &b) |
Detailed Description
Constructor & Destructor Documentation
◆ CPubKey() [1/3]
|
inline |
◆ CPubKey() [2/3]
|
inline |
◆ CPubKey() [3/3]
|
inlineexplicit |
Member Function Documentation
◆ begin()
|
inline |
Definition at line 105 of file pubkey.h.
References vch.
Referenced by CKey::Derive(), Derive(), CExtPubKey::Encode(), CKey::GetPubKey(), GetScriptForRawPubKey(), and WalletBatch::WriteKey().
◆ CheckLowS()
|
static |
Check whether a signature is normalized (lower-S).
Definition at line 274 of file pubkey.cpp.
References secp256k1_ecdsa_signature::data, ecdsa_signature_parse_der_lax(), and secp256k1_ecdsa_signature_normalize().
Referenced by IsLowDERSignature().
◆ Decompress()
bool CPubKey::Decompress | ( | ) |
Turn this public key into an uncompressed public key.
Definition at line 213 of file pubkey.cpp.
References IsValid(), PUBLIC_KEY_SIZE, secp256k1_ec_pubkey_parse(), secp256k1_ec_pubkey_serialize(), SECP256K1_EC_UNCOMPRESSED, Set(), and size().
◆ Derive()
bool CPubKey::Derive | ( | CPubKey & | pubkeyChild, |
ChainCode & | ccChild, | ||
unsigned int | nChild, | ||
const ChainCode & | cc | ||
) | const |
Derive BIP32 child pubkey.
Definition at line 227 of file pubkey.cpp.
References base_blob< BITS >::begin(), begin(), BIP32Hash(), COMPRESSED_PUBLIC_KEY_SIZE, IsValid(), memcpy(), SECP256K1_EC_COMPRESSED, secp256k1_ec_pubkey_parse(), secp256k1_ec_pubkey_serialize(), secp256k1_ec_pubkey_tweak_add(), Set(), and size().
Referenced by CExtPubKey::Derive().
◆ end()
|
inline |
Definition at line 106 of file pubkey.h.
Referenced by GetScriptForRawPubKey(), and WalletBatch::WriteKey().
◆ GetHash()
|
inline |
Get the 256-bit hash of this public key.
Definition at line 155 of file pubkey.h.
References Hash(), size(), and vch.
Referenced by CCryptoKeyStore::AddKeyPubKey(), DecryptKey(), and CCryptoKeyStore::EncryptKeys().
◆ GetID()
|
inline |
Get the KeyID of this public key (hash of its serialization)
Definition at line 149 of file pubkey.h.
References Hash160(), size(), and vch.
Referenced by CCryptoKeyStore::AddCryptedKey(), CWallet::AddCryptedKey(), CWallet::AddHDPubKey(), CBasicKeyStore::AddKeyPubKey(), CWallet::AddKeyPubKeyWithDB(), AddressTableModel::addRow(), CBasicKeyStore::AddWatchOnly(), CWallet::CreateCollateralTransaction(), CWallet::CreateTransaction(), CTransactionBuilder::CTransactionBuilder(), CTransactionBuilderOutput::CTransactionBuilderOutput(), CExtKey::Derive(), CExtPubKey::Derive(), CWallet::DeriveNewChildKey(), ExtractDestination(), ExtractDestinations(), PaymentServer::fetchPaymentACK(), CWallet::GenerateNewKey(), CWallet::GetAccountDestination(), getnewaddress(), getrawchangeaddress(), CKeyHolder::GetScriptForDestination(), CSporkMessage::GetSignerKeyID(), HaveKeys(), importelectrumwallet(), importprivkey(), importwallet(), IsMine(), CWallet::LoadHDPubKey(), CWallet::LoadKeyPool(), CWallet::MarkReserveKeysAsUsed(), SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked(), ProcessImport(), CBasicKeyStore::RemoveWatchOnly(), CWallet::ReserveKeyFromKeyPool(), CWallet::ReturnKey(), CSporkManager::SetPrivKey(), CSporkMessage::Sign(), SignN(), SignStep(), CWallet::TopUpKeyPool(), CHashSigner::VerifyHash(), CMessageSigner::VerifyMessage(), and verifymessage().
◆ GetLen()
|
inlinestaticprivate |
Compute the length of a pubkey with a given first byte.
Definition at line 57 of file pubkey.h.
References COMPRESSED_PUBLIC_KEY_SIZE, and PUBLIC_KEY_SIZE.
◆ Invalidate()
|
inlineprivate |
◆ IsCompressed()
|
inline |
Check whether this is a compressed public key.
Definition at line 174 of file pubkey.h.
References COMPRESSED_PUBLIC_KEY_SIZE, and size().
Referenced by DecryptKey(), CKey::Load(), CoinControlDialog::updateLabels(), and CKey::VerifyPubKey().
◆ IsFullyValid()
bool CPubKey::IsFullyValid | ( | ) | const |
fully validate whether this is a valid public key (more expensive than IsValid())
Definition at line 206 of file pubkey.cpp.
References IsValid(), secp256k1_ec_pubkey_parse(), and size().
Referenced by AddrToPubKey(), ExtractPubKey(), HexToPubKey(), CScriptCompressor::IsToPubKey(), MutateTxAddOutMultiSig(), and MutateTxAddOutPubKey().
◆ IsValid()
|
inline |
Definition at line 165 of file pubkey.h.
References size().
Referenced by TransactionSignatureChecker::CheckSig(), Decompress(), Derive(), ExtractDestination(), ExtractDestinations(), CWallet::GetAccountDestination(), GetOldestKeyInPool(), CKey::GetPubKey(), CReserveKey::GetReservedKey(), IsFullyValid(), CWallet::ReserveKeyFromKeyPool(), and Verify().
◆ operator[]()
|
inline |
◆ RecoverCompact()
bool CPubKey::RecoverCompact | ( | const uint256 & | hash, |
const std::vector< unsigned char > & | vchSig | ||
) |
Recover a public key from a compact signature.
Definition at line 186 of file pubkey.cpp.
References base_blob< BITS >::begin(), COMPACT_SIGNATURE_SIZE, PUBLIC_KEY_SIZE, SECP256K1_EC_COMPRESSED, secp256k1_ec_pubkey_serialize(), SECP256K1_EC_UNCOMPRESSED, secp256k1_ecdsa_recover(), secp256k1_ecdsa_recoverable_signature_parse_compact(), and Set().
Referenced by CSporkMessage::GetSignerKeyID(), SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked(), CHashSigner::VerifyHash(), and verifymessage().
◆ Serialize()
|
inline |
Implement serialization, as if this was a byte vector.
Definition at line 127 of file pubkey.h.
References size(), vch, and WriteCompactSize().
◆ Set()
|
inline |
Initialize a public key using begin/end iterators to byte data.
Definition at line 81 of file pubkey.h.
References GetLen(), Invalidate(), memcpy(), and vch.
Referenced by CPubKey(), CExtPubKey::Decode(), Decompress(), Derive(), CScriptCompressor::IsToPubKey(), and RecoverCompact().
◆ size()
|
inline |
Simple read-only vector-like interface to the pubkey data.
Definition at line 104 of file pubkey.h.
Referenced by Decompress(), CKey::Derive(), Derive(), CExtPubKey::Encode(), end(), GetHash(), GetID(), CKey::GetPubKey(), IsCompressed(), IsFullyValid(), IsValid(), Serialize(), Verify(), and WalletBatch::WriteKey().
◆ Unserialize()
|
inline |
Definition at line 134 of file pubkey.h.
References Invalidate(), PUBLIC_KEY_SIZE, ReadCompactSize(), and vch.
◆ Verify()
bool CPubKey::Verify | ( | const uint256 & | hash, |
const std::vector< unsigned char > & | vchSig | ||
) | const |
Verify a DER signature (~72 bytes).
If this public key is not fully valid, the return value will be false.
Definition at line 169 of file pubkey.cpp.
References base_blob< BITS >::begin(), secp256k1_ecdsa_signature::data, ecdsa_signature_parse_der_lax(), IsValid(), secp256k1_ec_pubkey_parse(), secp256k1_ecdsa_signature_normalize(), secp256k1_ecdsa_verify(), and size().
Referenced by CKey::VerifyPubKey(), and TransactionSignatureChecker::VerifySignature().
Friends And Related Function Documentation
◆ operator!=
◆ operator<
◆ operator==
Member Data Documentation
◆ COMPACT_SIGNATURE_SIZE
|
static |
Definition at line 39 of file pubkey.h.
Referenced by RecoverCompact(), and CKey::SignCompact().
◆ COMPRESSED_PUBLIC_KEY_SIZE
|
static |
Definition at line 37 of file pubkey.h.
Referenced by CKey::Derive(), Derive(), ec_privkey_export_der(), CExtPubKey::Encode(), GetLen(), and IsCompressed().
◆ PUBLIC_KEY_SIZE
|
static |
secp256k1:
Definition at line 36 of file pubkey.h.
Referenced by Decompress(), ec_privkey_export_der(), GetLen(), CKey::GetPubKey(), RecoverCompact(), and Unserialize().
◆ SIGNATURE_SIZE
|
static |
Definition at line 38 of file pubkey.h.
Referenced by CKey::Sign().
◆ vch
|
private |
see www.keylength.com script supports up to 75 for single byte push
Just store the serialized data. Its length can very cheaply be computed from the first byte.
Definition at line 46 of file pubkey.h.
Referenced by begin(), end(), GetHash(), GetID(), Invalidate(), operator[](), Serialize(), Set(), size(), and Unserialize().
The documentation for this class was generated from the following files:
- src/pubkey.h
- src/pubkey.cpp