CKey::ComputeKeyPair

Compute a KeyPair

Synopsis

Declared in <key.h>

KeyPair
ComputeKeyPair(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

NameDescription
merkle_rootOptional Merkle root controlling BIP341 tweaking (see above).