17#include <shared_mutex>
27 static constexpr unsigned char PADDING_ECDSA[32] = {
'E'};
28 static constexpr unsigned char PADDING_SCHNORR[32] = {
'S'};
34 const auto [num_elems, approx_size_bytes] =
setValid.setup_bytes(max_size_bytes);
35 LogInfo(
"Using %zu MiB out of %zu MiB requested for signature cache, able to store %zu elements",
36 approx_size_bytes >> 20, max_size_bytes >> 20, num_elems);
53 std::shared_lock<std::shared_mutex> lock(
cs_sigcache);
54 return setValid.contains(entry, erase);
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(std::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
virtual bool VerifySchnorrSignature(std::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)
void ComputeEntrySchnorr(uint256 &entry, const uint256 &hash, std::span< const unsigned char > sig, const XOnlyPubKey &pubkey) const
CSHA256 m_salted_hasher_schnorr
void ComputeEntryECDSA(uint256 &entry, const uint256 &hash, const std::vector< unsigned char > &vchSig, const CPubKey &pubkey) const
std::shared_mutex cs_sigcache
bool Get(const uint256 &entry, bool erase)
CSHA256 m_salted_hasher_ecdsa
Entries are SHA256(nonce || 'E' or 'S' || 31 zero bytes || signature hash || public key || signature)...
void Set(const uint256 &entry)
static constexpr size_t size()
const unsigned char * data() const
constexpr unsigned char * begin()
uint256 GetRandHash() noexcept
Generate a random uint256.