The Bitcoin protocol is subject to regular updates aimed at upgrading the protocol, addressing flaws and resolving security issues. Since its inception in 2009, many upgrades have already been successfully implemented. One of the more notable upgrades dealt with so-called transaction malleability, which made it possible for attackers to indirectly modify transaction IDs.
The Bitcoin protocol is subject to regular updates aimed at upgrading the protocol, addressing flaws and resolving security issues. Since its inception in 2009, many upgrades have already been successfully implemented. One of the more notable upgrades dealt with so-called transaction malleability, which made it possible for attackers to indirectly modify transaction IDs.
The solution implemented to fix transaction malleability is referred to as Segregated Witness, or SegWit. This article explains how SegWit stopped transaction malleability and outlines SegWit’s extended functionality, which made it possible to introduce many different types of scaling options (read this article to learn about blockchain scaling).
Segwit Essentials
- Segregated Witness, or SegWit, is a protocol implemented to fix transaction malleability which allowed for transaction IDs and hashes to be modified.
- SegWit virtually increases block size four times with the block weight concept.
- SegWit reduces transaction fees.
- Its design was proposed in Bitcoin Improvement Proposals (BIPs) 141, 148 and 91.
- SegWit makes it possible to set up Schnorr signatures and facilitates the implementation of the Lightning Network.
Design and development
SegWit was conceptualized and presented by developer Pieter Wiulle at the Scaling Bitcoin conference in December 2015, where the primary topic was making Bitcoin grow bigger and faster. With the promise of opening the door to Bitcoin scaling, SegWit immediately garnered substantial community support.
The design of SegWit was first outlined in Bitcoin Improvement Proposals (BIPs) 141 and 148. Its initial purpose was to address the ability to change signatures and, consequently, transaction IDs, which is commonly referred to as transaction malleability. This was a flawed piece of code that allowed anyone to alter small transaction details to modify a transaction hash, which also changed the transaction ID.
And while transaction malleability allowed for the modification of transaction ID, it did not enable the contents of BTC transactions to be changed. As it only allowed for the transaction ID and hash to be altered, transaction malleability never really posed a major risk to the Bitcoin protocol. It did, however, inhibit the development of more complex features, for instance various scaling solutions and smart contract functionality.
In addition to fixing transaction malleability, SegWit also reinvents the concept of block size. While the size of blocks in the Bitcoin blockchain was traditionally limited to 1 MB of data, SegWit builds upon this with a new concept termed block weight. With block weight, each block has a limit of 4 M weight units, or 1 M vbytes, meaning that 1 vbyte equals 4 weight units. As a result, nodes with software updated with the SegWit protocol can potentially send and receive four times the amount of data they could before the SegWit soft fork. However, due to various constraints, blocks are never that large – the average block size revolves around 1.3 MB.
This redesign of block size also results in lower transaction fees. Before SegWit, transaction fees were determined as fee per transaction size. With the introduction of the block weight concept, this changed to fee per weight unit. As SegWit reduces the burden on the blockchain, fees required for the validation and addition of transactions to the blockchain are reduced accordingly.
To test its functionality, SegWit was first activated on Litecoin on 10 May 2017. Once it proved to be operational, it was also implemented on Bitcoin on 23 August 2017. Since it was implemented by means of a soft fork, the blockchain is compatible with the nodes that do not support SegWit. This means that full nodes in the Bitcoin network will have the same copy of the ledger, regardless of how large their blocks are.
A foundation for scaling
Once SegWit was put in place, it enabled new scaling methods in terms of both on-chain and off-chain scaling solutions.
SegWit makes it possible to implement Schnorr signatures. A Schnorr signature is a digital signature created by the Schnorr signature algorithm. Its security is based on the intractability of discrete logarithm problems. As it is short, it takes up less space on the blockchain than a traditional signature. This reduces the load on the blockchain and increases the network’s throughput by means of first-layer scaling.
But perhaps a more interesting feature unlocked by SegWit is layer 2 scaling. The malleability fix has opened the door to the safe implementation of the Lightning Network. Lightning is a separate network that combines channels between different network users and the six-degrees-of-separation principle to connect users who have not yet transacted before. The technology requires that only the starting and final balance of the channel has to be written to the blockchain, but none of the transactions in between. This unburdens the blockchain, reduces transaction fees and increases the network’s speed.
The implementation of SegWit was a key stepping stone in enhancing Bitcoin scalability. It has far outgrown its initial design (eliminating transaction malleability) and proved to be essential in supporting the ever-growing masses using the largest cryptocurrency. As of writing this article, over half of bitcoin transactions have adopted SegWit, with the number projected to grow in the future.