aboutsummaryrefslogtreecommitdiff
path: root/src/hash.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hash.cpp')
-rw-r--r--src/hash.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/hash.cpp b/src/hash.cpp
index 83b90ae063..cc46043c2b 100644
--- a/src/hash.cpp
+++ b/src/hash.cpp
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2018 The Bitcoin Core developers
+// Copyright (c) 2013-2020 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -6,6 +6,7 @@
#include <crypto/common.h>
#include <crypto/hmac_sha512.h>
+#include <string>
inline uint32_t ROTL32(uint32_t x, int8_t r)
{
@@ -14,7 +15,7 @@ inline uint32_t ROTL32(uint32_t x, int8_t r)
unsigned int MurmurHash3(unsigned int nHashSeed, Span<const unsigned char> vDataToHash)
{
- // The following is MurmurHash3 (x86_32), see http://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp
+ // The following is MurmurHash3 (x86_32), see https://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp
uint32_t h1 = nHashSeed;
const uint32_t c1 = 0xcc9e2d51;
const uint32_t c2 = 0x1b873593;
@@ -84,3 +85,12 @@ uint256 SHA256Uint256(const uint256& input)
CSHA256().Write(input.begin(), 32).Finalize(result.begin());
return result;
}
+
+CHashWriter TaggedHash(const std::string& tag)
+{
+ CHashWriter writer(SER_GETHASH, 0);
+ uint256 taghash;
+ CSHA256().Write((const unsigned char*)tag.data(), tag.size()).Finalize(taghash.begin());
+ writer << taghash << taghash;
+ return writer;
+}