What is Segregated Witness
Segregated Witness: The BIP 141 Soft Fork
Activated on the Bitcoin network in August 2017 via BIP 141, Segregated Witness (SegWit) represents one of the most critical structural upgrades in Bitcoin's history.
By altering how transaction data is organized and validated, SegWit solved fundamental protocol limits while maintaining complete backwards compatibility.
π§³ What Does "Segregated Witness" Mean?
To understand SegWit, we can break down its name:
- Segregated: Separated or set apart.
- Witness: The cryptographic proofs of ownershipβspecifically, the digital signatures and unlocking scripts.
Historically, legacy Bitcoin transactions combined inputs, outputs, amounts, and signatures inside a single, contiguous data block. Under SegWit, the signatures are separated (segregated) from the main transaction data and stored in a parallel, auxiliary structure called the Witness Area.
TRANSACTION STRUCTURE COMPARISON
ββββββββββββββββββββββββββββββββββββββββ
β LEGACY TRANSACTION (Contiguous) β
ββββββββββββββββββββββββββββββββββββββββ€
β β’ Inputs (TXIDs, Indices) β
β β’ Unlocking Scripts (scriptSig) β βββ Signature stored inside input!
β β’ Outputs (Amounts, scriptPubKeys) β
ββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββ
β SEGWIT TRANSACTION (Segregated) β
ββββββββββββββββββββββββββββββββββββββββ€
β β’ Inputs (TXIDs, Indices) β
β β’ Outputs (Amounts, scriptPubKeys) β
ββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββ
β β’ WITNESS AREA (Segregated Data) β βββ Signature moved out of main body!
β - Signatures, Unlocking Scripts β
βββββββββββββββββββββββββββββββββββββββ
β©οΈ The Soft Fork Compatibility Trick
Implementing SegWit as a Soft Fork (a backward-compatible upgrade) was a brilliant cryptographic achievement. It allowed upgraded nodes to validate the new signatures while ensuring older, non-upgraded legacy nodes did not crash or reject the transactions.
To achieve this, SegWit-style outputs are mapped to legacy nodes as Anyone-Can-Spend outputs:
- Legacy Node's View: When a legacy node sees a SegWit output, the locking script appears to have no signature requirements. According to the old rules, the input is empty of unlocking scripts. The legacy node assumes anyone can spend it and marks it valid without verifying any signatures.
- SegWit Node's View: An upgraded node recognizes the specific SegWit output structure. Instead of treating it as anyone-can-spend, the node looks for the signatures in the Witness Area, pulls them, executes the elliptic curve math, and validates ownership.
If an attacker tries to steal SegWit coins by broadcasting a spend without a signature, legacy nodes might accept it, but all SegWit-upgraded nodes (and miners) will reject the transaction as invalid. Because the vast majority of the hash rate and validation network upgraded to SegWit, any attempt to steal these coins results in an invalid block that is instantly orphaned from the blockchain.
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: