32 typedef std::vector<unsigned char, secure_allocator<unsigned char> >
CPrivKey;
46 unsigned char vch[32];
49 bool static Check(
const unsigned char*
vch);
79 void Set(
const T pbegin,
const T pend,
bool fCompressedIn)
81 if (pend - pbegin != 32) {
85 if (
Check(&pbegin[0])) {
86 memcpy(
vch, (
unsigned char*)&pbegin[0], 32);
96 const unsigned char*
begin()
const {
return vch; }
97 const unsigned char*
end()
const {
return vch +
size(); }
127 bool Sign(
const uint256& hash, std::vector<unsigned char>& vchSig, uint32_t test_case = 0)
const;
167 void Encode(
unsigned char code[74])
const;
168 void Decode(
const unsigned char code[74]);
171 void SetMaster(
const unsigned char* seed,
unsigned int nSeedLen);
172 template <
typename Stream>
173 void Serialize(Stream& s,
int nType,
int nVersion)
const 175 unsigned int len = 74;
177 unsigned char code[74];
179 s.write((
const char *)&code[0], len);
181 template <
typename Stream>
185 unsigned char code[74];
186 s.read((
char *)&code[0], len);
200 #endif // BITCOIN_KEY_H void SetMaster(const unsigned char *seed, unsigned int nSeedLen)
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
bool SetPrivKey(const CPrivKey &vchPrivKey, bool fCompressed)
Initialize from a CPrivKey (serialized OpenSSL private key data).
CKey(const CKey &secret)
Copy constructor. This is necessary because of memlocking.
uint64_t ReadCompactSize(Stream &is)
bool fCompressed
Whether the public key corresponding to this private key is (to be) compressed.
bool Derive(CExtKey &out, unsigned int nChild) const
friend bool operator==(const CKey &a, const CKey &b)
bool VerifyPubKey(const CPubKey &vchPubKey) const
bool Sign(const uint256 &hash, std::vector< unsigned char > &vchSig, uint32_t test_case=0) const
void UnlockObject(const T &t)
void Unserialize(Stream &s, int nType, int nVersion)
CPrivKey GetPrivKey() const
bool Derive(CKey &keyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode &cc) const
Derive BIP32 child key.
void Encode(unsigned char code[74]) const
bool Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck)
Load private key and check that public key matches.
static bool CheckSignatureElement(const unsigned char *vch, int len, bool half)
Check whether an element of a signature (r or s) is valid.
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
CExtPubKey Neuter() const
unsigned char vchFingerprint[4]
friend bool operator==(const CExtKey &a, const CExtKey &b)
void Decode(const unsigned char code[74])
const unsigned char * begin() const
static bool Check(const unsigned char *vch)
Check whether the 32-byte array pointed to be vch is valid keydata.
bool IsCompressed() const
Check whether the public key corresponding to this private key is (to be) compressed.
void * memcpy(void *a, const void *b, size_t c)
const unsigned char * end() const
CPubKey GetPubKey() const
unsigned char vch[32]
The actual byte data.
void Serialize(Stream &s, int nType, int nVersion) const
unsigned int size() const
Simple read-only vector-like interface.
bool IsValid() const
Check whether this private key is valid.
~CKey()
Destructor (again necessary because of memlocking).
CKey()
Construct an invalid private key.
void WriteCompactSize(Stream &os, uint64_t nSize)
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
void LockObject(const T &t)
bool ECC_InitSanityCheck(void)