Bitcoin ABC  0.24.7
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 <uint256.h>
9 
10 #include <cstdint>
11 
13 class CSipHasher {
14 private:
15  uint64_t v[4];
16  uint64_t tmp;
17  // Only the low 8 bits of the input size matter.
18  uint8_t count;
19 
20 public:
22  CSipHasher(uint64_t k0, uint64_t k1);
29  CSipHasher &Write(uint64_t data);
31  CSipHasher &Write(const uint8_t *data, size_t size);
34  uint64_t Finalize() const;
35 };
36 
47 uint64_t SipHashUint256(uint64_t k0, uint64_t k1, const uint256 &val);
48 uint64_t SipHashUint256Extra(uint64_t k0, uint64_t k1, const uint256 &val,
49  uint32_t extra);
50 
51 #endif // BITCOIN_CRYPTO_SIPHASH_H
k1
static const uint8_t k1[32]
Definition: chacha_poly_aead.cpp:20
CSipHasher::CSipHasher
CSipHasher(uint64_t k0, uint64_t k1)
Construct a SipHash calculator initialized with 128-bit key (k0, k1)
Definition: siphash.cpp:27
uint256.h
CSipHasher
SipHash-2-4.
Definition: siphash.h:13
SipHashUint256
uint64_t SipHashUint256(uint64_t k0, uint64_t k1, const uint256 &val)
Optimized SipHash-2-4 implementation for uint256.
Definition: siphash.cpp:99
CSipHasher::count
uint8_t count
Definition: siphash.h:18
CSipHasher::Finalize
uint64_t Finalize() const
Compute the 64-bit SipHash-2-4 of the data written so far.
Definition: siphash.cpp:82
uint256
256-bit opaque blob.
Definition: uint256.h:127
SipHashUint256Extra
uint64_t SipHashUint256Extra(uint64_t k0, uint64_t k1, const uint256 &val, uint32_t extra)
Definition: siphash.cpp:138
CSipHasher::tmp
uint64_t tmp
Definition: siphash.h:16
CSipHasher::v
uint64_t v[4]
Definition: siphash.h:15
CSipHasher::Write
CSipHasher & Write(uint64_t data)
Hash a 64-bit integer worth of data.
Definition: siphash.cpp:36