Understanding SegWit
By: Ruma Das
Tags: Bitcoin, Blockchain, Lightning Network, Segwit

The First layer scaling solution is comprised of 3 different scaling mechanisms:

· Sharding

· Hard fork

· SegWit

In my last two articles, I have already covered Hard Fork and Sharding. So here in this article, I will focus on the last scaling solution i.e SegWit.

What is SegWit?

SegWit stands for Segregating Witness

i.e separating the signatures from the transactions.

In this process, certain parts of a transaction are removed, which will free up space so that more transactions can be added to the chain. The idea behind using this method is to overcome the block size limit of blockchain transactions. In simple terms, SegWit changed the way data are stored, therefore helping the Bitcoin network to run faster and more smoothly.

It was suggested as a soft fork change in the transaction format of Bitcoin in the Bitcoin Improvement Proposal number BIP141.

Problem Statement

In the Bitcoin platform, Blocks are getting generated every 10 minutes and are constrained to a maximum size of 1 megabyte (MB). As the number of transactions is increasing, more blocks need to be added to the chain. But due to the block size constraint, only a certain number of transactions can be added to a block. The weight of the transactions can cause delays in processing and verifying transactions. Sometimes, it takes hours to confirm a transaction as valid. This can slow down further when the network is busy.

The Solution

To overcome the block size limit issue and to enhance the transaction speed, the transaction is divided into two segments. Removing the unlocking signature (witness) from the original portion and appending it as a separate structure at the end. The original portion will still have the sender and receiver data, and the new “witness” structure would contain scripts and signatures. The original data segment would be counted normally, but the new “witness” segment becomes one-fourth of its original size.

Digital signature accounts for 65% of the space in a given transaction.

SegWit is backward compatible, which means nodes that are updated with the SegWit Bitcoin protocol can still work with nodes that haven’t been updated.

SegWit measures blocks by block weight.

The formula used to calculate block weight:

(tx size with witness data stripped) * 3 + (tx size)

Since segregated witness creates a sidechain where witness data is stored, it prevents transaction IDs from being altered by dishonest users. It also addresses signature malleability, by serializing signatures separately from the rest of the transaction data, so that the transaction ID is no longer malleable.

History

Pieter Wuille, a bitcoin developer, first proposed the concept of SegWit.

On 24 July 2017 as a part of the software upgrade process i.e Bitcoin Improvement Proposal (BIP) 91, the concept of Segregated Witness is activated at block 477,120.

Within one week of implementation, the bitcoin price seen a spike of 50%. The transaction usage rate using SegWit further increased from 7% to 10% in the first week of October. As of February 2018, SegWit transactions exceed 30%.

However, a group of China-based bitcoin miners were unhappy with the implementation and later forked to created Bitcoin Cash.

Lightning Network — Layer 2 solution

Lightning Network operates on top of bitcoin and is referred to as a “Layer 2” component. It is an off-chain micropayment system that is designed to enhance the transaction speed in the blockchain network.

SegWit acts as a base component for the Lightning Network. By implementing SegWit, the transaction malleability issue can be prevented which will allow this secure payment system to process millions of transactions per second in the Bitcoin network.

Advantages of SegWit:

· Prevents transaction malleability problem.

· Prevents signature malleability problem.

· Helps in scaling the bitcoin network.

· Increases block size.

· Reduced transaction fees.

· Acts as a base for the lightning protocol.

Conclusion

There is no doubt that Bitcoin technology is very revolutionary but like any other technology, it has certain drawbacks as well as challenges. Scaling is one of them which has restricted in large scale applications adopted. It is capable of processing only 7–10 transactions per second on the base layer. Many developers, researchers from the Bitcoin community are working hard to overcome the problem. SegWit along with the Lightning Network together aiming to allow Bitcoin to process millions (or more) transactions per second. But the real scenario will depend on the success of future projects.