Equity
Bitcoin Protocol Library
Public Member Functions | Static Public Attributes | List of all members
Equity::PrivateKey Class Reference

A Bitcoin private key. More...

#include <PrivateKey.h>

Public Member Functions

 PrivateKey (uint8_t const *data, size_t size)
 The object is constructed from the bytes in the range [begin, end). If the size of the range is not SIZE bytes or the value is not valid, the constructed object is marked as invalid. More...
 
 PrivateKey (std::vector< uint8_t > const &k)
 The object is constructed from the bytes in the given vector. If the size of the vector is not SIZE or the value is not valid, the constructed object is marked as invalid. More...
 
 PrivateKey (std::string const &s)
 The input can be in either the WIF format or the mini-key format. If the format is invalid or the value of the key is invalid, the constructed object is marked as invalid. More...
 
void setCompressed (bool yes=true)
 Sets the compressed flag.
 
std::array< uint8_t, SIZEvalue () const
 Returns the value as an array of bytes.
 
bool compressed () const
 Returns the value of the compressed flag.
 
bool valid () const
 Returns true if this private key is valid.
 
std::string toWif (unsigned version) const
 Returns a WIF format string. More...
 
std::string toHex () const
 Returns a hex format string. More...
 

Static Public Attributes

static size_t const SIZE = 256 / 8
 Number of bytes in a private key.
 

Detailed Description

A Bitcoin private key.

A Bitcoin PrivateKey is basically an ECC private key, though it can take many forms and encodings.

Constructor & Destructor Documentation

PrivateKey::PrivateKey ( uint8_t const *  data,
size_t  size 
)

The object is constructed from the bytes in the range [begin, end). If the size of the range is not SIZE bytes or the value is not valid, the constructed object is marked as invalid.

Parameters
datapointer to start of the data
sizelength of the data
PrivateKey::PrivateKey ( std::vector< uint8_t > const &  k)
explicit

The object is constructed from the bytes in the given vector. If the size of the vector is not SIZE or the value is not valid, the constructed object is marked as invalid.

Parameters
kvector of bytes
PrivateKey::PrivateKey ( std::string const &  s)
explicit

The input can be in either the WIF format or the mini-key format. If the format is invalid or the value of the key is invalid, the constructed object is marked as invalid.

Parameters
sstring form of the private key

Member Function Documentation

std::string PrivateKey::toHex ( ) const

Returns a hex format string.

Returns
a string containing the private key in hex format, or empty if the object is invalid
std::string PrivateKey::toWif ( unsigned  version) const

Returns a WIF format string.

Parameters
versionversion byte to be prepended (typically 0x80)
Returns
a string containing the private key in WIF format, or empty if the object is invalid

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