Add CKey::SignSchnorr function for BIP 340/341 signing

This commit is contained in:
Pieter Wuille
2021-02-08 00:15:51 -08:00
parent e77a2839b5
commit a91d532338
5 changed files with 85 additions and 0 deletions

View File

@@ -128,6 +128,18 @@ public:
*/
bool SignCompact(const uint256& hash, std::vector<unsigned char>& vchSig) const;
/**
* Create a BIP-340 Schnorr signature, for the xonly-pubkey corresponding to *this,
* optionally tweaked by *merkle_root. Additional nonce entropy can be provided through
* aux.
*
* When merkle_root is not nullptr, this results in a signature with a modified key as
* specified in BIP341:
* - If merkle_root->IsNull(): key + H_TapTweak(pubkey)*G
* - Otherwise: key + H_TapTweak(pubkey || *merkle_root)
*/
bool SignSchnorr(const uint256& hash, Span<unsigned char> sig, const uint256* merkle_root = nullptr, const uint256* aux = nullptr) const;
//! Derive BIP32 child key.
bool Derive(CKey& keyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode& cc) const;