Line data Source code
1 : // Copyright (c) 2019-present 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 <util/hasher.h>
6 :
7 : #include <crypto/siphash.h>
8 : #include <random.h>
9 :
10 422 : SaltedUint256Hasher::SaltedUint256Hasher() : m_hasher{
11 211 : FastRandomContext().rand64(),
12 422 : FastRandomContext().rand64()}
13 211 : {}
14 :
15 60026 : SaltedTxidHasher::SaltedTxidHasher() : m_hasher{
16 30013 : FastRandomContext().rand64(),
17 60026 : FastRandomContext().rand64()}
18 30013 : {}
19 :
20 38594 : SaltedWtxidHasher::SaltedWtxidHasher() : m_hasher{
21 19297 : FastRandomContext().rand64(),
22 38594 : FastRandomContext().rand64()}
23 19297 : {}
24 :
25 2054 : SaltedOutpointHasher::SaltedOutpointHasher() : m_hasher{
26 1027 : FastRandomContext().rand64(),
27 2054 : FastRandomContext().rand64()}
28 1027 : {}
29 :
30 167 : SaltedSipHasher::SaltedSipHasher() :
31 167 : m_k0{FastRandomContext().rand64()},
32 167 : m_k1{FastRandomContext().rand64()}
33 167 : {}
34 :
35 453689 : size_t SaltedSipHasher::operator()(const std::span<const unsigned char>& script) const
36 : {
37 453689 : return CSipHasher(m_k0, m_k1).Write(script).Finalize();
38 : }
|