Segregated Witness (SegWit): Bitcoin’s scaling solution
Segregated witness (SegWit) was implemented In 2017 when the war in the bitcoin community about block size reached its peak.
There were people who were pushing for an increase in block size limit beyond the 1 MB, that was intially set by its creator, Satoshi Nakamoto. The argument was that as bitcoin continues to scale, more people will use it and the 1 MB block size would be seen as a constraint because it can only handle a limited number of transactions per second.
This limitation led to the famous “block size debate,” with different parts of the community advocating for various solutions. Some wanted to increase the block size, while others preferred off-chain or secondary layer solutions.
The disagreement on the approach to scale Bitcoin has led to several forks in the crypto realm. Bitcoin Cash (BCH), another cryptocurrency, was created as a result of a disagreement on this issue, and it started with an 8 MB block size limit, which was later increased.
We are not going to go into too much details about the block size war in this article, but if you are interestend, you can check out the book “The Block Size War” by Jonathan Bier.
The implementation of SegWit into the Bitcoin network
SegWit was first introduced as a solution to the transaction malleability issue and later as a method to increase the effective block size without needing a hard fork. Bitcoin developer Pieter Wuille first presented it at the Scaling Bitcoin conference in December 2015.
Implementation in Bitcoin Core
Developers integrated the SegWit code into the Bitcoin Core codebase. Given the importance of this change, the code underwent extensive review and testing.
It was implemented in Bitcoin as a soft fork. A soft fork is a backward-compatible way to upgrade a blockchain. It means that non-upgraded nodes can still participate in the network. They are often refered to as “Legacy nodes”.
Miner Activation via BIP 9
SegWit used BIP 9’s version bits for deployment. It meant that SegWit would activate once 95% of miners signaled support within a single difficulty adjustment period (approximately two weeks). However, getting sufficient miner support took time.
Once activated, Bitcoin nodes across the network began recognizing and validating SegWit transactions. Wallets and other service providers then integrated support for SegWit transactions, a process that continued over subsequent months and years.
After activation, the broader ecosystem (wallets, exchanges, payment providers) began to adopt and support SegWit, a process that was gradual.
Over time, an increasing percentage of Bitcoin transactions have used SegWit, benefiting from its reduced fee structure.
What Is Segregated Witness (SegWit)?
Before the introduction of SegWit, there was a challenge in the bitcoin blockchain network (and other cryptocurrencies) with the possibility of transaction malleability.
At its core, transaction malleability refers to the ability for someone to change the unique transaction identifier (called the transaction ID or TXID) of a transaction before it’s confirmed, without altering the actual essentials of the transaction (i.e., sender, receiver, and amount).
After the activation of SegWit a change in the transaction format of bitcoin was introduced that not only solved the transaction malleability problem, but also made it possible to effectively increase the block size, without increasing the limit of the blocks.
How Segregated Witness (SegWit) solved the problems?
Prior to SegWit, in the original Bitcoin protocol, the TXID was calculated by hashing the entire transaction, including the witness data (signatures). Because signatures could be slightly altered without changing the transaction’s actual meaning, the TXID could be modified by a third party before the transaction was confirmed.
SegWit stands for Segregated Witness and “Witness” means signature. So from the name we can get a pretty decent clue to what this upgrade does.
It “removes” the signature from the transaction. This separation means that the witness data (signature) is not included when computing the transaction ID, making the transaction format more flexible and addressing the issue of transaction malleability.
More space in blocks
With the separation of witness data, there’s effectively more room in each block for transactions. While it’s not a direct increase in the block size, it’s an adjustment to how block size is calculated. This change, termed “block weight,” allowed for more transactions to fit within a block, which in turn helps in slightly alleviating the scalability concerns.
Introduction of the Block Weight Concept
With SegWit, the notion of block size was somewhat redefined. Instead of a simple 1 MB block size, Bitcoin implemented a “block weight” system. This system gives different “weights” to different parts of a transaction.
- The main part of a transaction (without the witness data) has a weight of 1 byte per byte.
- The witness data (like signatures) has a weight of 1/4th byte per byte.
Therefore, with this weighting system, a block can have a maximum weight of 4 million units. This effectively means that, depending on the composition of transactions, blocks can be larger than 1 MB, up to a theoretical limit of 4 MB if they were composed entirely of witness data (which is an unlikely extreme scenario). In reality, blocks with SegWit Tx’s often come in a bit over 1 MB, with 2 MB being a more practical upper limit for average transaction mixes.
Besides its primary purpose, SegWit also improved the security of the Bitcoin network. The upgrade altered the way data was signed, reducing certain risks associated with transaction signing.
While offering various benefits, its adoption was gradual.
Not all service providers, wallets, and exchanges immediately supported SegWit transactions. Over time, as more entities adopted it, the network began to realize its full benefits. By observing transaction data, one can see an increasing percentage of transactions on the network using Segregated Witness as time goes on.
The effect on Bitcoin transactions after SegWit
By separation of the Signature (The Witness), it made it possible for more transaction to fit into a block. That decreased the competition for block space which led to decreasing transaction fees.
With more room in blocks, transactions could get confirmed faster, especially during high-traffic periods.
Post-SegWit, new address formats such as bech32 started gaining popularity.
While the addresses starting with “1” are legacy addresses The ones that start with “bc1” are native to SegWit and enables the full benefit of the upgrade.
How SegWit paved the way for the Lightning network
The Lightning Network (LN) is a second-layer solution for Bitcoin, designed to facilitate faster and more scalable transactions.
The Lightning Network relies on chained commitment transactions.
If a malicious actor can change the TXID of an earlier transaction in the chain, it would render the subsequent commitment transactions invalid because they reference the TXID of the previous transaction.
This would destabilize and potentially compromise the security of LN channels.
SegWit addressed the transaction malleability issue by removing the signature data (witness data) from the part of the transaction data that is hashed to create the TXID.
By doing this, even if the witness data is altered, the TXID remains the same. With this malleability issue resolved, the foundation for reliable and secure LN channels was established.
Block Space Efficiency
While not a strict necessity for LN, SegWit also made block space use more efficient by segregating the witness data.
This indirectly helps LN because opening and closing LN channels involve on-chain transactions. More efficient block space usage means these transactions are more economical, further incentivizing the use of LN.
Increased Smart Contract Flexibility
SegWit’s changes to the Bitcoin scripting system allow for greater flexibility. It also benefits more complex smart contracts and off-chain solutions like LN.
In summary, while the theoretical underpinnings of the Lightning Network could have been conceptualized without SegWit, the latter’s solutions to specific technical challenges, made the practical and secure deployment of the LN feasible.
Segregated Witness, a pivotal upgrade in Bitcoin’s protocol, addressed transaction malleability while optimizing block space. Its implementation paved the way for improved scalability. By reducing fees it set the stage for advanced solutions like the Lightning Network. As a testament to Bitcoin’s adaptability, SegWit showcases the network’s commitment to continuous evolution in response to its challenges.
If you want to dive deeper and learn more about Bitcoin, you can check out our Bitcoin Hub for more useful articles!
1. What is Segregated Witness (SegWit)? SegWit is a protocol upgrade that changes the way data is stored within Bitcoin transactions, enhancing the blockchain’s capacity and solving the transaction malleability issue.
2. Why was SegWit introduced? SegWit was introduced to improve the scalability of the Bitcoin network, allowing it to process more transactions without significantly increasing block size. It also addressed the transaction malleability issue.
3. How does SegWit work? SegWit segregates the witness data (signatures) from the transaction data. This makes transactions smaller in size, allowing more transactions to fit into a block.
4. What is transaction malleability? Transaction malleability refers to the ability to change the unique transaction ID without changing its content. SegWit solves this by ensuring the signature data doesn’t affect the transaction ID.
5. How does SegWit affect transaction fees? By optimizing the space within blocks, SegWit can lead to a reduction in transaction fees, as more transactions fit within a block.
6. Was SegWit a hard or soft fork? SegWit was introduced as a soft fork, meaning it was backwards compatible with nodes that did not upgrade.
7. Does SegWit affect Bitcoin’s security? No, SegWit maintains the security of the Bitcoin network while optimizing its transaction capacity.
8. How did SegWit pave the way for the Lightning Network? By resolving the transaction malleability issue, SegWit made the development of second-layer solutions like the Lightning Network more feasible.
9. Do all Bitcoin wallets support SegWit? While many modern wallets support SegWit transactions, it’s always a good idea to check with your specific wallet provider.
10. How can I tell if a Bitcoin address is SegWit-enabled? SegWit-enabled addresses typically start with “3” (P2SH format) or “bc1” (bech32 format). However, not all addresses starting with “3” are SegWit addresses.