]> Git Repo - VerusCoin.git/blobdiff - src/hash.cpp
Merge pull request #5360
[VerusCoin.git] / src / hash.cpp
index 218607a6fdfc9af9947ea5791edb9ffcf1c7e2c3..20d5d217778f2beb5f007d6e3e36a8175c69ea10 100644 (file)
@@ -1,4 +1,11 @@
+// Copyright (c) 2013-2014 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
 #include "hash.h"
+#include "crypto/common.h"
+#include "crypto/hmac_sha512.h"
+
 
 inline uint32_t ROTL32(uint32_t x, int8_t r)
 {
@@ -18,10 +25,10 @@ unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector<unsigned char
 
         //----------
         // body
-        const uint32_t* blocks = (const uint32_t*)(&vDataToHash[0] + nblocks * 4);
+        const uint8_t* blocks = &vDataToHash[0] + nblocks * 4;
 
         for (int i = -nblocks; i; i++) {
-            uint32_t k1 = blocks[i];
+            uint32_t k1 = ReadLE32(blocks + i*4);
 
             k1 *= c1;
             k1 = ROTL32(k1, 15);
@@ -63,3 +70,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);
+}
This page took 0.021176 seconds and 4 git commands to generate.