Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
sigcache.h
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2016 The Bitcoin Core developers
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef BITCOIN_SCRIPT_SIGCACHE_H
7#define BITCOIN_SCRIPT_SIGCACHE_H
8
10#include <util/hasher.h>
11
12#include <optional>
13#include <vector>
14
15// DoS prevention: limit cache size to 32MiB (over 1000000 entries on 64-bit
16// systems). Due to how we count cache size, actual memory usage is slightly
17// more (~32.25 MiB)
18static constexpr size_t DEFAULT_MAX_SIG_CACHE_BYTES{32 << 20};
19
20class CPubKey;
21
23private:
24 bool store;
25
26 bool IsCached(const std::vector<uint8_t> &vchSig, const CPubKey &vchPubKey,
27 const uint256 &sighash) const;
28
29public:
36
37 bool VerifySignature(const std::vector<uint8_t> &vchSig,
38 const CPubKey &vchPubKey,
39 const uint256 &sighash) const override;
40
42};
43
44[[nodiscard]] bool InitSignatureCache(size_t max_size_bytes);
45
46#endif // BITCOIN_SCRIPT_SIGCACHE_H
An encapsulated public key.
Definition pubkey.h:31
The basic transaction that is broadcasted on the network and contained in blocks.
friend class TestCachingTransactionSignatureChecker
Definition sigcache.h:41
bool VerifySignature(const std::vector< uint8_t > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const override
Definition sigcache.cpp:122
bool IsCached(const std::vector< uint8_t > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const
Definition sigcache.cpp:115
CachingTransactionSignatureChecker(const CTransaction *txToIn, unsigned int nInIn, const Amount amountIn, bool storeIn, PrecomputedTransactionData &txdataIn)
Definition sigcache.h:30
256-bit opaque blob.
Definition uint256.h:129
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
static constexpr size_t DEFAULT_MAX_SIG_CACHE_BYTES
Definition sigcache.h:18
bool InitSignatureCache(size_t max_size_bytes)
Definition sigcache.cpp:85
Precompute sighash midstate to avoid quadratic hashing.