diff --git a/src/util/hasher.h b/src/util/hasher.h --- a/src/util/hasher.h +++ b/src/util/hasher.h @@ -98,4 +98,15 @@ } }; +class SaltedSipHasher { +private: + /** Salt */ + const uint64_t m_k0, m_k1; + +public: + SaltedSipHasher(); + + size_t operator()(const Span &script) const; +}; + #endif // BITCOIN_UTIL_HASHER_H diff --git a/src/util/hasher.cpp b/src/util/hasher.cpp --- a/src/util/hasher.cpp +++ b/src/util/hasher.cpp @@ -14,3 +14,13 @@ SaltedOutpointHasher::SaltedOutpointHasher() : k0(GetRand(std::numeric_limits::max())), k1(GetRand(std::numeric_limits::max())) {} + +SaltedSipHasher::SaltedSipHasher() + : m_k0(GetRand(std::numeric_limits::max())), + m_k1(GetRand(std::numeric_limits::max())) {} + +size_t SaltedSipHasher::operator()(const Span &script) const { + return CSipHasher(m_k0, m_k1) + .Write(script.data(), script.size()) + .Finalize(); +} diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -156,13 +156,6 @@ } }; -class KeyIDHasher { -public: - KeyIDHasher() {} - - size_t operator()(const CKeyID &id) const { return id.GetUint64(0); } -}; - /** * A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used * in a wallet. It contains the scripts and keys related to the scriptPubKeys it @@ -377,7 +370,7 @@ /* the HD chain data model (external chain counters) */ CHDChain m_hd_chain; - std::unordered_map m_inactive_hd_chains; + std::unordered_map m_inactive_hd_chains; /* HD derive new child key (on internal or external chain) */ void DeriveNewChildKey(WalletBatch &batch, CKeyMetadata &metadata,