SegWit: The Signature Separation
SegWit: The Signature Separation
Activated in August 2017 after years of debate, Segregated Witness (SegWit) is the most significant structural change to the Bitcoin transaction format in history. Defined in BIP141, it fundamentally altered how signatures are stored and accounted for on the blockchain.
1. What was "Segregated"?
Before SegWit, every transaction was a single blob of data. This blob included:
-
Base Data: Inputs, Outputs, Amounts.
-
Witness Data: The cryptographic signatures (scriptsig) that prove ownership.
SegWit "Segregated" (separated) the Witness data from the Base data.
-
The
txidis now calculated ONLY from the base data. -
The signatures are moved to a new "Witness" field that sits outside the traditional transaction structure.
2. Why do this?
The primary reason for SegWit was not just about block size—it was about Transaction Malleability.
-
In the old format, the signature was part of the transaction ID.
-
Because signatures can be "tweaked" (malleated) without becoming invalid, a third party could change the
txidof a transaction while it was in the mempool. -
Impact: This made it impossible to build "Layer 2" protocols like the Lightning Network, which rely on chaining multiple unconfirmed transactions together.
3. The Anyone-Can-Spend Trick
SegWit was implemented as a Soft Fork. To ensure old nodes wouldn't reject the new transactions, SegWit used a clever trick:
-
To an old node, a SegWit output looks like an "Anyone-Can-Spend" script.
-
Old nodes see the transaction, think it requires no signature, and accept it as valid.
-
New (SegWit-aware) nodes know to look in the special "Witness" field for the real signatures.
4. Key Benefits at a Glance
-
Malleability Fix: Enables the Lightning Network.
-
Capacity Increase: Blocks can effectively hold more than 1MB of data.
-
Efficiency: Reduces the amount of data nodes need to store and verify for certain types of operations.
| Feature | Legacy Transaction | SegWit Transaction |
|---|---|---|
| Signature Location | Inside Base Data | Separated Witness Field |
| TXID Calculation | Includes Signature | Excludes Signature |
| Malleable? | Yes | No |
In the next section, we will analyze how SegWit Fixed Transaction Malleability.
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: