24 typedef std::vector<unsigned char, secure_allocator<unsigned char> >
CPrivKey;
33 static const unsigned int SIZE = 279;
40 SIZE >= COMPRESSED_SIZE,
41 "COMPRESSED_SIZE is larger than SIZE");
52 std::vector<unsigned char, secure_allocator<unsigned char> > keydata;
55 bool static Check(
const unsigned char* vch);
59 CKey() : fValid(false), fCompressed(false)
67 return a.fCompressed == b.fCompressed &&
68 a.size() == b.size() &&
69 memcmp(a.keydata.data(), b.keydata.data(), a.size()) == 0;
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])) {
79 memcpy(keydata.data(), (
unsigned char*)&pbegin[0], keydata.size());
81 fCompressed = fCompressedIn;
88 unsigned int size()
const {
return (fValid ? keydata.size() : 0); }
89 const unsigned char* begin()
const {
return keydata.data(); }
90 const unsigned char* end()
const {
return keydata.data() + size(); }
93 bool IsValid()
const {
return fValid; }
96 bool IsCompressed()
const {
return fCompressed; }
99 void MakeNewKey(
bool fCompressed);
120 bool Sign(
const uint256& hash, std::vector<unsigned char>& vchSig,
bool grind =
true, uint32_t test_case = 0)
const;
129 bool SignCompact(
const uint256& hash, std::vector<unsigned char>& vchSig)
const;
138 bool VerifyPubKey(
const CPubKey& vchPubKey)
const;
141 bool Load(
const CPrivKey& privkey,
const CPubKey& vchPubKey,
bool fSkipCheck);
164 void SetSeed(
const unsigned char* seed,
unsigned int nSeedLen);
176 #endif // BITCOIN_KEY_H
CExtPubKey Neuter() const
bool operator==(const CNetAddr &a, const CNetAddr &b)
void ECC_Stop()
Deinitialize the elliptic curve support.
unsigned char vchFingerprint[4]
static const unsigned int SIZE
secp256k1:
bool Derive(CExtKey &out, unsigned int nChild) const
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
secure_allocator is defined in allocators.h CPrivKey is a serialized private key, with all parameters...
static const unsigned int COMPRESSED_SIZE
friend bool operator==(const CExtKey &a, const CExtKey &b)
An encapsulated public key.
void SetSeed(const unsigned char *seed, unsigned int nSeedLen)
void Decode(const unsigned char code[BIP32_EXTKEY_SIZE])
void * memcpy(void *a, const void *b, size_t c)
static bool GetPubKey(const SigningProvider &provider, const SignatureData &sigdata, const CKeyID &address, CPubKey &pubkey)
const unsigned int BIP32_EXTKEY_SIZE
bool ECC_InitSanityCheck()
Check that required EC support is available at runtime.
An encapsulated private key.
void Encode(unsigned char code[BIP32_EXTKEY_SIZE]) const
void ECC_Start()
Initialize the elliptic curve support.