Support for Schnorr signatures and integration in SignatureCheckers (BIP 340)

This enables the schnorrsig module in libsecp256k1, adds the relevant types
and functions to src/pubkey, as well as in higher-level `SignatureChecker`
classes. The (verification side of the) BIP340 test vectors is also added.
This commit is contained in:
Pieter Wuille
2020-09-11 14:33:30 -07:00
parent 5de246ca81
commit 0664f5fe1f
14 changed files with 165 additions and 13 deletions

View File

@@ -9,6 +9,7 @@
#include <hash.h>
#include <serialize.h>
#include <span.h>
#include <uint256.h>
#include <stdexcept>
@@ -206,6 +207,25 @@ public:
bool Derive(CPubKey& pubkeyChild, ChainCode &ccChild, unsigned int nChild, const ChainCode& cc) const;
};
class XOnlyPubKey
{
private:
uint256 m_keydata;
public:
/** Construct an x-only pubkey from exactly 32 bytes. */
XOnlyPubKey(Span<const unsigned char> bytes);
/** Verify a Schnorr signature against this public key.
*
* sigbytes must be exactly 64 bytes.
*/
bool VerifySchnorr(const uint256& msg, Span<const unsigned char> sigbytes) const;
const unsigned char& operator[](int pos) const { return *(m_keydata.begin() + pos); }
size_t size() const { return m_keydata.size(); }
};
struct CExtPubKey {
unsigned char nDepth;
unsigned char vchFingerprint[4];