SegWit: not just a solution to transaction malleability problem

Segregated Witness or shortly SegWit is a soft fork of Bitcoin aiming to resolve the problem of transaction malleability that implies changing the ID of a transaction before it is confirmed by the network. Another useful feature that it has offered to Bitcoin users (almost accidentally) has improved the network capacity making it possible to process a bigger number of transactions per second.

Our experts at Numbrs have made detailed research on this technology and come up with an explanation of the useful improvements that it can provide the Bitcoin network.

Transaction malleability explained

First things first, let’s understand what transaction malleability is, whom it may affect and why BTC users should worry about it at all. Although Bitcoin is based on a perfectly programmed decentralized system that eliminates the need for third parties to govern transactions between users, it is also a very comlicated system. Its complexity results in bugs that can be exploited by savvy fraudsters. One of such bugs enables an attacker to mess up with transactions by changing their unique IDs, i.e. hashes.

When you send bitcoins from one wallet to another, the network records input and output details about this transaction such as the wallets’ addresses, the amount being sent, the ID of the previous transaction that was recorded on the network, and, most importantly, the digital signature validating this transaction. Transaction malleability is a loophole in the system that refers specifically to digital signatures. When Alice sends funds to Bob, the last one can trick the system in the following way in case he has control over at least one node of the network:

  1. Ben launches an identical transaction into the network, but with a different txID.
  2. If Ben gets lucky, the network will record his transaction first and thus make it valid.
  3. The money sent by Alice will be sent to Ben’s other wallet that Alice has no notion about.
  4. Ben complains that he has never received the funds. 
  5. If Alice checks the blockchain to see her original txID she won’t find it and send the funds once again.

Thus, Ben makes double profits while Alice and the rest of the network remain in obscurity. By the way, this is exactly the bug that hackers utilized to steal funds from the ill-famous Mt.Gox in 2014. Do you still think that the bug is nothing serious?

What SegWit proposes to resolve it

As the problem of malleability troubled the minds of many, the protocol upgrade was proposed at a Bitcoin conference in 2015 by Dr. Pieter Wuille who’s a part of the Bitcoin Core advancement group. 

The renovation suggests removing the witness data, i.e. the signature that validates transactions, and placing it on a sidechain. This helps to prevent attackers from changing the hashes and eliminates malleability.

An interesting aspect of SegWit is that it comes in a form of a soft fork and is backward-compatible. Its implementation doesn’t require the changes to be accepted by all the nodes in the system and thus prevents the community split. The cons of this approach are that Bitcoin malleability is still something that cryptocurrency users should beware of as not all the nodes have implemented the patch. At the time of writing, SegWit has been implemented by ~70% of the network. 

Transactionfee.info: the pace of SegWit implementation was boisterous in the early years and now it gradually slows down 

SegWit improves Bitcoin scalability

The secondary effect that Segregated Witness inventors have almost unintentianally granted to Bitcoin users was the improvement of its scalability. We have already disclosed this issue and its importance in the previous article where we talked about the Lightning Network. 

The signature occupies around 65% of every block. SegWit removes it and thus frees up the room for more transactions. The effect is not that strong to fully resolve the scalability problem, though, as with SegWit Bitcoin gets a chance to process around 15 transactions per second vs its normal capacity of 5-6 tps. However, don’t hurry to give it up.

SegWit is the solution that has made the Lightning Network possible in the first place. While the signature format was not strictly defined, one could not launch the second layer and put the money at risk. SegWit has become the game-changer by setting up a standard for the signature verification. Thus, although it doesn’t significantly improve Bitcoin’s capacity, it still represents an important milestone in the development of the network and can push its mass adoption further.

SegWit pros

With all said above, Segregated Witness provides the Bitcoin network with the following advantages:

  • Resolves the issue of transaction malleability and improves the security of the network.
  • Facilitates the process of setting up a full node as it also reduces the amount of data one should record on a hard disk.
  • Reduces transactional costs. With SegWit, the network can process more transactions per second, therefore more participants can send funds in a given moment and the competition for the fees gets lower.
  • Increases the network capacity without increasing the size of blocks.

It’s worth adding a few words to the last point. SegWit can be easily confused with another proposal named SegWit2x. It has nothing to do with transaction malleability as it implies increasing the size of blocks with the key goal to make them process more transactions in a unit of time. There have been many debates when this hard fork was proposed in 2017, but the community has never come to an agreement, thus, SegWit2x has never been implemented.

Getting back to SegWit, there are a few cons to this technology as well, though. Miners are the ones who are not very eager to adopt it, because they can no longer use the Bitcoin weakness that allowed them to mine BTC using less power and thus make more money. Since large mining pools contribute to the Bitcoin network more than anybody else, it would be difficult to make them change their mind.

When can we see mass improvements?

In order for SegWit to be fully activated, at least 95% of nodes have to support it. With the current implementation rate hovering around 70%, the Bitcoin network still has a long way to go to get to a brighter future.

There’s little that standalone Bitcoin users can do to push it forward, so they have to rely on the industry giants such as mining pools and exchanges. While the first ones were reluctant to do that in the early years of SegWit, some centralized exchanges that have a significant influence on the market have already switched to the light side. For instance, Bitmex enabled SegWit support in late 2019.

Although big participants of the market understand the necessity, they have their own scaling issues to cope with while the industry is booming. Exchanges harden their defences against hackers while wallets struggle to increase the number of supported coins. The general trend is positive, though, so the technology has a chance of being adopted across the whole network in the upcoming years.