23 typedef std::vector<unsigned char, secure_allocator<unsigned char> >
CPrivKey;
32 static const unsigned int SIZE = 279;
40 "COMPRESSED_SIZE is larger than SIZE");
51 std::vector<unsigned char, secure_allocator<unsigned char> >
keydata;
54 bool static Check(
const unsigned char* vch);
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());
88 const std::byte*
data()
const {
return reinterpret_cast<const std::byte*
>(
keydata.data()); }
120 bool Sign(
const uint256& hash, std::vector<unsigned char>& vchSig,
bool grind =
true, uint32_t test_case = 0)
const;
An encapsulated private key.
bool SignSchnorr(const uint256 &hash, Span< unsigned char > sig, const uint256 *merkle_root, const uint256 &aux) const
Create a BIP-340 Schnorr signature, for the xonly-pubkey corresponding to *this, optionally tweaked b...
bool Negate()
Negate private key.
static const unsigned int SIZE
secp256k1:
friend bool operator==(const CKey &a, const CKey &b)
const unsigned char * end() const
unsigned int size() const
Simple read-only vector-like interface.
bool IsValid() const
Check whether this private key is valid.
bool Sign(const uint256 &hash, std::vector< unsigned char > &vchSig, bool grind=true, uint32_t test_case=0) const
Create a DER-serialized signature.
bool fValid
see www.keylength.com script supports up to 75 for single byte push
CKey()
Construct an invalid private key.
CPrivKey GetPrivKey() const
Convert the private key to a CPrivKey (serialized OpenSSL private key data).
static const unsigned int COMPRESSED_SIZE
bool IsCompressed() const
Check whether the public key corresponding to this private key is (to be) compressed.
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
bool fCompressed
Whether the public key corresponding to this private key is (to be) compressed.
CPubKey GetPubKey() const
Compute the public key from a private key.
const std::byte * data() const
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
const unsigned char * begin() const
std::vector< unsigned char, secure_allocator< unsigned char > > keydata
The actual byte data.
bool VerifyPubKey(const CPubKey &vchPubKey) const
Verify thoroughly whether a private key and a public key match.
bool Load(const CPrivKey &privkey, const CPubKey &vchPubKey, bool fSkipCheck)
Load private key and check that public key matches.
static bool Check(const unsigned char *vch)
Check whether the 32-byte array pointed to by vch is valid keydata.
bool Derive(CKey &keyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode &cc) const
Derive BIP32 child key.
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
Create a compact signature (65 bytes), which allows reconstructing the used public key.
An encapsulated public key.
A Span is an object that can refer to a contiguous sequence of objects.
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
CPrivKey is a serialized private key, with all parameters included (SIZE bytes)
bool ECC_InitSanityCheck()
Check that required EC support is available at runtime.
void ECC_Start()
Initialize the elliptic curve support.
void ECC_Stop()
Deinitialize the elliptic curve support.
const unsigned int BIP32_EXTKEY_SIZE
unsigned char vchFingerprint[4]
CExtPubKey Neuter() const
bool Derive(CExtKey &out, unsigned int nChild) const
void Decode(const unsigned char code[BIP32_EXTKEY_SIZE])
void Encode(unsigned char code[BIP32_EXTKEY_SIZE]) const
friend bool operator==(const CExtKey &a, const CExtKey &b)
void SetSeed(Span< const std::byte > seed)