aboutsummaryrefslogtreecommitdiff
path: root/src/pubkey.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2020-09-11 14:33:30 -0700
committerPieter Wuille <pieter@wuille.net>2020-10-12 17:15:40 -0700
commit0664f5fe1f77f08d235aa3750b59428257b0b91d (patch)
treefe5078625aa3e9b7cf34b51e6eb66e8fccf0d74f /src/pubkey.h
parent5de246ca8159dcffaa4c136a60c8bfed2028e2ee (diff)
downloadbitcoin-0664f5fe1f77f08d235aa3750b59428257b0b91d.tar.xz
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.
Diffstat (limited to 'src/pubkey.h')
-rw-r--r--src/pubkey.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/pubkey.h b/src/pubkey.h
index cd1049f66f..1a818037d1 100644
--- a/src/pubkey.h
+++ b/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];