CKey

An encapsulated private key.

Synopsis

Declared in <key.h>

class CKey;

Member Functions

NameDescription
CKey [constructor]Constructors
operator= Assignment operators
ComputeBIP324ECDHSecret Compute a BIP324-style ECDH shared secret.
ComputeKeyPair Compute a KeyPair
Derive Derive BIP32 child key.
EllSwiftCreate Create an ellswift-encoded public key for this key, with specified entropy.
GetPrivKey Convert the private key to a CPrivKey (serialized OpenSSL private key data). This is expensive.
GetPubKey Compute the public key from a private key. This is expensive.
IsCompressed Check whether the public key corresponding to this private key is (to be) compressed.
IsValid Check whether this private key is valid.
Load Load private key and check that public key matches.
MakeNewKey Generate a new private key using a cryptographic PRNG.
Set Initialize using begin and end iterators to byte data.
Sign Create a DER-serialized signature. The test_case parameter tweaks the deterministic nonce.
SignCompact Create a compact 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.
SignSchnorr Create a BIP-340 Schnorr signature, for the xonly-pubkey corresponding to *this, optionally tweaked by *merkle_root. Additional nonce entropy is provided through aux.
VerifyPubKey Verify thoroughly whether a private key and a public key match. This is done using a different mechanism than just regenerating it.
begin Iterator to the first key byte.
data Pointer to the first key byte, or nullptr if the key is invalid.
end Iterator past the last key byte.
size Number of key bytes, or 0 if the key is invalid.

Static Data Members

NameDescription
COMPRESSED_SIZE Size in bytes of a serialized private key whose public key is compressed.
SIZE secp256k1:

Friends

NameDescription
operator==Compare two private keys for equality of compression flag and key material.

Non-Member Functions

NameDescription
DecodeSecretDecode a WIF-encoded private key.
EncodeSecretEncode a private key in WIF format.
GenerateRandomKeyGenerate a new random private key.
MessageSignSign a message.