1 // Copyright (c) 2013-2014 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 #include "crypto/hmac_sha512.h"
8 inline uint32_t ROTL32(uint32_t x, int8_t r)
10 return (x << r) | (x >> (32 - r));
13 unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector<unsigned char>& vDataToHash)
15 // The following is MurmurHash3 (x86_32), see http://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp
16 uint32_t h1 = nHashSeed;
17 if (vDataToHash.size() > 0)
19 const uint32_t c1 = 0xcc9e2d51;
20 const uint32_t c2 = 0x1b873593;
22 const int nblocks = vDataToHash.size() / 4;
26 const uint32_t* blocks = (const uint32_t*)(&vDataToHash[0] + nblocks * 4);
28 for (int i = -nblocks; i; i++) {
29 uint32_t k1 = blocks[i];
37 h1 = h1 * 5 + 0xe6546b64;
42 const uint8_t* tail = (const uint8_t*)(&vDataToHash[0] + nblocks * 4);
46 switch (vDataToHash.size() & 3) {
62 h1 ^= vDataToHash.size();
72 void BIP32Hash(const unsigned char chainCode[32], unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64])
75 num[0] = (nChild >> 24) & 0xFF;
76 num[1] = (nChild >> 16) & 0xFF;
77 num[2] = (nChild >> 8) & 0xFF;
78 num[3] = (nChild >> 0) & 0xFF;
79 CHMAC_SHA512(chainCode, 32).Write(&header, 1)