Changeset View
Changeset View
Standalone View
Standalone View
src/crypto/siphash.h
// Copyright (c) 2016-2018 The Bitcoin Core developers | // Copyright (c) 2016-2018 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_CRYPTO_SIPHASH_H | #ifndef BITCOIN_CRYPTO_SIPHASH_H | ||||
#define BITCOIN_CRYPTO_SIPHASH_H | #define BITCOIN_CRYPTO_SIPHASH_H | ||||
#include <uint256.h> | #include <uint256.h> | ||||
#include <cstdint> | #include <cstdint> | ||||
/** SipHash-2-4 */ | /** SipHash-2-4 */ | ||||
class CSipHasher { | class CSipHasher { | ||||
private: | private: | ||||
uint64_t v[4]; | uint64_t v[4]; | ||||
uint64_t tmp; | uint64_t tmp; | ||||
int count; | // Only the low 8 bits of the input size matter. | ||||
uint8_t count; | |||||
public: | public: | ||||
/** Construct a SipHash calculator initialized with 128-bit key (k0, k1) */ | /** Construct a SipHash calculator initialized with 128-bit key (k0, k1) */ | ||||
CSipHasher(uint64_t k0, uint64_t k1); | CSipHasher(uint64_t k0, uint64_t k1); | ||||
/** | /** | ||||
* Hash a 64-bit integer worth of data. | * Hash a 64-bit integer worth of data. | ||||
* It is treated as if this was the little-endian interpretation of 8 bytes. | * 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 | * This function can only be used when a multiple of 8 bytes have been | ||||
Show All 25 Lines |