SipHash-2-4 */
| 11 | |
| 12 | /** SipHash-2-4 */ |
| 13 | class CSipHasher |
| 14 | { |
| 15 | private: |
| 16 | uint64_t v[4]; |
| 17 | uint64_t tmp; |
| 18 | uint8_t count; // Only the low 8 bits of the input size matter. |
| 19 | |
| 20 | public: |
| 21 | /** Construct a SipHash calculator initialized with 128-bit key (k0, k1) */ |
| 22 | CSipHasher(uint64_t k0, uint64_t k1); |
| 23 | /** Hash a 64-bit integer worth of data |
| 24 | * It is treated as if this was the little-endian interpretation of 8 bytes. |
| 25 | * This function can only be used when a multiple of 8 bytes have been written so far. |
| 26 | */ |
| 27 | CSipHasher& Write(uint64_t data); |
| 28 | /** Hash arbitrary bytes. */ |
| 29 | CSipHasher& Write(const unsigned char* data, size_t size); |
| 30 | /** Compute the 64-bit SipHash-2-4 of the data written so far. The object remains untouched. */ |
| 31 | uint64_t Finalize() const; |
| 32 | }; |
| 33 | |
| 34 | /** Optimized SipHash-2-4 implementation for uint256. |
| 35 | * |
no outgoing calls