44 unsigned char vch[65];
47 unsigned int static GetLen(
unsigned char chHeader) {
48 if (chHeader == 2 || chHeader == 3)
50 if (chHeader == 4 || chHeader == 6 || chHeader == 7)
68 void Set(
const T pbegin,
const T pend) {
69 int len = pend == pbegin ? 0 :
GetLen(pbegin[0]);
70 if (len && len == (pend-pbegin))
71 memcpy(vch, (
unsigned char*)&pbegin[0], len);
83 CPubKey(
const std::vector<unsigned char> &vch) {
84 Set(vch.begin(), vch.end());
89 const unsigned char *
begin()
const {
return vch; }
90 const unsigned char *
end()
const {
return vch+
size(); }
91 const unsigned char &
operator[](
unsigned int pos)
const {
return vch[pos]; }
95 return a.
vch[0] == b.
vch[0] &&
102 return a.
vch[0] < b.
vch[0] ||
110 template<
typename Stream>
void Serialize(Stream &s,
int nType,
int nVersion)
const {
111 unsigned int len =
size();
113 s.write((
char*)vch, len);
115 template<
typename Stream>
void Unserialize(Stream &s,
int nType,
int nVersion) {
118 s.read((
char*)vch, len);
153 bool Verify(
const uint256 &
hash,
const std::vector<unsigned char>& vchSig)
const;
169 typedef std::vector<unsigned char, secure_allocator<unsigned char> >
CPrivKey;
185 bool static Check(
const unsigned char *vch);
194 CKey(
const CKey &secret) : fValid(secret.fValid), fCompressed(secret.fCompressed) {
196 memcpy(vch, secret.
vch,
sizeof(vch));
206 void Set(
const T pbegin,
const T pend,
bool fCompressedIn) {
207 if (pend - pbegin != 32) {
211 if (
Check(&pbegin[0])) {
212 memcpy(vch, (
unsigned char*)&pbegin[0], 32);
214 fCompressed = fCompressedIn;
221 unsigned int size()
const {
return (fValid ? 32 : 0); }
223 const unsigned char *
end()
const {
return vch +
size(); }
246 bool Sign(
const uint256 &
hash, std::vector<unsigned char>& vchSig)
const;
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)
unsigned static int GetLen(unsigned char chHeader)
const unsigned char * begin() const
friend bool operator<(const CPubKey &a, const CPubKey &b)
const unsigned char * end() const
CKeyID(const uint160 &in)
unsigned int size() const
void Set(const T pbegin, const T pend)
bool Sign(const uint256 &hash, std::vector< unsigned char > &vchSig) const
uint160 Hash160(const T1 pbegin, const T1 pend)
friend bool operator==(const CPubKey &a, const CPubKey &b)
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
int std::string int dummy
bool IsCompressed() const
void LockObject(const T &t)
void Serialize(Stream &s, int nType, int nVersion) const
CPubKey GetPubKey() const
CPrivKey GetPrivKey() const
bool RecoverCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig)
An encapsulated public key.
void MakeNewKey(bool fCompressed)
const unsigned char & operator[](unsigned int pos) const
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
CScriptID(const uint160 &in)
void WriteCompactSize(Stream &os, uint64 nSize)
bool IsCompressed() const
bool SetPrivKey(const CPrivKey &vchPrivKey, bool fCompressed)
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
CPubKey(const T pbegin, const T pend)
A reference to a CKey: the Hash160 of its serialized public key.
bool IsFullyValid() const
A reference to a CScript: the Hash160 of its serialization (see script.h)
uint64 ReadCompactSize(Stream &is)
static bool Check(const unsigned char *vch)
An encapsulated private key.
bool Verify(const uint256 &hash, const std::vector< unsigned char > &vchSig) const
unsigned int size() const
unsigned int GetSerializeSize(int nType, int nVersion) const
friend bool operator!=(const CPubKey &a, const CPubKey &b)
const unsigned char * end() const