The Witness Overview
The Witness (Segregated Witness)
The Witness is a separate data structure in a Bitcoin transaction introduced by the SegWit upgrade in 2017. It contains the cryptographic proofs (signatures and public keys) required to spend an input, but it is stored outside the main part of the transaction.
1. Why "Segregated"?
The word "Segregated" means "set apart." In legacy transactions, the signature is stored in the ScriptSig, which is part of the data hashed to create the TXID.
-
The Problem: If a signature was slightly modified, the TXID would change.
-
The Solution: Move the signature to a separate area called the Witness.
2. Segregation Benefits
By separating the witness data:
-
Fixes Malleability: Changing the signature in the witness does not change the TXID.
-
Increased Capacity: Witness data is "weighted" differently, effectively allowing for blocks up to 4MB in size.
-
Future Upgrades: It is easier to introduce new signature types (like Schnorr) into the witness than into the legacy ScriptSig.
3. The Witness Stack
Unlike ScriptSig, which is a single script, the Witness is a stack of items.
-
Item 1: The Signature.
-
Item 2: The Public Key. Each item is a simple byte array, making it much easier for nodes to parse and verify.
4. Relationship with Inputs
Every input in a SegWit transaction has its own corresponding witness. Even if an input doesn't need a signature (like a certain smart contract), it still has a "Witness" area that can be empty.
| Property | Value |
|---|---|
| Role | Segregated Proof of Ownership |
| Location | End of the Transaction |
| Impact on TXID | None |
| Nickname | The Witness |
In the next section, we will look at how the Witness is Serialized into raw bytes.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: