mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-14 06:32:33 +01:00
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:
20
src/pubkey.h
20
src/pubkey.h
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user