2022-12-24 23:49:50 +00:00
|
|
|
// Copyright (c) 2019-2022 The Bitcoin Core developers
|
2019-09-17 17:02:56 -04:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2022-06-09 16:26:55 +01:00
|
|
|
#include <crypto/siphash.h>
|
2019-09-17 17:02:56 -04:00
|
|
|
#include <random.h>
|
2022-06-09 16:26:55 +01:00
|
|
|
#include <span.h>
|
2019-09-17 17:02:56 -04:00
|
|
|
#include <util/hasher.h>
|
|
|
|
|
2022-01-31 19:32:59 +07:00
|
|
|
SaltedTxidHasher::SaltedTxidHasher() : k0(GetRand<uint64_t>()), k1(GetRand<uint64_t>()) {}
|
2019-09-17 17:02:56 -04:00
|
|
|
|
2023-02-01 18:52:11 -05:00
|
|
|
SaltedOutpointHasher::SaltedOutpointHasher(bool deterministic) :
|
|
|
|
k0(deterministic ? 0x8e819f2607a18de6 : GetRand<uint64_t>()),
|
|
|
|
k1(deterministic ? 0xf4020d2e3983b0eb : GetRand<uint64_t>())
|
|
|
|
{}
|
2019-09-17 19:29:59 -04:00
|
|
|
|
2022-01-31 19:32:59 +07:00
|
|
|
SaltedSipHasher::SaltedSipHasher() : m_k0(GetRand<uint64_t>()), m_k1(GetRand<uint64_t>()) {}
|
2019-09-17 19:29:59 -04:00
|
|
|
|
|
|
|
size_t SaltedSipHasher::operator()(const Span<const unsigned char>& script) const
|
|
|
|
{
|
2023-07-17 03:33:13 +02:00
|
|
|
return CSipHasher(m_k0, m_k1).Write(script).Finalize();
|
2019-09-17 19:29:59 -04:00
|
|
|
}
|