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

General SipHash-2-4 implementation. More...

#include <siphash.h>

Collaboration diagram for CSipHasher:
[legend]

Public Member Functions

 CSipHasher (uint64_t k0, uint64_t k1)
 Construct a SipHash calculator initialized with 128-bit key (k0, k1). More...
 
CSipHasherWrite (uint64_t data)
 Hash a 64-bit integer worth of data. More...
 
CSipHasherWrite (std::span< const unsigned char > data)
 Hash arbitrary bytes. More...
 
uint64_t Finalize () const
 Compute the 64-bit SipHash-2-4 of the data written so far. More...
 

Private Attributes

SipHashState m_state
 
uint64_t m_tmp {0}
 
uint8_t m_count {0}
 Only the low 8 bits of the input size matter. More...
 

Detailed Description

General SipHash-2-4 implementation.

Definition at line 26 of file siphash.h.

Constructor & Destructor Documentation

◆ CSipHasher()

CSipHasher::CSipHasher ( uint64_t  k0,
uint64_t  k1 
)

Construct a SipHash calculator initialized with 128-bit key (k0, k1).

Definition at line 22 of file siphash.cpp.

Member Function Documentation

◆ Finalize()

uint64_t CSipHasher::Finalize ( ) const

Compute the 64-bit SipHash-2-4 of the data written so far.

The object remains untouched.

Definition at line 73 of file siphash.cpp.

Here is the caller graph for this function:

◆ Write() [1/2]

CSipHasher & CSipHasher::Write ( std::span< const unsigned char >  data)

Hash arbitrary bytes.

Definition at line 44 of file siphash.cpp.

◆ Write() [2/2]

CSipHasher & 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 8 bytes. This function can only be used when a multiple of 8 bytes have been written so far.

Definition at line 24 of file siphash.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_count

uint8_t CSipHasher::m_count {0}
private

Only the low 8 bits of the input size matter.

Definition at line 30 of file siphash.h.

◆ m_state

SipHashState CSipHasher::m_state
private

Definition at line 28 of file siphash.h.

◆ m_tmp

uint64_t CSipHasher::m_tmp {0}
private

Definition at line 29 of file siphash.h.


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