What Is Segregated Witness (SegWit)?
Segregated Witness (SegWit) refers to a change in the transaction format of Bitcoin. Its stated purpose as a protocol upgrade was to protect against transaction malleability and decrease transaction times by increasing block capacity. Transaction malleability refers to the possibility that tiny pieces of transaction information could be changed, invalidating new cryptocurrency blocks.
It was also intended to speed up the validation process by storing more transactions in a block.
- Segregated Witness (SegWit) refers to a change in Bitcoin's transaction format where the witness information was removed from the input field of the block.
- The stated purpose of Segregated Witness is to prevent non-intentional Bitcoin transaction malleability and allow for more transactions to be stored within a block.
- SegWit was also intended to solve a blockchain size limitation problem that reduced Bitcoin transaction speed.
Understanding Segregated Witness (SegWit)
The Bitcoin network consists of thousands of computers that work as validators for the blocks created by miners. These computers are called nodes, which each keep a complete record of every transaction. This record is called a blockchain.
The Bitcoin network faced several problems as it matured. One was that more transactions were occurring, which added more blocks to the chain. Blocks are created every 10 minutes and used to be constrained to a maximum size of one megabyte (MB). Due to this constraint, only a certain number of transactions could be added to a block.
The number of transactions being conducted, represented by the blocks, was weighing down the network and causing delays in processing and verifying transactions. In some cases, it took hours to confirm a transaction was valid. Without SegWit's implementation, Bitcoin transaction validation would have slowed to a crawl as the cryptocurrency grew in popularity and the number of transactions increased.
SegWit was formulated by Bitcoin developer Pieter Wuille. Wuille is also the co-founder of Blockstream, a software company specializing in digital security for financial services.
The SegWit protocol divides the transaction into two segments. The unlocking signature (the "witness" data) is removed from the original portion, but it remains a part of the blockchain as a separate structure at the end. The original portion holds the sender and receiver data, while the separate structure at the end (the "witness" structure) contains scripts and signatures.
As a result of this segregation of data, more space is created, and more transactions can be added to the blockchain.
Goals of SegWit
To understand the goals behind SegWit's implementation, it's essential to understand what's going on behind the scenes that makes it useful.
The Main Issue SegWit Addressed
When one user sends another user some Bitcoin, two pieces of information are required: a public address and a private key. A public address is a digital identifier for the entities involved in the transaction. Every user has a public address to receive and send Bitcoin, and the entire network can see these addresses. Private keys cannot be seen—they are used as verification that the public addresses belong to a user.
On a basic level, SegWit is a process that changes the way data are stored, therefore helping the Bitcoin network to run faster.
The process for transferring Bitcoin starts when one user broadcasts a request to the network. This request includes the user's public address, the amount of Bitcoin being sent, and a transaction fee for the miners.
Next, miners process the transaction; information from both users is encrypted, which means the data is turned into a line of computer code called the transaction ID. At this point, the transaction is queued. Transactions are added to the queue until the block limit is reached and a block is created.
Finally, the block is broadcast to the nodes; if more than half of all nodes agree that the information is valid, the block is confirmed and added to the blockchain. At this point, the Bitcoin has successfully been transferred between users.
Over time, the network began to experience a slowdown in the number of transactions it could process as Bitcoin became more popular. Developers traced this issue back to the size limit of the blocks within the blockchain.
How SegWit Addressed the Issue
SegWit was the solution to a blockchain size limitation problem that reduced Bitcoin transaction speed. Bitcoin developer Dr. Pieter Wuille suggested that to solve this problem, the digital signature of the transaction witness needed to be segregated from the transaction data.
SegWit moves the signature outside of the transaction data. This reduces the size required for transaction storage. Bitcoin used to have a block size limit of 1 MB, but this changed as SegWit became accepted through the network.
Bitcoin transitioned to a block weight limit under SegWit of 4 million weight units (WU). A block that does not use SegWit holds 1 million WU, while one that uses SegWit has a limit of 4 million WU. Because old blocks were limited to 1 MB, many cryptocurrency fans believe that 1 MB equals 1 million WU (the non-SegWit block limit) and then correlate the 4 million WU limit to an increase of block size to 4 MB. While there was a block size increase following SegWit's adoption, the limit is not in megabytes.
For example, block 720399 was mined on Jan. 25, 2022. It had a size of 1.558 MB but was 3.993 million WU. Block 720340 was mined 21 minutes later and was 1.457 MB with a weight of 3.993 million WU. Earlier the same day, a block was mined with a size of 1.188 MB, with 3.993 WU. This demonstrates that there is not necessarily a size limit in megabytes, but a limit based on the weight, taking the block's base size and total size into account.
This creates more space for data, which increases the speed of transaction validation. SegWit also paved the way for Bitcoin to enable smart contracts and upgrade to another version, Taproot.
Is SegWit Secure?
SegWit enhances the security of Bitcoin's blockchain by preventing transaction malleability—the ability to change small pieces of information in a block.
Why Was SegWit a Good Idea?
The cryptocurrency community still debates whether SegWit is good or bad, but security enhancements and decreased transaction times benefit the blockchain, miners, and nodes that accept it. SegWit led to the implementation of Taproot, an upgrade to Bitcoin built upon SegWit that allows for even faster validation.
Is SegWit a Soft Fork?
SegWit is a soft fork of the Bitcoin blockchain. Soft forks are changes that do not create a new blockchain, while a hard fork does.