Segregated Witness

As blockchain and cryptocurrency grow, it also becomes apparent over time that there are flaws. This is the case with Bitcoin, for example, as we are currently finding out that it is actually not very scalable at all. But we also ran into problems in the past, which have since been solved. Such a solution can be applied by means of a soft fork. This also happened with Bitcoin, when the upgrade called SegWit (Segregated Witness) was implemented on the blockchain. In this article, we'll explain everything you need to know about Segregated Witness.

What is SegWit?

Segregated Witness (also known as SegWit) is an upgrade to the Bitcoin protocol (a soft fork) that changes the structure of transactions by moving the signature data (such as the private key) to a separate database. The main purpose of this is to increase Bitcoin's transaction capacity. In the process, it also makes the transactions less easy to manipulate.

In terms of age, SegWit is no longer a new idea: the update was first proposed in 2015, before being officially brought out by Pieter Wuille and other Bitcoin Core developers in December 2015. However, it was not introduced until much later due to its controversial nature and rejection by miners. Only in 2017, as part of the SegWit2X compromise, was the proposal that allowed SegWit (BIP-91) approved. The activation of SegWit on the Bitcoin network finally took place on August 24, 2017 at block 481,824.

The main improvement that SegWit brings is the fact that transactions can no longer be manipulated. Thus, it also ensures that transactions are suddenly smaller, allowing many more transactions to fit into a block.

How does a SegWit work?

As you probably already know, every transaction in Bitcoin has an identifier (txid) that is represented as a string of characters. For example, the identifier of the first transaction between Satoshi Nakamoto and Hal Finney is:

f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16

This identifier is a fingerprint of the transaction, which can also be called the result of applying a hash function to this transaction. It depends on the elements present in the transaction: if any of them is changed, the identifier is completely changed.

In Bitcoin, classic transactions are malleable. This means that it is possible to change their identifier without invalidating them. So how is this possible? It is possible because the signatures that make the transaction valid do not cover all the data. This is because the transaction is first built without signatures, then it is signed, and finally the signatures are added.

Increase of transaction capability by SegWit

In addition to correcting the manipulability of transactions, the SegWit update has another important effect: it increases the transaction capacity of the network while avoiding a hard fork. This increase is made possible by placing the signature scripts outside the traditional blocks.

In SegWit, a new technique is used to measure the impact of transactions and blocks on the network: weight. Instead of relying on the size of a transaction, which is expressed in bytes representing the amount of data stored on the blockchain, SegWit uses a virtual attribute called the weight. This is expressed in weight units (WU) and defined as:

Weight = 4 × base size + size of witness

This update changes the 1 MB limit on block size to a 4 MWU limit. This is not a quadrupling of network capacity, although the block does allow up to 4 MB of block size. So, this is a trick that is being implemented by SegWit.

Assuming full implementation of SegWit, one would expect a 70-100% increase in network transaction capacity. That is, these are SegWit blocks with a total size of 1.7-2 MB, which would allow for 5-15 transactions per second in the best case.

Other benefits of SegWit

In accordance with BIP-143, the signature algorithm has been improved for SegWit transactions. On the one hand, it avoids redundant hashes when verifying a signature. On the other hand, by taking into account the input amounts of the transaction, the algorithm provides better security than the offline signature used by hardware wallets such as the Ledger Nano S.

SegWit also provides version control of the scripts, making this update a tool to improve the protocol.

Because more transactions can be processed, the transaction costs are also a lot lower. And that is, of course, a big advantage for Bitcoin users, for example. They can perform more transactions through SegWit, for a lower price.

Disadvantages

Contrary to what you might think, SegWit was not a small change for Bitcoin at all: it was a major restructuring of transactions that brought its own set of complications. Even though the upgrade was done via a soft fork, that doesn't mean it was a smooth process. As soon as SegWit was activated, the blocks of all miners who did not comply with the new rules were rejected by the network: the upgrade was thus mandatory for all miners.

In the process, SegWit was not unanimously supported by the Bitcoin community. Blockchain scalability advocates, miners and major market players generally opposed it. And some community members urged it to be activated on August 1, 2017, via a "User Activated Soft Fork." The SegWit update only came about in the context of the compromise created by SegWit2X, an agreement that wanted to allow SegWit while increasing the base block size limit to 2MB but ultimately did not hold up.

SegWit makes the base of the code very complex by, for example, associating a new interpretation of the scripts with the new addresses. This is problematic because Bitcoin is an economic system where security depends on the control of a large number of people (nodes) and must be simple in design.

SegWit also causes "validation defeat" for the nodes that follow the old rules: they don't see the signatures and don't validate them, which degrades the quality of the network and forces nodes to upgrade to the new software.

The last major drawback of SegWit is that its deployment is slow and limited. Since it is a soft fork, people have the choice to use SegWit or not. However, it directly affects the promises this update makes. Currently, SegWit adoption is stagnant at around 50% (April 2021), which means that only 50% of nodes have switched to SegWit.

Conclusion

Now we explained what SegWit, how it works and what the benefits are, it’s time to summarize what you just have learned. It’s clear that SegWit is an upgrade to the Bitcoin protocol that brings a number of improvements we already talked about in this article. In particular, it fixes the malleability of transactions that hampered the implementation of the Lightning network and increases the capacity of the network. One of the biggest benefits is that more transactions can fit in a block, which also reduces transaction costs. This is of course very beneficial for crypto traders, but also for nodes of the Bitcoin blockchain. The fact that it is a soft fork makes SegWit compatible with older versions of Bitcoin, but SegWit is far from perfect. Therefore, it is still far from clear how this will play out.