24 typedef std::vector<unsigned char, secure_allocator<unsigned char> >
CPrivKey;
41 "COMPRESSED_PRIVATE_KEY_SIZE is larger than PRIVATE_KEY_SIZE");
52 std::vector<unsigned char, secure_allocator<unsigned char> >
keydata;
55 bool static Check(
const unsigned char* vch);
74 void Set(
const T pbegin,
const T pend,
bool fCompressedIn)
76 if (
size_t(pend - pbegin) !=
keydata.size()) {
78 }
else if (
Check(&pbegin[0])) {
117 bool Sign(
const uint256& hash, std::vector<unsigned char>& vchSig,
bool grind =
true, uint32_t test_case = 0)
const;
161 void SetSeed(
const unsigned char* seed,
unsigned int nSeedLen);
162 template <
typename Stream>
169 s.write((
const char *)&code[0], len);
171 template <
typename Stream>
177 throw std::runtime_error(
"Invalid extended key size\n");
178 s.read((
char *)&code[0], len);
192 #endif // BITCOIN_KEY_H CPrivKey GetPrivKey() const
Convert the private key to a CPrivKey (serialized OpenSSL private key data).
bool Derive(CExtKey &out, unsigned int nChild) const
void ECC_Stop()
Deinitialize the elliptic curve support.
uint64_t ReadCompactSize(Stream &is)
void WriteCompactSize(CSizeComputer &os, uint64_t nSize)
bool VerifyPubKey(const CPubKey &vchPubKey) const
Verify thoroughly whether a private key and a public key match.
CPubKey GetPubKey() const
Compute the public key from a private key.
static const unsigned int COMPRESSED_PRIVATE_KEY_SIZE
void Encode(unsigned char code[BIP32_EXTKEY_SIZE]) const
unsigned char vchFingerprint[4]
void Unserialize(Stream &s)
const unsigned char * begin() const
bool fValid
see www.keylength.com script supports up to 75 for single byte push
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
Create a compact signature (65 bytes), which allows reconstructing the used public key...
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
secure_allocator is defined in allocators.h CPrivKey is a serialized private key, with all parameters...
bool Sign(const uint256 &hash, std::vector< unsigned char > &vchSig, bool grind=true, uint32_t test_case=0) const
Create a DER-serialized signature.
static const unsigned int PRIVATE_KEY_SIZE
secp256k1:
friend bool operator==(const CExtKey &a, const CExtKey &b)
An encapsulated public key.
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
unsigned int size() const
Simple read-only vector-like interface.
bool IsCompressed() const
Check whether the public key corresponding to this private key is (to be) compressed.
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
void SetSeed(const unsigned char *seed, unsigned int nSeedLen)
void Decode(const unsigned char code[BIP32_EXTKEY_SIZE])
CExtPubKey Neuter() const
bool Derive(CKey &keyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode &cc) const
Derive BIP32 child key.
void * memcpy(void *a, const void *b, size_t c)
const unsigned char * end() const
const unsigned int BIP32_EXTKEY_SIZE
bool fCompressed
Whether the public key corresponding to this private key is (to be) compressed.
bool ECC_InitSanityCheck()
Check that required EC support is available at runtime.
CKey()
Construct an invalid private key.
std::vector< unsigned char, secure_allocator< unsigned char > > keydata
The actual byte data.
static bool Check(const unsigned char *vch)
Check whether the 32-byte array pointed to by vch is valid keydata.
An encapsulated private key.
void Serialize(Stream &s) const
bool Load(const CPrivKey &privkey, const CPubKey &vchPubKey, bool fSkipCheck)
Load private key and check that public key matches.
friend bool operator==(const CKey &a, const CKey &b)
bool IsValid() const
Check whether this private key is valid.
void ECC_Start()
Initialize the elliptic curve support.