48 unsigned char vch[65];
51 unsigned int static GetLen(
unsigned char chHeader)
53 if (chHeader == 2 || chHeader == 3)
55 if (chHeader == 4 || chHeader == 6 || chHeader == 7)
75 void Set(
const T pbegin,
const T pend)
77 int len = pend == pbegin ? 0 : GetLen(pbegin[0]);
78 if (len && len == (pend - pbegin))
79 memcpy(vch, (
unsigned char*)&pbegin[0], len);
92 explicit CPubKey(
const std::vector<unsigned char>& _vch)
94 Set(_vch.begin(), _vch.end());
98 unsigned int size()
const {
return GetLen(vch[0]); }
99 const unsigned char*
begin()
const {
return vch; }
100 const unsigned char*
end()
const {
return vch +
size(); }
101 const unsigned char&
operator[](
unsigned int pos)
const {
return vch[pos]; }
106 return a.
vch[0] == b.
vch[0] &&
115 return a.
vch[0] < b.
vch[0] ||
120 template <
typename Stream>
123 unsigned int len =
size();
125 s.write((
char*)vch, len);
127 template <
typename Stream>
132 s.read((
char*)vch, len);
165 bool IsFullyValid()
const;
177 bool Verify(
const uint256& hash,
const std::vector<unsigned char>& vchSig)
const;
182 static bool CheckLowS(
const std::vector<unsigned char>& vchSig);
185 bool RecoverCompact(
const uint256& hash,
const std::vector<unsigned char>& vchSig);
196 unsigned char vchFingerprint[4];
211 void Decode(
const unsigned char code[BIP32_EXTKEY_SIZE]);
212 bool Derive(
CExtPubKey& out,
unsigned int nChild)
const;
217 s.
seek(BIP32_EXTKEY_SIZE + 1);
219 template <
typename Stream>
226 s.write((
const char *)&code[0], len);
228 template <
typename Stream>
233 if (len != BIP32_EXTKEY_SIZE)
234 throw std::runtime_error(
"Invalid extended key size\n");
235 s.read((
char *)&code[0], len);
251 #endif // RAVEN_PUBKEY_H unsigned char vchFingerprint[4]
unsigned static int GetLen(unsigned char chHeader)
Compute the length of a pubkey with a given first byte.
friend bool operator<(const CPubKey &a, const CPubKey &b)
uint64_t ReadCompactSize(Stream &is)
void WriteCompactSize(CSizeComputer &os, uint64_t nSize)
CKeyID(const uint160 &in)
void Invalidate()
Set this key data to be invalid.
void Set(const T pbegin, const T pend)
Initialize a public key using begin/end iterators to byte data.
uint256 GetHash() const
Get the 256-bit hash of this public key.
void Serialize(Stream &s) const
const unsigned char & operator[](unsigned int pos) const
void Unserialize(Stream &s)
uint160 Hash160(const T1 pbegin, const T1 pend)
Compute the 160-bit hash an object.
friend bool operator==(const CPubKey &a, const CPubKey &b)
Comparator implementation.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
const unsigned char * begin() const
void Serialize(Stream &s) const
Implement serialization, as if this was a byte vector.
void Unserialize(Stream &s)
Users of this module must hold an ECCVerifyHandle.
friend bool operator==(const CExtPubKey &a, const CExtPubKey &b)
const unsigned char * end() const
CPubKey()
Construct an invalid public key.
An encapsulated public key.
uint256 Hash(const T1 pbegin, const T1 pend)
Compute the 256-bit hash of an object.
unsigned int size() const
Simple read-only vector-like interface to the pubkey data.
unsigned int size() const
unsigned char vch[65]
Just store the serialized data.
CPubKey(const std::vector< unsigned char > &_vch)
Construct a public key from a byte vector.
void seek(size_t _nSize)
Pretend _nSize bytes are written, without specifying them.
void * memcpy(void *a, const void *b, size_t c)
const unsigned int BIP32_EXTKEY_SIZE
secp256k1: const unsigned int PRIVATE_KEY_SIZE = 279; const unsigned int PUBLIC_KEY_SIZE = 65; const ...
CPubKey(const T pbegin, const T pend)
Construct a public key using begin/end iterators to byte data.
A reference to a CKey: the Hash160 of its serialized public key.
void Serialize(CSizeComputer &s) const
friend bool operator!=(const CPubKey &a, const CPubKey &b)
bool IsCompressed() const
Check whether this is a compressed public key.