Bitcoin Core 30.99.0
P2P Digital Currency
Public Member Functions | Private Attributes | List of all members
PresaltedSipHasher Class Reference

Optimized SipHash-2-4 implementation for uint256. More...

#include <siphash.h>

Collaboration diagram for PresaltedSipHasher:
[legend]

Public Member Functions

 PresaltedSipHasher (uint64_t k0, uint64_t k1) noexcept
 
uint64_t operator() (const uint256 &val) const noexcept
 Equivalent to CSipHasher(k0, k1).Write(val).Finalize(). More...
 
uint64_t operator() (const uint256 &val, uint32_t extra) const noexcept
 Equivalent to CSipHasher(k0, k1).Write(val).Write(extra).Finalize(), with extra encoded as 4 little-endian bytes. More...
 

Private Attributes

const SipHashState m_state
 

Detailed Description

Optimized SipHash-2-4 implementation for uint256.

This class caches the initial SipHash v[0..3] state derived from (k0, k1) and implements a specialized hashing path for uint256 values, with or without an extra 32-bit word. The internal state is immutable, so PresaltedSipHasher instances can be reused for multiple hashes with the same key.

Definition at line 55 of file siphash.h.

Constructor & Destructor Documentation

◆ PresaltedSipHasher()

PresaltedSipHasher::PresaltedSipHasher ( uint64_t  k0,
uint64_t  k1 
)
inlineexplicitnoexcept

Definition at line 60 of file siphash.h.

Member Function Documentation

◆ operator()() [1/2]

uint64_t PresaltedSipHasher::operator() ( const uint256 val) const
noexcept

Equivalent to CSipHasher(k0, k1).Write(val).Finalize().

Definition at line 91 of file siphash.cpp.

◆ operator()() [2/2]

uint64_t PresaltedSipHasher::operator() ( const uint256 val,
uint32_t  extra 
) const
noexcept

Equivalent to CSipHasher(k0, k1).Write(val).Write(extra).Finalize(), with extra encoded as 4 little-endian bytes.

Specialized implementation for efficiency.

Definition at line 128 of file siphash.cpp.

Member Data Documentation

◆ m_state

const SipHashState PresaltedSipHasher::m_state
private

Definition at line 57 of file siphash.h.


The documentation for this class was generated from the following files: