46 unsigned char vch[65];
49 unsigned int static GetLen(
unsigned char chHeader) {
50 if (chHeader == 2 || chHeader == 3)
52 if (chHeader == 4 || chHeader == 6 || chHeader == 7)
70 void Set(
const T pbegin,
const T pend) {
71 int len = pend == pbegin ? 0 :
GetLen(pbegin[0]);
72 if (len && len == (pend-pbegin))
73 memcpy(vch, (
unsigned char*)&pbegin[0], len);
85 CPubKey(
const std::vector<unsigned char> &vch) {
86 Set(vch.begin(), vch.end());
91 const unsigned char *
begin()
const {
return vch; }
92 const unsigned char *
end()
const {
return vch+
size(); }
93 const unsigned char &
operator[](
unsigned int pos)
const {
return vch[pos]; }
97 return a.
vch[0] == b.
vch[0] &&
104 return a.
vch[0] < b.
vch[0] ||
112 template<
typename Stream>
void Serialize(Stream &s,
int nType,
int nVersion)
const {
113 unsigned int len =
size();
115 s.write((
char*)vch, len);
117 template<
typename Stream>
void Unserialize(Stream &s,
int nType,
int nVersion) {
120 s.read((
char*)vch, len);
157 bool Verify(
const uint256 &hash,
const std::vector<unsigned char>& vchSig)
const;
170 bool Derive(
CPubKey& pubkeyChild,
unsigned char ccChild[32],
unsigned int nChild,
const unsigned char cc[32])
const;
176 typedef std::vector<unsigned char, secure_allocator<unsigned char> >
CPrivKey;
192 bool static Check(
const unsigned char *vch);
201 CKey(
const CKey &secret) : fValid(secret.fValid), fCompressed(secret.fCompressed) {
218 void Set(
const T pbegin,
const T pend,
bool fCompressedIn) {
219 if (pend - pbegin != 32) {
223 if (
Check(&pbegin[0])) {
224 memcpy(vch, (
unsigned char*)&pbegin[0], 32);
226 fCompressed = fCompressedIn;
233 unsigned int size()
const {
return (fValid ? 32 : 0); }
235 const unsigned char *
end()
const {
return vch +
size(); }
258 bool Sign(
const uint256 &hash, std::vector<unsigned char>& vchSig)
const;
268 bool Derive(
CKey& keyChild,
unsigned char ccChild[32],
unsigned int nChild,
const unsigned char cc[32])
const;
286 void Encode(
unsigned char code[74])
const;
287 void Decode(
const unsigned char code[74]);
303 void Encode(
unsigned char code[74])
const;
304 void Decode(
const unsigned char code[74]);
307 void SetMaster(
const unsigned char *seed,
unsigned int nSeedLen);
bool VerifyCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig) const
void UnlockObject(const T &t)
void Unserialize(Stream &s, int nType, int nVersion)
void Encode(unsigned char code[74]) const
unsigned char vchFingerprint[4]
unsigned static int GetLen(unsigned char chHeader)
const unsigned char * begin() const
unsigned char vchChainCode[32]
CExtPubKey Neuter() const
friend bool operator<(const CPubKey &a, const CPubKey &b)
uint64_t ReadCompactSize(Stream &is)
const unsigned char * end() const
CKeyID(const uint160 &in)
unsigned int size() const
void Set(const T pbegin, const T pend)
unsigned char vchFingerprint[4]
bool Sign(const uint256 &hash, std::vector< unsigned char > &vchSig) const
uint160 Hash160(const T1 pbegin, const T1 pend)
void Decode(const unsigned char code[74])
friend bool operator==(const CPubKey &a, const CPubKey &b)
bool Derive(CExtPubKey &out, unsigned int nChild) const
bool Derive(CExtKey &out, unsigned int nChild) const
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
bool IsCompressed() const
friend bool operator==(const CExtPubKey &a, const CExtPubKey &b)
void LockObject(const T &t)
void Serialize(Stream &s, int nType, int nVersion) const
CPubKey GetPubKey() const
CPrivKey GetPrivKey() const
bool Derive(CKey &keyChild, unsigned char ccChild[32], unsigned int nChild, const unsigned char cc[32]) const
bool RecoverCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig)
friend bool operator==(const CExtKey &a, const CExtKey &b)
An encapsulated public key.
void MakeNewKey(bool fCompressed)
const unsigned char & operator[](unsigned int pos) const
unsigned char vchChainCode[32]
CPubKey(const std::vector< unsigned char > &vch)
uint256 Hash(const T1 pbegin, const T1 pend)
void Set(const T pbegin, const T pend, bool fCompressedIn)
const unsigned char * begin() const
bool Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck)
CScriptID(const uint160 &in)
bool IsCompressed() const
void Decode(const unsigned char code[74])
bool SetPrivKey(const CPrivKey &vchPrivKey, bool fCompressed)
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
void * memcpy(void *a, const void *b, size_t c)
CPubKey(const T pbegin, const T pend)
A reference to a CKey: the Hash160 of its serialized public key.
bool IsFullyValid() const
void SetMaster(const unsigned char *seed, unsigned int nSeedLen)
A reference to a CScript: the Hash160 of its serialization (see script.h)
static bool Check(const unsigned char *vch)
An encapsulated private key.
bool Verify(const uint256 &hash, const std::vector< unsigned char > &vchSig) const
void Encode(unsigned char code[74]) const
bool Derive(CPubKey &pubkeyChild, unsigned char ccChild[32], unsigned int nChild, const unsigned char cc[32]) const
unsigned int size() const
void WriteCompactSize(Stream &os, uint64_t nSize)
unsigned int GetSerializeSize(int nType, int nVersion) const
friend bool operator!=(const CPubKey &a, const CPubKey &b)
const unsigned char * end() const
bool ECC_InitSanityCheck(void)
Check that required EC support is available at runtime.
friend bool operator==(const CKey &a, const CKey &b)