[#CKey]
= CKey
:mrdocs:

An encapsulated private key&period;

== Synopsis

Declared in `&lt;key&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class CKey;
----

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:CKey/2constructor-09.adoc[`CKey`]         [.small]#[constructor]#
| Constructors
| xref:CKey/operator_assign-08.adoc[`operator&equals;`] 
| Assignment operators
| xref:CKey/ComputeBIP324ECDHSecret.adoc[`ComputeBIP324ECDHSecret`] 
| Compute a BIP324&hyphen;style ECDH shared secret&period;
| xref:CKey/ComputeKeyPair.adoc[`ComputeKeyPair`] 
| Compute a KeyPair
| xref:CKey/Derive.adoc[`Derive`] 
| Derive BIP32 child key&period;
| xref:CKey/EllSwiftCreate.adoc[`EllSwiftCreate`] 
| Create an ellswift&hyphen;encoded public key for this key, with specified entropy&period;
| xref:CKey/GetPrivKey.adoc[`GetPrivKey`] 
| Convert the private key to a CPrivKey (serialized OpenSSL private key data)&period; This is expensive&period;
| xref:CKey/GetPubKey.adoc[`GetPubKey`] 
| Compute the public key from a private key&period; This is expensive&period;
| xref:CKey/IsCompressed.adoc[`IsCompressed`] 
| Check whether the public key corresponding to this private key is (to be) compressed&period;
| xref:CKey/IsValid.adoc[`IsValid`] 
| Check whether this private key is valid&period;
| xref:CKey/Load.adoc[`Load`] 
| Load private key and check that public key matches&period;
| xref:CKey/MakeNewKey.adoc[`MakeNewKey`] 
| Generate a new private key using a cryptographic PRNG&period;
| xref:CKey/Set.adoc[`Set`] 
| Initialize using begin and end iterators to byte data&period;
| xref:CKey/Sign.adoc[`Sign`] 
| Create a DER&hyphen;serialized signature&period; The test&lowbar;case parameter tweaks the deterministic nonce&period;
| xref:CKey/SignCompact.adoc[`SignCompact`] 
| Create a compact signature (65 bytes), which allows reconstructing the used public key&period; The format is one header byte, followed by two times 32 bytes for the serialized r and s values&period; The header byte&colon; 0x1B &equals; first key with even y, 0x1C &equals; first key with odd y, 0x1D &equals; second key with even y, 0x1E &equals; second key with odd y, add 0x04 for compressed keys&period;
| xref:CKey/SignSchnorr.adoc[`SignSchnorr`] 
| Create a BIP&hyphen;340 Schnorr signature, for the xonly&hyphen;pubkey corresponding to &ast;this, optionally tweaked by &ast;merkle&lowbar;root&period; Additional nonce entropy is provided through aux&period;
| xref:CKey/VerifyPubKey.adoc[`VerifyPubKey`] 
| Verify thoroughly whether a private key and a public key match&period; This is done using a different mechanism than just regenerating it&period;
| xref:CKey/begin.adoc[`begin`] 
| Iterator to the first key byte&period;
| xref:CKey/data.adoc[`data`] 
| Pointer to the first key byte, or nullptr if the key is invalid&period;
| xref:CKey/end.adoc[`end`] 
| Iterator past the last key byte&period;
| xref:CKey/size-09.adoc[`size`] 
| Number of key bytes, or 0 if the key is invalid&period;
|===


== Static Data Members

[cols="1,4"]
|===
| Name| Description
| xref:CKey/COMPRESSED_SIZE.adoc[`COMPRESSED&lowbar;SIZE`] 
| Size in bytes of a serialized private key whose public key is compressed&period;
| xref:CKey/SIZE-0d.adoc[`SIZE`] 
| secp256k1&colon;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:operator_eq-0e7.adoc[operator&equals;&equals;]`
| Compare two private keys for equality of compression flag and key material&period;
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:DecodeSecret.adoc[`DecodeSecret`]
| Decode a WIF&hyphen;encoded private key&period;
| xref:EncodeSecret.adoc[`EncodeSecret`]
| Encode a private key in WIF format&period;
| xref:GenerateRandomKey.adoc[`GenerateRandomKey`]
| Generate a new random private key&period;
| xref:MessageSign.adoc[`MessageSign`]
| Sign a message&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
