SegWit

SegWit, or Segregated Witness, refers to a change in Bitcoin’s transaction format that changes how transaction data is stored.

What is SegWit?

SegWit, or Segregated Witness, refers to a change in Bitcoin’s transaction format that changes how transaction data is stored.

The Long Definition

SegWit refers to a change in the transaction format of Bitcoin. It was originally intended to fix a transaction malleability bug. Transaction malleability refers to a vulnerability in blockchain that can lead to tiny details in a transaction being changed. When exploited, it can invalidate the block containing the transactions.

SegWit was also implemented as an upgrade that increases the blockchain’s block capacity. This allowed for more transactions to be stored within a block. As a consequence, Bitcoin experienced decreased transaction times.

What is Segwit

History of SegWit

The Bitcoin blockchain was launched in 2009. Due to its architecture and Proof of Work (PoW) consensus mechanism, the protocol can only process a limited number of transactions per second.

In the first few years of its existence, Bitcoin wasn’t popular. There weren’t that many transactions being done on the protocol. So, its limited tps wasn’t a problem.

But by 2015, bitcoin (BTC) had become quite popular. This increased the demand for transaction processing. And since the protocol wasn’t fast, transactions took a long time to be validated. It wasn’t uncommon for a transaction to take hours before it was processed and verified.

Bitcoin needed a solution. And this would come from Segregated Witness (SegWit).

SegWit was proposed as Bitcoin Improvement for Proposal 141 (BIP141). It was formulated by Bitcoin developer and Blockstream co-founder, Pieter Wuiller.

SegWit was initially meant to solve the problem of transaction malleability. But it was soon discovered that it could potentially improve transaction processing times.

With this in mind, the proposal went through a community vote. It was finally approved and activated on July 21, 2017, as a soft fork. A soft fork is a change to a protocol that doesn’t result in the creation of a new blockchain.

However, some miners were unhappy with the SegWit upgrade. So, they pushed for a hard fork to a blockchain without the upgrade. A hard fork is a major change that results in the creation of a new protocol. This particular hard fork led to the formation of Bitcoin Cash.

Since SegWit is a soft fork, not all blocks on Bitcoin have the upgrade. There are non-SegWit blocks still being written to the protocol.

layer 2 under construction

Understanding SegWit

BTC transactions are recorded on the Bitcoin blockchain. Each consists of several crucial pieces of information that are written to the blockchain as part of the transaction ID. In a non-SegWit block, the transaction ID consisted of the actual transaction data and signature information (witness).

The actual transaction data is made of the amount and the sender’s and recipient’s public keys. A public key is a wallet’s address on the blockchain. So, when you send bitcoins to your friend, both your wallet addresses will be recorded as part of the transaction.

Signature information, on the other hand, consists of a digital signature. It proves that the sender owns the funds they are trying to transfer. As such, it’s also known as witness information. This information is provided by the sender’s wallet’s private keys.

SegWit works by removing the signature information from the transaction ID. This information will still be written to the blockchain. However, that will happen outside the base transaction block.

So with SegWit, the witness information is essentially segregated from the other transaction data. This is why the feature is called Segregated Witness.

The Effects of SegWit

The SegWit upgrade had two major effects on the Bitcoin blockchain.

  • Removed transaction malleability
  • Increased the block capacity

The Transaction Malleability Problem

In its early years, Bitcoin had a small problem. This was known as transaction malleability. It was a vulnerability that could allow someone to change the transaction ID by changing the witness information. If exploited, it could invalidate a block.

SegWit was actually initially proposed as a solution to this problem. This is why it works by separating the witness information from other transaction data. That way, even if someone is able to change this information, the block would not be affected.

However, it was soon discovered that SegWit has a bigger side benefit– it could increase the block capacity. Doing so would help address Bitcoin’s problem of slow transaction speeds.

Segwit

SegWit, Block Capacity, and Transaction Speeds

Bitcoin blocks are created approximately every ten minutes. Before SegWit, the maximum block size was limited to 1 MB. This meant that only a limited number of transactions could be added to a block. The result was slow confirmation times. This lead to high transaction fees during periods of high demand

Remember how SegWit removes the witness data from a transaction’s ID?

Well, after SegWit, the maximum block size increased to 4 MB. Note that this wasn’t an actual increase in the block size. Rather, by separating the signature data from the transaction data, it changed the way transaction size is calculated. The effective block size limit was increased without having to change the actual block size. How?

The size of Bitcoin transactions is measured in units called weight units (WU). A block that doesn’t use SegWit can contain a maximum of 1 million WU. Basically, 1 MB= 1 million WU.

Contrarily, SegWit blocks change the structure of the transaction ID to create more space for data. This allows them to contain up to 4 million WU.

People typically assume that since 1 million WU= 1 MB, 4 million WU must be equal to 4MB. So it’s not uncommon to hear that SegWit increased the maximum block size to 4 MB. However, it’s important to note that the change is not necessarily in the actual block size. Rather, it’s the effective weight limit based on Bitcoin’s WU.

As such, with SegWit, you have a block that can store more transactions. The block processing time will still be 10 minutes. However, during this time, you have more transactions moving through the blockchain.

This is the most popular effect of SegWit. Therefore, the change is typically referred to as aimed at improving Bitcoin’s transaction speed.

Segwit's affect on blockchain capacity

Layer 2 Upgrades

SegWit also made it possible to develop Layer-2 protocols on Bitcoin. A Layer-2 protocol is a network that runs on top of an existing blockchain. It is typically used as a scalability upgrade.

Before, the transaction malleability bug was an obstacle to L2 upgrades. SegWit solved the problem. This allowed projects to create L2 scaling solutions like Lightning Network.


Want to join the Dypto journey? Follow our socials!