[#CKey-ComputeKeyPair] = xref:CKey.adoc[CKey]::ComputeKeyPair :relfileprefix: ../ :mrdocs: Compute a KeyPair == Synopsis Declared in `<key.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:KeyPair.adoc[KeyPair] ComputeKeyPair(xref:uint256.adoc[uint256] const* merkle_root) const; ---- == Description Wraps a `secp256k1_keypair` type. `merkle_root` is used to optionally perform tweaking of the internal key, as specified in BIP341: * If merkle_root == nullptr: no tweaking is done, use the internal key directly (this is used for signatures in BIP342 script). * If merkle_root‐>IsNull(): tweak the internal key with H_TapTweak(pubkey) (this is used for key path spending when no scripts are present). * Otherwise: tweak the internal key with H_TapTweak(pubkey || *merkle_root) (this is used for key path spending with the Merkle root of the script tree). == Return Value The computed key pair. == Parameters [cols="1,4"] |=== | Name| Description | *merkle_root* | Optional Merkle root controlling BIP341 tweaking (see above). |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#