What is SegWit?
Segregated Witness (SegWit) is a protocol upgrade developed in 2015. The concept was introduced as a solution to the scalability problem that blockchain networks were and are still facing today.
SegWit’s main idea is to reorganize block data so that signatures are no longer placed along with transaction data. In other words, the SegWit upgrade consists of segregating the witnesses (signatures) from transaction data. This allows for more transactions to be stored in a single block, increasing the transaction throughput of the network.
By only being able to process about 7 transactions per second, a Bitcoin transaction can sometimes take a long time to go through. That's a lot slower when compared to conventional payment solutions and financial networks, which can process thousands of transactions per second.
What are the main benefits of SegWit?
One of the biggest benefits of SegWit is the increase in block capacity. By removing the signature data from the transaction input, more transactions can be stored within a single block.
Without SegWit, the signature data can take up to 65% of a block. With SegWit, the signature data is moved away from the transaction's input. This causes the effective block size to increase from 1 MB to about 4 MB.
Note that SegWit is not an actual block size increase. Instead, it is an engineering solution to increase the effective block size without having to increase the block size limit (which would require a hard fork). To be more specific, the actual block size is still 1 MB, but the effective block size limit is 4 MB.
Also, SegWit introduced the idea of block weight. We may consider block weight as a concept that replaces the idea of block size. Essentially, block weight is a measure that includes all block data, including transaction data (1 MB) and the signature data (up to 3 MB), which is no longer part of the input field.
Transaction speed increase
Increased transaction speed has also helped reduce transaction costs in the Bitcoin network. Before SegWit, it wasn't uncommon to spend over $30 per transaction. However, SegWit has dropped that cost dramatically to less than $1 per transaction.
Transaction malleability fix
A major issue with Bitcoin was the ability to potentially tamper with transaction signatures. If a signature is altered, it could result in a transaction between two parties being corrupted. Since the data stored on blockchains are virtually immutable, invalid transactions could be permanently stored on the blockchain.
SegWit and the Lightning Network
The development of second-layer protocols was partially enabled by fixing the transaction malleability bug. Simply put, second-layer protocols are new platforms or products that are built on top of a blockchain, such as Bitcoin. One of the more popular second-layer protocols is the Lightning Network, an off-chain micropayment network.
The Lightning Network is a second-layer protocol that operates on top of the Bitcoin network. The Lightning Network's main purpose is to allow more transactions to be confirmed in a shorter amount of time, resulting in faster transactions for users. Transactions are collected off-chain and effectively buffered for the Bitcoin network to eventually process.
SegWit vs. SegWit2x
The key difference between SegWit and SegWit2x is that the latter would have not just included a change in transaction batching, but also an increase in the block size (from 1MB to 2MB). Still, a larger block size would increase the burden on node operators and miners, as there would be more data to be handled.
Another notable difference is that the SegWit proposal was supported and enforced by the Bitcoin community. The episode gave birth to the concept of UASF, which stands for user-activated soft fork.
On the other hand, the SegWit2x proposed a substantial change to one of the fundamental rules governing Bitcoin. But since developers were unable to come to a consensus on its adoption and implementation, the SegWit2x movement was ultimately suspended.
Nested SegWit vs. Native SegWit (bech32)
In short, Native SegWit (also known as bech32) is an updated version of the Nested SegWit. The bech32 format offers increased transaction speed, better error-detection mechanisms, and even lower transaction fees. Also, bech32 addresses are lowercase, making them easier to read.
Note that blockchain transactions between non-SegWit (Legacy), Nested SegWit, and Native SegWit (bech32) addresses are fully compatible. However, not all exchanges and crypto wallets support SegWit, so you might not be able to withdraw funds directly to a SegWit address.
The implementation of SegWit marked the biggest protocol upgrade of Bitcoin, and the fact that it was supported and implemented by the decentralized community makes it even more interesting.
The introduction of SegWit was a major step forward in solving many problems related to Bitcoin and other blockchain networks - especially in regards to scalability. Through the combination of SegWit and the second-layer protocols, blockchain networks can handle a larger number of transactions, with more efficiency and lower costs.
Despite being a powerful and innovative solution, SegWit is yet to be fully adopted. Currently, the percentage of Bitcoin addresses using SegWit is around 53%.