TeachMeBitcoin

What is Segregated Witness

From TeachMeBitcoin, the free encyclopedia ⏱️ 3 min read

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:

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:

  1. 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.
  2. 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.

β˜• Help support TeachMeBitcoin

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:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!