32 typedef std::vector<unsigned char, secure_allocator<unsigned char> >
CPrivKey;
46 std::vector<unsigned char, secure_allocator<unsigned char> >
keydata;
49 bool static Check(
const unsigned char* vch);
53 CKey() : fValid(false), fCompressed(false)
73 void Set(
const T pbegin,
const T pend,
bool fCompressedIn)
75 if (
size_t(pend - pbegin) != keydata.size()) {
77 }
else if (
Check(&pbegin[0])) {
78 memcpy(keydata.data(), (
unsigned char*)&pbegin[0], keydata.size());
80 fCompressed = fCompressedIn;
87 unsigned int size()
const {
return (fValid ? keydata.size() : 0); }
88 const unsigned char*
begin()
const {
return keydata.data(); }
89 const unsigned char*
end()
const {
return keydata.data() +
size(); }
116 bool Sign(
const uint256& hash, std::vector<unsigned char>& vchSig, uint32_t test_case = 0)
const;
142 unsigned char vchFingerprint[4];
157 void Decode(
const unsigned char code[BIP32_EXTKEY_SIZE]);
160 void SetMaster(
const unsigned char* seed,
unsigned int nSeedLen);
161 template <
typename Stream>
168 s.write((
const char *)&code[0], len);
170 template <
typename Stream>
175 if (len != BIP32_EXTKEY_SIZE)
176 throw std::runtime_error(
"Invalid extended key size\n");
177 s.read((
char *)&code[0], len);
191 #endif // FABCOIN_KEY_H const unsigned char * begin() const
bool VerifyPubKey(const CPubKey &vchPubKey) const
Verify thoroughly whether a private key and a public key match.
uint64_t ReadCompactSize(Stream &is)
void WriteCompactSize(CSizeComputer &os, uint64_t nSize)
const unsigned char * end() const
unsigned char vchFingerprint[4]
void Unserialize(Stream &s)
bool fValid
Whether this private key is valid.
void Serialize(Stream &s) const
bool IsValid() const
Check whether this private key is valid.
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
secp256k1: const unsigned int PRIVATE_KEY_SIZE = 279; const unsigned int PUBLIC_KEY_SIZE = 65; const ...
bool IsCompressed() const
Check whether the public key corresponding to this private key is (to be) compressed.
CPubKey GetPubKey() const
Compute the public key from a private key.
CPrivKey GetPrivKey() const
Convert the private key to a CPrivKey (serialized OpenSSL private key data).
friend bool operator==(const CExtKey &a, const CExtKey &b)
An encapsulated public key.
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
~CKey()
Destructor (again necessary because of memlocking).
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
bool Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck)
Load private key and check that public key matches.
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
Create a compact signature (65 bytes), which allows reconstructing the used public key...
void ECC_Start(void)
Initialize the elliptic curve support.
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 ...
bool fCompressed
Whether the public key corresponding to this private key is (to be) compressed.
CKey()
Construct an invalid private key.
std::vector< unsigned char, secure_allocator< unsigned char > > keydata
The actual byte data.
static bool Check(const unsigned char *vch)
Check whether the 32-byte array pointed to by vch is valid keydata.
An encapsulated private key.
unsigned int size() const
Simple read-only vector-like interface.
bool Derive(CKey &keyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode &cc) const
Derive BIP32 child key.
bool Sign(const uint256 &hash, std::vector< unsigned char > &vchSig, uint32_t test_case=0) const
Create a DER-serialized signature.
void ECC_Stop(void)
Deinitialize the elliptic curve support.
bool ECC_InitSanityCheck(void)
Check that required EC support is available at runtime.
friend bool operator==(const CKey &a, const CKey &b)