Fabcoin Core  0.16.2
P2P Digital Currency
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
CPubKey Class Reference

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
 
std::vector< unsigned char > getvch () 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...
 

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 [65]
 Just store the serialized data. 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

An encapsulated public key.

Definition at line 39 of file pubkey.h.

Constructor & Destructor Documentation

CPubKey::CPubKey ( )
inline

Construct an invalid public key.

Definition at line 67 of file pubkey.h.

template<typename T >
CPubKey::CPubKey ( const T  pbegin,
const T  pend 
)
inline

Construct a public key using begin/end iterators to byte data.

Definition at line 85 of file pubkey.h.

CPubKey::CPubKey ( const std::vector< unsigned char > &  _vch)
inline

Construct a public key from a byte vector.

Definition at line 91 of file pubkey.h.

Member Function Documentation

const unsigned char* CPubKey::begin ( void  ) const
inline

Definition at line 98 of file pubkey.h.

Here is the caller graph for this function:

bool CPubKey::CheckLowS ( const std::vector< unsigned char > &  vchSig)
static

Check whether a signature is normalized (lower-S).

Definition at line 272 of file pubkey.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CPubKey::Decompress ( )

Turn this public key into an uncompressed public key.

Definition at line 211 of file pubkey.cpp.

Here is the call graph for this function:

bool CPubKey::Derive ( CPubKey pubkeyChild,
ChainCode ccChild,
unsigned int  nChild,
const ChainCode cc 
) const

Derive BIP32 child pubkey.

Definition at line 225 of file pubkey.cpp.

Here is the call graph for this function:

const unsigned char* CPubKey::end ( void  ) const
inline

Definition at line 99 of file pubkey.h.

Here is the call graph for this function:

Here is the caller graph for this function:

uint256 CPubKey::GetHash ( ) const
inline

Get the 256-bit hash of this public key.

Definition at line 152 of file pubkey.h.

Here is the call graph for this function:

Here is the caller graph for this function:

CKeyID CPubKey::GetID ( ) const
inline

Get the KeyID of this public key (hash of its serialization)

Definition at line 146 of file pubkey.h.

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned static int CPubKey::GetLen ( unsigned char  chHeader)
inlinestaticprivate

Compute the length of a pubkey with a given first byte.

Definition at line 50 of file pubkey.h.

std::vector<unsigned char> CPubKey::getvch ( ) const
inline

Definition at line 101 of file pubkey.h.

Here is the call graph for this function:

void CPubKey::Invalidate ( )
inlineprivate

Set this key data to be invalid.

Definition at line 60 of file pubkey.h.

bool CPubKey::IsCompressed ( ) const
inline

Check whether this is a compressed public key.

Definition at line 171 of file pubkey.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CPubKey::IsFullyValid ( ) const

fully validate whether this is a valid public key (more expensive than IsValid())

Definition at line 204 of file pubkey.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CPubKey::IsValid ( ) const
inline

Definition at line 162 of file pubkey.h.

Here is the call graph for this function:

Here is the caller graph for this function:

const unsigned char& CPubKey::operator[] ( unsigned int  pos) const
inline

Definition at line 100 of file pubkey.h.

bool CPubKey::RecoverCompact ( const uint256 hash,
const std::vector< unsigned char > &  vchSig 
)

Recover a public key from a compact signature.

Definition at line 184 of file pubkey.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename Stream >
void CPubKey::Serialize ( Stream &  s) const
inline

Implement serialization, as if this was a byte vector.

Definition at line 124 of file pubkey.h.

Here is the call graph for this function:

template<typename T >
void CPubKey::Set ( const T  pbegin,
const T  pend 
)
inline

Initialize a public key using begin/end iterators to byte data.

Definition at line 74 of file pubkey.h.

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int CPubKey::size ( void  ) const
inline

Simple read-only vector-like interface to the pubkey data.

Definition at line 97 of file pubkey.h.

Here is the caller graph for this function:

template<typename Stream >
void CPubKey::Unserialize ( Stream &  s)
inline

Definition at line 131 of file pubkey.h.

Here is the call graph for this function:

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 167 of file pubkey.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

bool operator!= ( const CPubKey a,
const CPubKey b 
)
friend

Definition at line 112 of file pubkey.h.

bool operator< ( const CPubKey a,
const CPubKey b 
)
friend

Definition at line 116 of file pubkey.h.

bool operator== ( const CPubKey a,
const CPubKey b 
)
friend

Comparator implementation.

Definition at line 107 of file pubkey.h.

Member Data Documentation

unsigned char CPubKey::vch[65]
private

Just store the serialized data.

Its length can very cheaply be computed from the first byte.

Definition at line 47 of file pubkey.h.


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