<p>The reason is increasing the ability to precompute and/or cache those hash values once for the whole transaction (potentially allowing them to be used for many signatures).</p>
<p>In &quot;normal&quot; (<code>SIGHASH_ALL</code>) signatures, both the prevouts and sequence values of all inputs are committed to by the sighash. However:</p>
<ul>
<li>With sighash types that include <code>SIGHASH_ANYONECANPAY</code>, neither prevouts or sequence values are included.</li>
<li>With sighash types that include <code>SIGHASH_NONE</code> or <code>SIGHASH_SINGLE</code>, but not <code>SIGHASH_ANYONECANPAY</code>, the prevouts are included in the hash, but the sequence values are not.</li>
</ul>
<p>Splitting the two pieces of data up means that all sighashes can be computed based on just these two precomputed values, even when non-<code>SIGHASH_ALL</code> signatures occur.</p>

CC BY-SA 4.0
2023-09-29T11:20:23.907Z
2023-09-29T11:20:23.907Z
Pieter Wuille
<p>When a Segwit transaction is signed, among the many hashes that are calculated to create the data that is going to be signed, the hash of the concatenated [input + index] is calculated (hashPrevouts) and so is the hash of the concatenated [nSequence] numbers (hashSequence).</p>
<p>My question is why are those hashes computed separately, instead of just hashing the concatenation of the [inputs + indexes + Sequence number].</p>

<segregated-witness><signature>
Why are hashSequence and hashPrevouts computed separately?
mathboi
# Why are hashSequence and hashPrevouts computed separately?

(Asked by: username_0 on 2023-09-29)

When a Segwit transaction is signed, among the many hashes that are calculated to create the data that is going to be signed, the hash of the concatenated [input + index] is calculated (hashPrevouts) and so is the hash of the concatenated [nSequence] numbers (hashSequence).

My question is why are those hashes computed separately, instead of just hashing the concatenation of the [inputs + indexes + Sequence number].

**Tags:** segregated-witness, signature


---

## 1 answers

### Answer by username_1 on 2023-09-29. Score: 8 | Accepted answer

The reason is increasing the ability to precompute and/or cache those hash values once for the whole transaction (potentially allowing them to be used for many signatures).

In "normal" (`SIGHASH_ALL`) signatures, both the prevouts and sequence values of all inputs are committed to by the sighash. However:

* With sighash types that include `SIGHASH_ANYONECANPAY`, neither prevouts or sequence values are included.
* With sighash types that include `SIGHASH_NONE` or `SIGHASH_SINGLE`, but not `SIGHASH_ANYONECANPAY`, the prevouts are included in the hash, but the sequence values are not.

Splitting the two pieces of data up means that all sighashes can be computed based on just these two precomputed values, even when non-`SIGHASH_ALL` signatures occur.


---

