aboutsummaryrefslogtreecommitdiff
path: root/src/hash.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2020-09-11 14:32:50 -0700
committerPieter Wuille <pieter@wuille.net>2020-10-12 02:06:32 -0700
commit9eb590894f15ff40806039bfd32972fbc260e30d (patch)
tree74ddd22d2750eb0de88176a108aa9a7ecc57fe6f /src/hash.h
parent450d2b23710ad296eede81339195376021ab5500 (diff)
downloadbitcoin-9eb590894f15ff40806039bfd32972fbc260e30d.tar.xz
Add TaggedHash function (BIP 340)
This adds the TaggedHash function as defined by BIP340 to the hash module, which is used in BIP340 and BIP341 to produce domain-separated hashes.
Diffstat (limited to 'src/hash.h')
-rw-r--r--src/hash.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/hash.h b/src/hash.h
index c16bbb48ce..6d876076ee 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -15,6 +15,7 @@
#include <uint256.h>
#include <version.h>
+#include <string>
#include <vector>
typedef uint256 ChainCode;
@@ -202,4 +203,12 @@ unsigned int MurmurHash3(unsigned int nHashSeed, Span<const unsigned char> vData
void BIP32Hash(const ChainCode &chainCode, unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64]);
+/** Return a CHashWriter primed for tagged hashes (as specified in BIP 340).
+ *
+ * The returned object will have SHA256(tag) written to it twice (= 64 bytes).
+ * A tagged hash can be computed by feeding the message into this object, and
+ * then calling CHashWriter::GetSHA256().
+ */
+CHashWriter TaggedHash(const std::string& tag);
+
#endif // BITCOIN_HASH_H