12 #include <boost/test/unit_test.hpp>
20 #define T(expected, seed, data) BOOST_CHECK_EQUAL(MurmurHash3(seed, ParseHex(data)), expected)
30 T(0x00000000, 0x00000000,
"");
31 T(0x6a396f08, 0xFBA4C795,
"");
32 T(0x81f16f39, 0xffffffff,
"");
34 T(0x514e28b7, 0x00000000,
"00");
35 T(0xea3f0b17, 0xFBA4C795,
"00");
36 T(0xfd6cf10d, 0x00000000,
"ff");
38 T(0x16c6b7ab, 0x00000000,
"0011");
39 T(0x8eb51c3d, 0x00000000,
"001122");
40 T(0xb4471bf8, 0x00000000,
"00112233");
41 T(0xe2301fa8, 0x00000000,
"0011223344");
42 T(0xfc2e4a15, 0x00000000,
"001122334455");
43 T(0xb074502c, 0x00000000,
"00112233445566");
44 T(0x8034d2a0, 0x00000000,
"0011223344556677");
45 T(0xb4698def, 0x00000000,
"001122334455667788");
64 0x726fdb47dd0e0e31, 0x74f839c593dc67fd, 0x0d6c8009d9a94f5a, 0x85676696d7fb7e2d,
65 0xcf2794e0277187b7, 0x18765564cd99a68d, 0xcbc9466e58fee3ce, 0xab0200f58b01d137,
66 0x93f5f5799a932462, 0x9e0082df0ba9e4b0, 0x7a5dbbc594ddb9f3, 0xf4b32f46226bada7,
67 0x751e8fbc860ee5fb, 0x14ea5627c0843d90, 0xf723ca908e7af2ee, 0xa129ca6149be45e5,
68 0x3f2acc7f57c29bdb, 0x699ae9f52cbe4794, 0x4bc1b3f0968dd39c, 0xbb6dc91da77961bd,
69 0xbed65cf21aa2ee98, 0xd0f2cbb02e3b67c7, 0x93536795e3a33e88, 0xa80c038ccd5ccec8,
70 0xb8ad50c6f649af94, 0xbce192de8a85b8ea, 0x17d835b85bbb15f3, 0x2f2e6163076bcfad,
71 0xde4daaaca71dc9a5, 0xa6a2506687956571, 0xad87a3535c49ef28, 0x32d892fad841c342,
72 0x7127512f72f27cce, 0xa7f32346f95978e3, 0x12e0b01abb051238, 0x15e034d40fa197ae,
73 0x314dffbe0815a3b4, 0x027990f029623981, 0xcadcd4e59ef40c4d, 0x9abfd8766a33735c,
74 0x0e3ea96b5304a7d0, 0xad0c42d6fc585992, 0x187306c89bc215a9, 0xd4a60abcf3792b95,
75 0xf935451de4f21df2, 0xa9538f0419755787, 0xdb9acddff56ca510, 0xd06c98cd5c0975eb,
76 0xe612a3cb9ecba951, 0xc766e62cfcadaf96, 0xee64435a9752fe72, 0xa192d576b245165a,
77 0x0a8787bf8ecb74b2, 0x81b3e73d20b49b6f, 0x7fa8220ba3b2ecea, 0x245731c13ca42499,
78 0xb78dbfaf3a8d83bd, 0xea1ad565322a1a0b, 0x60e61c23a3795013, 0x6606d7e446282b93,
79 0x6ca4ecb15c5f91e1, 0x9f626da15c9625f3, 0xe51b38608ef25f57, 0x958a324ceb064572
84 CSipHasher hasher(0x0706050403020100ULL, 0x0F0E0D0C0B0A0908ULL);
86 static const unsigned char t0[1] = {0};
89 static const unsigned char t1[7] = {1,2,3,4,5,6,7};
92 hasher.
Write(0x0F0E0D0C0B0A0908ULL);
94 static const unsigned char t2[2] = {16,17};
97 static const unsigned char t3[9] = {18,19,20,21,22,23,24,25,26};
100 static const unsigned char t4[5] = {27,28,29,30,31};
103 hasher.
Write(0x2726252423222120ULL);
105 hasher.
Write(0x2F2E2D2C2B2A2928ULL);
111 CSipHasher hasher2(0x0706050403020100ULL, 0x0F0E0D0C0B0A0908ULL);
115 hasher2.
Write(&x, 1);
118 CSipHasher hasher3(0x0706050403020100ULL, 0x0F0E0D0C0B0A0908ULL);
122 hasher3.
Write(uint64_t(x)|(uint64_t(x+1)<<8)|(uint64_t(x+2)<<16)|(uint64_t(x+3)<<24)|
123 (uint64_t(x+4)<<32)|(uint64_t(x+5)<<40)|(uint64_t(x+6)<<48)|(uint64_t(x+7)<<56));
132 for (
int i = 0; i < 16; ++i) {
133 uint64_t k1 = ctx.
rand64();
134 uint64_t k2 = ctx.
rand64();
136 uint32_t n = ctx.
rand32();
A writer stream (for serialization) that computes a 256-bit hash.
uint64_t Finalize() const
Compute the 64-bit SipHash-2-4 of the data written so far.
CSipHasher & Write(uint64_t data)
Hash a 64-bit integer worth of data It is treated as if this was the little-endian interpretation of ...
The basic transaction that is broadcasted on the network and contained in blocks.
uint32_t rand32() noexcept
Generate a random 32-bit integer.
uint64_t rand64() noexcept
Generate a random 64-bit integer.
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(murmurhash3)
uint64_t siphash_4_2_testvec[]
#define T(expected, seed, data)
#define BOOST_FIXTURE_TEST_SUITE(a, b)
#define BOOST_CHECK_EQUAL(v1, v2)
uint256 GetRandHash() noexcept
uint64_t SipHashUint256Extra(uint64_t k0, uint64_t k1, const uint256 &val, uint32_t extra)
uint64_t SipHashUint256(uint64_t k0, uint64_t k1, const uint256 &val)
Optimized SipHash-2-4 implementation for uint256.
uint256 uint256S(const char *str)