diff options
Diffstat (limited to 'src/hash.cpp')
-rw-r--r-- | src/hash.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/hash.cpp b/src/hash.cpp index 218607a6fd..2cca06ae23 100644 --- a/src/hash.cpp +++ b/src/hash.cpp @@ -1,3 +1,7 @@ +// Copyright (c) 2013-2014 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #include "hash.h" inline uint32_t ROTL32(uint32_t x, int8_t r) @@ -63,3 +67,16 @@ unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector<unsigned char return h1; } + +void BIP32Hash(const unsigned char chainCode[32], unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64]) +{ + unsigned char num[4]; + num[0] = (nChild >> 24) & 0xFF; + num[1] = (nChild >> 16) & 0xFF; + num[2] = (nChild >> 8) & 0xFF; + num[3] = (nChild >> 0) & 0xFF; + CHMAC_SHA512(chainCode, 32).Write(&header, 1) + .Write(data, 32) + .Write(num, 4) + .Finalize(output); +} |