17#include <shared_mutex>
27 static constexpr unsigned char PADDING_ECDSA[32] = {
'E'};
28 static constexpr unsigned char PADDING_SCHNORR[32] = {
'S'};
35 LogPrintf(
"Using %zu MiB out of %zu MiB requested for signature cache, able to store %zu elements\n",
36 approx_size_bytes >> 20, max_size_bytes >> 20, num_elems);
53 std::shared_lock<std::shared_mutex> lock(
cs_sigcache);
59 std::unique_lock<std::shared_mutex> lock(
cs_sigcache);
An encapsulated public key.
const unsigned char * data() const
unsigned int size() const
Simple read-only vector-like interface to the pubkey data.
A hasher class for SHA-256.
void Finalize(unsigned char hash[OUTPUT_SIZE])
CSHA256 & Write(const unsigned char *data, size_t len)
bool VerifySchnorrSignature(Span< const unsigned char > sig, const XOnlyPubKey &pubkey, const uint256 &sighash) const override
SignatureCache & m_signature_cache
bool VerifyECDSASignature(const std::vector< unsigned char > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const override
std::pair< uint32_t, size_t > setup_bytes(size_t bytes)
setup_bytes is a convenience function which accounts for internal memory usage when deciding how many...
void insert(Element e)
insert loops at most depth_limit times trying to insert a hash at various locations in the table via ...
bool contains(const Element &e, const bool erase) const
contains iterates through the hash locations for a given element and checks to see if it is present.
virtual bool VerifySchnorrSignature(Span< const unsigned char > sig, const XOnlyPubKey &pubkey, const uint256 &sighash) const
virtual bool VerifyECDSASignature(const std::vector< unsigned char > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const
SignatureCache(size_t max_size_bytes)
CSHA256 m_salted_hasher_schnorr
void ComputeEntrySchnorr(uint256 &entry, const uint256 &hash, Span< const unsigned char > sig, const XOnlyPubKey &pubkey) const
void ComputeEntryECDSA(uint256 &entry, const uint256 &hash, const std::vector< unsigned char > &vchSig, const CPubKey &pubkey) const
std::shared_mutex cs_sigcache
CSHA256 m_salted_hasher_ecdsa
Entries are SHA256(nonce || 'E' or 'S' || 31 zero bytes || signature hash || public key || signature)...
bool Get(const uint256 &entry, const bool erase)
void Set(const uint256 &entry)
constexpr std::size_t size() const noexcept
constexpr C * data() const noexcept
static constexpr size_t size()
const unsigned char * data() const
constexpr unsigned char * begin()
uint256 GetRandHash() noexcept
Generate a random uint256.