[#KeyPair]
= KeyPair
:mrdocs:

KeyPair

== Synopsis

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

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

== Description

Wraps a `secp256k1&lowbar;keypair` type, an opaque data structure for holding a secret and public key&period; This is intended for BIP340 keys and allows us to easily determine if the secret key needs to be negated by checking the parity of the public key&period; This class primarily intended for passing secret keys to libsecp256k1 functions expecting a `secp256k1&lowbar;keypair`&period; For all other cases, CKey should be preferred&period;

A KeyPair can be created from a CKey with an optional merkle&lowbar;root tweak (per BIP342)&period; See CKey&colon;&colon;ComputeKeyPair for more details&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:KeyPair/2constructor-051.adoc[`KeyPair`]         [.small]#[constructor]#
| Constructors
| xref:KeyPair/operator_assign-00.adoc[`operator&equals;`] 
| Assignment operators
| xref:KeyPair/IsValid.adoc[`IsValid`] 
| Check whether this keypair is valid&period;
| xref:KeyPair/SignSchnorr.adoc[`SignSchnorr`] 
| Create a BIP&hyphen;340 Schnorr signature using this key pair&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:CKey/ComputeKeyPair.adoc[CKey::ComputeKeyPair]`
| Compute a KeyPair
|===


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