Bitcoin Core  0.19.99
P2P Digital Currency
siphash.h
Go to the documentation of this file.
1 // Copyright (c) 2016-2018 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.
4 
5 #ifndef BITCOIN_CRYPTO_SIPHASH_H
6 #define BITCOIN_CRYPTO_SIPHASH_H
7 
8 #include <stdint.h>
9 
10 #include <uint256.h>
11 
14 {
15 private:
16  uint64_t v[4];
17  uint64_t tmp;
18  int count;
19 
20 public:
22  CSipHasher(uint64_t k0, uint64_t k1);
27  CSipHasher& Write(uint64_t data);
29  CSipHasher& Write(const unsigned char* data, size_t size);
31  uint64_t Finalize() const;
32 };
33 
44 uint64_t SipHashUint256(uint64_t k0, uint64_t k1, const uint256& val);
45 uint64_t SipHashUint256Extra(uint64_t k0, uint64_t k1, const uint256& val, uint32_t extra);
46 
47 #endif // BITCOIN_CRYPTO_SIPHASH_H
uint64_t v[4]
Definition: siphash.h:16
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 ...
Definition: siphash.cpp:28
uint64_t SipHashUint256(uint64_t k0, uint64_t k1, const uint256 &val)
Optimized SipHash-2-4 implementation for uint256.
Definition: siphash.cpp:94
CSipHasher(uint64_t k0, uint64_t k1)
Construct a SipHash calculator initialized with 128-bit key (k0, k1)
Definition: siphash.cpp:18
int count
Definition: siphash.h:18
static const unsigned char k1[32]
uint64_t Finalize() const
Compute the 64-bit SipHash-2-4 of the data written so far.
Definition: siphash.cpp:76
uint64_t tmp
Definition: siphash.h:17
256-bit opaque blob.
Definition: uint256.h:121
SipHash-2-4.
Definition: siphash.h:13
uint64_t SipHashUint256Extra(uint64_t k0, uint64_t k1, const uint256 &val, uint32_t extra)
Definition: siphash.cpp:134