An encapsulated private key.

Synopsis

Declared in <key.h>

class CKey;

Member Functions

Name

Description

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

Name

Description

COMPRESSED_SIZE

Size in bytes of a serialized private key whose public key is compressed.

SIZE

secp256k1:

Friends

Name

Description

operator==

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

Non-Member Functions

Name

Description

DecodeSecret

Decode a WIF‐encoded private key.

EncodeSecret

Encode a private key in WIF format.

GenerateRandomKey

Generate a new random private key.

MessageSign

Sign a message.

Created with MrDocs