Bitcoin Core
24.1.0
P2P Digital Currency
src
util
hasher.cpp
Go to the documentation of this file.
1
// Copyright (c) 2019 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
#include <
crypto/siphash.h
>
6
#include <random.h>
7
#include <
span.h
>
8
#include <
util/hasher.h
>
9
10
SaltedTxidHasher::SaltedTxidHasher
() : k0(
GetRand
<uint64_t>()),
k1
(
GetRand
<uint64_t>()) {}
11
12
SaltedOutpointHasher::SaltedOutpointHasher
() : k0(
GetRand
<uint64_t>()),
k1
(
GetRand
<uint64_t>()) {}
13
14
SaltedSipHasher::SaltedSipHasher
() : m_k0(
GetRand
<uint64_t>()), m_k1(
GetRand
<uint64_t>()) {}
15
16
size_t
SaltedSipHasher::operator()
(
const
Span<const unsigned char>
& script)
const
17
{
18
return
CSipHasher
(
m_k0
,
m_k1
).
Write
(script.
data
(), script.
size
()).Finalize();
19
}
CSipHasher::Write
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 ...
Definition:
siphash.cpp:28
span.h
SaltedSipHasher::operator()
size_t operator()(const Span< const unsigned char > &script) const
Definition:
hasher.cpp:16
siphash.h
Span::size
constexpr std::size_t size() const noexcept
Definition:
span.h:186
SaltedOutpointHasher::SaltedOutpointHasher
SaltedOutpointHasher()
Definition:
hasher.cpp:12
GetRand
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition:
random.h:79
SaltedSipHasher::m_k0
const uint64_t m_k0
Salt.
Definition:
hasher.h:93
SaltedTxidHasher::SaltedTxidHasher
SaltedTxidHasher()
Definition:
hasher.cpp:10
SaltedSipHasher::m_k1
const uint64_t m_k1
Definition:
hasher.h:93
k1
static const unsigned char k1[32]
Definition:
chacha_poly_aead.cpp:19
hasher.h
Span::data
constexpr C * data() const noexcept
Definition:
span.h:173
CSipHasher
SipHash-2-4.
Definition:
siphash.h:13
Span< const unsigned char >
SaltedSipHasher::SaltedSipHasher
SaltedSipHasher()
Definition:
hasher.cpp:14
Generated on Tue May 16 2023 12:00:00 for Bitcoin Core by
1.8.14