5#ifndef BITCOIN_CRYPTO_SIPHASH_H
6#define BITCOIN_CRYPTO_SIPHASH_H
20 static constexpr uint64_t
C0{0x736f6d6570736575},
C1{0x646f72616e646f6d},
C2{0x6c7967656e657261},
C3{0x7465646279746573};
60 const uint64_t d0{
data.GetUint64(0)}, d1{
data.GetUint64(1)}, d2{
data.GetUint64(2)}, d3{
data.GetUint64(3)};
186 ALWAYS_INLINE uint64_t
Hash(
const uint256& hash, uint64_t extra)
const noexcept
General SipHash-2-4 implementation.
uint8_t m_count
Only the low 8 bits of the input size matter.
uint64_t Finalize() const
Compute the 64-bit SipHash-2-4 of the data written so far.
CSipHasher(uint64_t k0, uint64_t k1)
Construct a SipHash calculator initialized with 128-bit key (k0, k1).
CSipHasher & Write(uint64_t data)
Hash a 64-bit integer worth of data.
Optimized SipHash-2-4 implementation for uint256.
uint64_t operator()(const uint256 &val) const noexcept
Equivalent to CSipHasher(k0, k1).Write(val).Finalize().
PresaltedSipHasher(uint64_t k0, uint64_t k1) noexcept
const SipHashState m_state
Shared SipHash state (v0..v3) with its round, compression, and finalization primitives.
ALWAYS_INLINE SipHashState(uint64_t k0, uint64_t k1) noexcept
Construct a SipHashState initialized with the specified key.
ALWAYS_INLINE SipHashState & Compress1Jumbo(const uint256 &data) noexcept
Mutably compress one jumbo block into this state, with 1 SipRound.
ALWAYS_INLINE SipHashState Copy() const noexcept
Construct a copy of this state.
static constexpr uint64_t FINALIZER
SipHash v2 finalizer constant.
ALWAYS_INLINE uint64_t Finalize3U() noexcept
Mutably finalize this state with 3 SipRounds using the unpadded finalizer, and return the resulting h...
static constexpr uint64_t C3
ALWAYS_INLINE void SipRound() noexcept
Mutably perform one SipRound on this state.
static constexpr uint64_t FINALIZER_UNPADDED
SipHash custom unpadded finalizer constant.
ALWAYS_INLINE uint64_t Finalize4() noexcept
Mutably finalize this state with 4 SipRounds, and return the resulting hash.
ALWAYS_INLINE SipHashState(uint64_t v0, uint64_t v1, uint64_t v2, uint64_t v3) noexcept
Construct a SipHashState with the specified values as state.
static constexpr uint64_t C2
static constexpr uint64_t C1
ALWAYS_INLINE SipHashState & Compress1(uint64_t data) noexcept
Mutably compress one block into this state, with 1 SipRound.
uint64_t m_v0
State variables.
ALWAYS_INLINE SipHashState & Compress2(uint64_t data) noexcept
Mutably compress one block into this state, with 2 SipRounds.
static constexpr uint64_t C0
SipHash initialization constants.
A custom weaker variant of SipHash-1-3 without padding, and supporting "jumbo" inputs.
SipHasher13UJ & Write(uint64_t data) noexcept
Hash a normal 64-bit value.
ALWAYS_INLINE uint64_t Hash(const uint256 &hash, uint64_t extra) const noexcept
Hash a jumbo block followed by a normal block after the data written so far, and finalize without mod...
SipHasher13UJ & WriteJumbo(const uint256 &hash) noexcept
Hash a 256-bit value as a jumbo block.
uint64_t Finalize() const noexcept
Compute the 64-bit SipHash-1-3-UJ of the data written so far.
SipHasher13UJ(uint64_t k0, uint64_t k1) noexcept
Construct a SipHash-1-3-UJ calculator initialized with 128-bit key (k0, k1).
ALWAYS_INLINE uint64_t Hash(const uint256 &hash) const noexcept
Hash a jumbo block after the data written so far and finalize without modifying the object.
static const PrecomputedData data
Precomputed COutPoint and CCoins values.
static SECP256K1_INLINE uint64_t rotl(const uint64_t x, int k)