<p>The signature cache is basically a set of public key, message hash, and signature tuples. When there is a valid pubkey, message hash, and signature combination, all of those are hashed together with SHA256. This hash is then inserted into the signature cache. So the signature cache contains only the hashes of valid combinations. When verifying a signature, the pubkey, message hash, and signature are hashed together, and that resulting hash is looked up in the signature cache. If it is in there, then the signature is known to be valid and actual signature verification can be skipped.</p>
<p>The signature cache itself is not just a set. It is actually a Cuckoo cache which is a type of hash table that guarantees constant time lookup in the worst case.</p>

CC BY-SA 4.0
2021-05-24T16:58:03.430Z
2021-05-24T16:58:03.430Z
Ava Chow
<p>There is a signature cache in Bitcoin, which is used to cache the result of signature verification to avoid extra signature verification. What data is stored in the signature cache? Is it stored in the form of key-value pairs or other forms?
When a Bitcoin node performs block validation, how does it determine that the signature verification result of a transaction is already in the signature cache?</p>

<bitcoin-core><signature><cache>
What is the data structure of the signature cache in Bitcoin?
GoneV
# What is the data structure of the signature cache in Bitcoin?

(Asked by: username_0 on 2021-05-24)

There is a signature cache in Bitcoin, which is used to cache the result of signature verification to avoid extra signature verification. What data is stored in the signature cache? Is it stored in the form of key-value pairs or other forms?
When a Bitcoin node performs block validation, how does it determine that the signature verification result of a transaction is already in the signature cache?

**Tags:** bitcoin-core, signature, cache


---

## 1 answers

### Answer by username_1 on 2021-05-24. Score: 4 | Accepted answer

The signature cache is basically a set of public key, message hash, and signature tuples. When there is a valid pubkey, message hash, and signature combination, all of those are hashed together with SHA256. This hash is then inserted into the signature cache. So the signature cache contains only the hashes of valid combinations. When verifying a signature, the pubkey, message hash, and signature are hashed together, and that resulting hash is looked up in the signature cache. If it is in there, then the signature is known to be valid and actual signature verification can be skipped.

The signature cache itself is not just a set. It is actually a Cuckoo cache which is a type of hash table that guarantees constant time lookup in the worst case.


---

