mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
partial bitcoin#19953: Implement BIP 340-342 validation
contains: - 9eb590894f15ff40806039bfd32972fbc260e30d
This commit is contained in:
parent
477157d40b
commit
fdc3c07554
10
src/hash.cpp
10
src/hash.cpp
@ -7,6 +7,7 @@
|
||||
#include <crypto/common.h>
|
||||
#include <crypto/hmac_sha512.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
inline uint32_t ROTL32(uint32_t x, int8_t r)
|
||||
{
|
||||
@ -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;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <uint256.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
typedef uint256 ChainCode;
|
||||
@ -241,4 +242,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
|
||||
|
Loading…
Reference in New Issue
Block a user