An encapsulated secp256k1 private key.
More...
#include <key.h>
|
| CKey () |
| Construct an invalid private key.
|
|
template<typename T > |
void | Set (const T pbegin, const T pend, bool fCompressedIn) |
| Initialize using begin and end iterators to byte data.
|
|
unsigned int | size () const |
| Simple read-only vector-like interface.
|
|
const std::byte * | data () const |
|
const uint8_t * | begin () const |
|
const uint8_t * | end () const |
|
bool | IsValid () const |
| Check whether this private key is valid.
|
|
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 | Negate () |
| Negate private key.
|
|
CPrivKey | GetPrivKey () const |
| Convert the private key to a CPrivKey (serialized OpenSSL private key data).
|
|
CPubKey | GetPubKey () const |
| Compute the public key from a private key.
|
|
bool | SignECDSA (const uint256 &hash, std::vector< uint8_t > &vchSig, bool grind=true, uint32_t test_case=0) const |
| Create a DER-serialized ECDSA signature.
|
|
bool | SignSchnorr (const uint256 &hash, SchnorrSig &sig, uint32_t test_case=0) const |
| Create a Schnorr signature.
|
|
bool | SignSchnorr (const uint256 &hash, std::vector< uint8_t > &vchSig, uint32_t test_case=0) const |
|
bool | SignCompact (const uint256 &hash, std::vector< uint8_t > &vchSig) const |
| Create a compact ECDSA signature (65 bytes), which allows reconstructing the used public key.
|
|
bool | Derive (CKey &keyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode &cc) const |
| Derive BIP32 child key.
|
|
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.
|
|
An encapsulated secp256k1 private key.
Definition at line 28 of file key.h.
◆ CKey()
Construct an invalid private key.
Definition at line 60 of file key.h.
◆ begin()
const uint8_t * CKey::begin |
( |
| ) |
const |
|
inline |
Definition at line 93 of file key.h.
◆ Check()
Check whether the 32-byte array pointed to by vch is valid keydata.
Definition at line 179 of file key.cpp.
◆ data()
const std::byte * CKey::data |
( |
| ) |
const |
|
inline |
Definition at line 90 of file key.h.
◆ Derive()
Derive BIP32 child key.
Definition at line 352 of file key.cpp.
◆ end()
const uint8_t * CKey::end |
( |
| ) |
const |
|
inline |
Definition at line 94 of file key.h.
◆ GetPrivKey()
Convert the private key to a CPrivKey (serialized OpenSSL private key data).
This is expensive.
Definition at line 196 of file key.cpp.
◆ GetPubKey()
Compute the public key from a private key.
This is expensive.
Definition at line 210 of file key.cpp.
◆ IsCompressed()
bool CKey::IsCompressed |
( |
| ) |
const |
|
inline |
Check whether the public key corresponding to this private key is (to be) compressed.
Definition at line 101 of file key.h.
◆ IsValid()
bool CKey::IsValid |
( |
| ) |
const |
|
inline |
Check whether this private key is valid.
Definition at line 97 of file key.h.
◆ Load()
Load private key and check that public key matches.
Definition at line 336 of file key.cpp.
◆ MakeCompressedKey()
CKey CKey::MakeCompressedKey |
( |
| ) |
|
|
static |
Produce a valid compressed key.
Definition at line 466 of file key.cpp.
◆ MakeNewKey()
void CKey::MakeNewKey |
( |
bool |
fCompressed | ) |
|
Generate a new private key using a cryptographic PRNG.
Definition at line 183 of file key.cpp.
◆ MakeUncompressedKey()
CKey CKey::MakeUncompressedKey |
( |
| ) |
|
|
static |
Produce a valid uncompressed key.
Definition at line 470 of file key.cpp.
◆ Negate()
Negate private key.
Definition at line 191 of file key.cpp.
◆ Set()
void CKey::Set |
( |
const T |
pbegin, |
|
|
const T |
pend, |
|
|
bool |
fCompressedIn |
|
) |
| |
|
inline |
Initialize using begin and end iterators to byte data.
Definition at line 76 of file key.h.
◆ SignCompact()
Create a compact ECDSA signature (65 bytes), which allows reconstructing the used public key.
The format is one header byte, followed by two times 32 bytes for the serialized r and s values. The header byte: 0x1B = first key with even y, 0x1C = first key with odd y, 0x1D = second key with even y, 0x1E = second key with odd y, add 0x04 for compressed keys.
Definition at line 316 of file key.cpp.
◆ SignECDSA()
Create a DER-serialized ECDSA signature.
The test_case parameter tweaks the deterministic nonce.
Definition at line 242 of file key.cpp.
◆ SignSchnorr() [1/2]
Create a Schnorr signature.
The test_case parameter tweaks the deterministic nonce.
Definition at line 288 of file key.cpp.
◆ SignSchnorr() [2/2]
◆ size()
Simple read-only vector-like interface.
Definition at line 89 of file key.h.
◆ VerifyPubKey()
bool CKey::VerifyPubKey |
( |
const CPubKey & |
vchPubKey | ) |
const |
Verify thoroughly whether a private key and a public key match.
This is done using a different mechanism than just regenerating it. (An ECDSA signature is created then verified.)
Definition at line 302 of file key.cpp.
◆ operator==
Definition at line 69 of file key.h.
◆ COMPRESSED_SIZE
Definition at line 34 of file key.h.
◆ fCompressed
Whether the public key corresponding to this private key is (to be) compressed.
Definition at line 50 of file key.h.
◆ fValid
see www.keylength.com script supports up to 75 for single byte push
Whether this private key is valid. We check for correctness when modifying the key data, so fValid should always correspond to the actual state.
Definition at line 46 of file key.h.
◆ keydata
The actual byte data.
Definition at line 53 of file key.h.
◆ SIZE
secp256k1:
Definition at line 33 of file key.h.
The documentation for this class was generated from the following files: