What Is Segregated Witness (SegWit)?

SegWit is a new improvement on the bitcoin network that has been approved by a large part of the community. Since its implementation, the amount of transactions per second has increased by an astounding 25%. This has lead to a lot of speculation as to why segwit was implemented.

One thing you may want to note is that bitcoin's transaction fee went down by 50% when segwit was implemented, which suggests a large number of small transactions per second are taking place on the network. With this being said, let us get into what exactly SegWit is and how it works!

SegWit, which is also known as Segregated Witness, is a soft fork that intends to improve Bitcoin transaction efficiency by introducing segregated witness functionality. SegWit implements the use of a separate transaction for every input and output amount of a bitcoin transaction, thus reducing fees per byte.

Understanding Segregated Witness (SegWit)

Thousands of computers make up the Bitcoin network, which serves as a validator for the blocks that miners produce. These machines, also known as nodes, each maintain an exhaustive record of each transaction. We refer to this record as a blockchain. 

As it developed, the Bitcoin network ran into a number of issues. One was the increase in transactions, which resulted in more blocks being added to the chain. Block sizes are limited to a maximum of one megabyte and are generated every 10 minutes (MB). This limitation limited the number of transactions that could be put to a block.

The network was being burdened by the volume of transactions represented by the blocks, which were delaying the processing and verification of transactions. Sometimes it took hours to determine whether a transaction was legitimate. Bitcoin transaction validation would have slowed to a standstill without SegWit's activation as the cryptocurrency gained popularity and a greater volume of transactions.

The transaction is split into two halves by the SegWit algorithm. The unlocking signature (also known as the "witness" data) is taken out of the beginning but is still there at the end as a separate structure in the blockchain. While the "witness" structure, which is a different structure at the end, contains scripts and signatures, the original portion contains the sender and receiver data . 

Transaction Malleability: What Is It?

Transaction malleability is the capacity of a transaction to have numerous valid txids (Transaction IDS). When a portion of a transaction is malleable, it allows for changes to be made after the transaction has been signed without invalidating the signature.

Since a transaction's hash is represented by a txid, any changes to the transaction will also affect the txid. Only modifications that change the txid but do not invalidate the signature raise worries about malleability, whereas modifications that change the txid but do not invalidate the signature are not a worry.

The issue with transaction malleability

Developers and consumers who want to reference an earlier transaction in a new spending transaction before the earlier transaction has been confirmed on the blockchain must deal with malleability.

This issue arises because the spending transaction needs to include the txid of the prior transaction in order to spend bitcoin generated by a prior transaction. The reference will fail if this txid potentially changes, invalidating the spending transaction.

A specific issue hindering the adoption of the Lightning Network, which depends on the exchange of unconfirmed Bitcoin transactions, is transaction malleability.

How Transaction Malleability is Fixed by SegWit

There are two ways to malleate a transaction. ScriptSig, the portion of the transaction that contains the signature and other data needed to unlock the bitcoin, can be expanded upon after a transaction is signed. Second, it is possible to alter the signature itself, which is a part of the ScriptSig.

Because a signature cannot make itself immutable by signing itself, both of these solutions are feasible. The txid will change if the ScriptSig or the signatures it includes are altered because they are a part of the preimage of the txid.

SegWit avoids this option by purging the ScriptSig of all data. To do this, the ScriptSig data—typically signatures and public keys—is transferred to the Witness, a new component of SegWit transactions that is not hashed to get the transaction identifier (txid).

Thus, after being signed, the ScriptSig for SegWit inputs is made immutable, while the information needed to unlock bitcoin, which is not immutable, is contained in the Witness. As a result, it is impossible to alter the ScriptSig without also changing the txid and rendering the transaction invalid.

Why Did SegWit Make Sense?

Although the pros and cons of SegWit are still hotly contested in the cryptocurrency industry, security improvements and faster transaction speeds are favourable for the blockchain, miners, and SegWit-accepting nodes. Taproot, an improvement to Bitcoin built atop SegWit that enables even faster validation, was made possible thanks to SegWit.

Final Thoughts

The adoption of SegWit was the largest protocol upgrade for Bitcoin, and the fact that the decentralised community supported and helped to develop it adds to its intrigue. 

With relation to scaling, the introduction of SegWit was a significant step toward resolving many issues with Bitcoin and other blockchain networks. Blockchain networks are able to process more transactions more quickly and cheaply by combining SegWit with the second-layer protocols.

SegWit has not yet achieved widespread adoption, despite being a strong and cutting-edge solution. Approximately 53% of Bitcoin addresses are currently implementing SegWit.

Segregated Witness will only enhance the capabilities of the entire Bitcoin ecosystem. This will also drastically reduce the size of the transaction as well as the overall amount of space it takes up.

We'll have a lot more area to work with in the blocks, which means that more transactions can fit within them. For instance, the current block size limit is 1MB per block. If we reduce this to 0.7x or 0.8x, we'll be able to fit 4 - 5 times as many transactions in each block, lowering fees and increasing the speed of transfers.

I hope this blog will clarify what the concept "Segregated Witness" means (SegWit). If you like the article, please spread the word to your friends who are interested in cryptocurrencies.