Bitcoin Intermediate Concepts
SegWit
Fixing a Flaw
Every Bitcoin transaction has two key parts: the details of the payment (who sends how much to whom) and the digital signature that authorizes it. Originally, both were bundled together. This created a subtle but serious problem called transaction malleability.
Think of the digital signature as the wax seal on an old letter. The letter's content is the transaction data. Transaction malleability was like a scenario where someone could melt and re-apply the wax seal without changing the letter's content. The letter would still be valid and arrive at its destination, but the unique pattern of the seal—its identifier—would be different. In Bitcoin, this meant a third party could alter a transaction's signature, changing its unique ID (txid) before it was confirmed. The payment would still go through, but the altered ID could cause confusion and break more complex contracts that relied on that specific ID.
Segregated Witness
The solution was an upgrade called Segregated Witness, or SegWit. The name explains exactly what it does: it segregates (separates) the witness (the signature data) from the main transaction data.
By moving the signature to a separate field, SegWit ensures that the transaction ID is calculated using only the core payment details. Since the signature is no longer part of the data that gets hashed to create the ID, it can't be modified to change that ID. This permanently fixed transaction malleability.
The Segregated Witness (SegWit) upgrade moved signatures and public keys from the scriptSig to a separate witness field, reducing transaction size and cost.
More Than Just a Fix
SegWit came with a major bonus: it increased the number of transactions that could fit in a block. The signature data, which can take up a lot of space, was moved out of the main 1MB block limit. Instead, Bitcoin introduced a new concept called "block weight," with a limit of 4 million weight units (WU).
Transaction data costs 4 WU per byte, while the separated witness data only costs 1 WU per byte. By making witness data "cheaper," the network could fit more transactions into the same amount of space. This effectively increased the block capacity to around 1.8 to 2.2 MB on average, without changing the fundamental block size rule.
By separating signatures, SegWit boosted transaction throughput and lowered fees, all while making the network more secure.
Most importantly, by solving transaction malleability, SegWit laid the foundation for second-layer solutions. These systems, like the Lightning Network, rely on creating chains of transactions that reference each other. Without the guarantee of a fixed, unchangeable transaction ID, these complex off-chain networks would be unreliable. SegWit provided the stability needed for them to be built.
Let's review what you've learned about this crucial upgrade.
What was the core problem that the Segregated Witness (SegWit) upgrade was designed to solve?
How does SegWit prevent third parties from altering a transaction's ID (txid)?
SegWit was a clever solution that not only fixed a fundamental flaw but also paved the way for Bitcoin to scale.