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])) {
120 bool Sign(
const uint256& hash, std::vector<unsigned char>& vchSig,
bool grind =
true,
uint32_t test_case = 0)
const;
164 void SetSeed(
const unsigned char* seed,
unsigned int nSeedLen);
165 template <
typename Stream>
172 s.write((
const char *)&code[0], len);
174 template <
typename Stream>
180 throw std::runtime_error(
"Invalid extended key size\n");
181 s.read((
char *)&code[0], len);
195 #endif // BITCOIN_KEY_H static const unsigned int COMPRESSED_PRIVATE_KEY_SIZE
Definition: key.h:34
bool Negate()
Negate private key.
Definition: key.cpp:165
void Encode(unsigned char code[BIP32_EXTKEY_SIZE]) const
Definition: key.cpp:322
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
Definition: key.h:74
void ECC_Stop()
Definition: key.cpp:365
uint64_t ReadCompactSize(Stream &is)
Definition: serialize.h:289
void WriteCompactSize(CSizeComputer &os, uint64_t nSize)
Definition: serialize.h:986
bool fCompressed
Whether the public key corresponding to this private key is (to be) compressed.
Definition: key.h:49
bool Derive(CExtKey &out, unsigned int nChild) const
Definition: key.cpp:293
friend bool operator==(const CKey &a, const CKey &b)
Definition: key.h:65
bool VerifyPubKey(const CPubKey &vchPubKey) const
Definition: key.cpp:232
void Decode(const unsigned char code[BIP32_EXTKEY_SIZE])
Definition: key.cpp:333
CPrivKey GetPrivKey() const
Definition: key.cpp:171
bool Derive(CKey &keyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode &cc) const
Derive BIP32 child key.
Definition: key.cpp:273
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
Definition: key.h:24
CKey key
Definition: key.h:149
CExtPubKey Neuter() const
Definition: key.cpp:312
unsigned char vchFingerprint[4]
Definition: key.h:146
unsigned int uint32_t
Definition: stdint.h:21
ChainCode chaincode
Definition: key.h:148
friend bool operator==(const CExtKey &a, const CExtKey &b)
Definition: key.h:151
const unsigned char * begin() const
Definition: key.h:89
static const unsigned int PRIVATE_KEY_SIZE
Definition: key.h:33
std::vector< unsigned char, secure_allocator< unsigned char > > keydata
The actual byte data.
Definition: key.h:52
static bool Check(const unsigned char *vch)
Check whether the 32-byte array pointed to by vch is valid keydata.
Definition: key.cpp:153
Definition: uint256.h:121
bool Load(const CPrivKey &privkey, const CPubKey &vchPubKey, bool fSkipCheck)
Load private key and check that public key matches.
Definition: key.cpp:261
bool fValid
Definition: key.h:41
bool IsCompressed() const
Check whether the public key corresponding to this private key is (to be) compressed.
Definition: key.h:96
void Serialize(Stream &s) const
Definition: key.h:166
void * memcpy(void *a, const void *b, size_t c)
Definition: glibc_compat.cpp:18
const unsigned int BIP32_EXTKEY_SIZE
Definition: pubkey.h:17
const unsigned char * end() const
Definition: key.h:90
unsigned char nDepth
Definition: key.h:145
CPubKey GetPubKey() const
Definition: key.cpp:184
bool ECC_InitSanityCheck()
Definition: key.cpp:341
unsigned int size() const
Simple read-only vector-like interface.
Definition: key.h:88
bool IsValid() const
Check whether this private key is valid.
Definition: key.h:93
void SetSeed(const unsigned char *seed, unsigned int nSeedLen)
Definition: key.cpp:301
bool Sign(const uint256 &hash, std::vector< unsigned char > &vchSig, bool grind=true, uint32_t test_case=0) const
Definition: key.cpp:210
CKey()
Construct an invalid private key.
Definition: key.h:59
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
Definition: key.cpp:246
unsigned int nChild
Definition: key.h:147
void Unserialize(Stream &s)
Definition: key.h:175
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
Definition: key.cpp:157
void ECC_Start()
Definition: key.cpp:348