Bitcoin Core 22.99.0
P2P Digital Currency
sigcache.h
Go to the documentation of this file.
1// Copyright (c) 2009-2010 Satoshi Nakamoto
2// Copyright (c) 2009-2020 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 <span.h>
11#include <util/hasher.h>
12
13#include <vector>
14
15// DoS prevention: limit cache size to 32MB (over 1000000 entries on 64-bit
16// systems). Due to how we count cache size, actual memory usage is slightly
17// more (~32.25 MB)
18static const unsigned int DEFAULT_MAX_SIG_CACHE_SIZE = 32;
19// Maximum sig cache size allowed
20static const int64_t MAX_MAX_SIG_CACHE_SIZE = 16384;
21
22class CPubKey;
23
25{
26private:
27 bool store;
28
29public:
30 CachingTransactionSignatureChecker(const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, bool storeIn, PrecomputedTransactionData& txdataIn) : TransactionSignatureChecker(txToIn, nInIn, amountIn, txdataIn, MissingDataBehavior::ASSERT_FAIL), store(storeIn) {}
31
32 bool VerifyECDSASignature(const std::vector<unsigned char>& vchSig, const CPubKey& vchPubKey, const uint256& sighash) const override;
33 bool VerifySchnorrSignature(Span<const unsigned char> sig, const XOnlyPubKey& pubkey, const uint256& sighash) const override;
34};
35
37
38#endif // BITCOIN_SCRIPT_SIGCACHE_H
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
An encapsulated public key.
Definition: pubkey.h:33
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:260
bool VerifySchnorrSignature(Span< const unsigned char > sig, const XOnlyPubKey &pubkey, const uint256 &sighash) const override
Definition: sigcache.cpp:118
CachingTransactionSignatureChecker(const CTransaction *txToIn, unsigned int nInIn, const CAmount &amountIn, bool storeIn, PrecomputedTransactionData &txdataIn)
Definition: sigcache.h:30
bool VerifyECDSASignature(const std::vector< unsigned char > &vchSig, const CPubKey &vchPubKey, const uint256 &sighash) const override
Definition: sigcache.cpp:105
A Span is an object that can refer to a contiguous sequence of objects.
Definition: span.h:93
256-bit opaque blob.
Definition: uint256.h:124
MissingDataBehavior
Enum to specify what *TransactionSignatureChecker's behavior should be when dealing with missing tran...
Definition: interpreter.h:268
@ ASSERT_FAIL
Abort execution through assertion failure (for consensus code)
static unsigned const char sighash[]
Definition: sighash.json.h:2
void InitSignatureCache()
Definition: sigcache.cpp:95
static const unsigned int DEFAULT_MAX_SIG_CACHE_SIZE
Definition: sigcache.h:18
static const int64_t MAX_MAX_SIG_CACHE_SIZE
Definition: sigcache.h:20