Segregated Witness (or SegWit) is the name of the upgrade for the Bitcoin protocol that removed signature data from transactions. The upgrade was first introduced by Bitcoin developer Peter Wuille in 2015, formalised as a Bitcoin Improvement Proposal (BIP 141) and was eventually implemented into Bitcoin on August 24, 2017.
By removing signatures from the transaction, SegWit enabled for better scaling but also fixed the transaction malleability issue that was present in Bitcoin. The presence of transaction malleability meant that the data associated with a transaction could be changed before it was confirmed and exploitation of this would make it seem like a transaction never happened.
For example, a user receiving bitcoins prior to SegWit could change the transaction ID without changing the transaction itself. When the tampered transaction is confirmed, it will seem as if the original transaction never took place. If the sender checks the blockchain, they will mistakenly think that they hadn’t sent the bitcoins.
In order to stop witness data from being used to change transaction IDs, SegWit proposed to remove signatures from the transactions and places them in a sidechain away from the main Bitcoin blockchain. To ensure the protocol upgrade remained compatible with older clients, the upgrade had to ensure witness data was still stored on the main chain. Therefore, the witness data in the sidechain is encrypted and this root code would then be stored on the main Bitcoin chain.
Positive Side Effects for Scaling
A positive side effect of removing the witness data was that it freed up to 65% of the space of each Bitcoin block, enhancing Bitcoin’s scalability. Since witness data is now recorded elsewhere, Bitcoin blocks had more space for transactions which enabled more transactions without increasing the size of the blockchain.
After solving Bitcoin’s issue of transaction malleability, SegWit also paved the way for further work on the Layer 2 scaling solution, the Lightning Network. If the malleability problem persisted as work was done on Lightning, then it could have jeopardised the second layer solution as Lightning bundles together frequent payments that are only recorded to the blockchain at the beginning and end of a series of payments.
After SegWit Bitcoin’s blocks went from having a block size limit of 1MB to a block weight limit of 4MB. The upgrade shifted the block size limit shifted into a block weight limit, which is a combination of the 1MB of information stored on the main chain plus the witness data stored on a sidechain.
How Can I Use SegWit?
Another positive effect of SegWit that follows on from the increased transaction capacity is the lower fees. To benefit from lower fees on the Bitcoin network, users would have to store, send and receive bitcoins using SegWit-enabled addresses.
There are two types of SegWit addresses, as opposed to legacy Bitcoin addresses which start with a ‘1’:
- P2SH addresses will start with a '2',
- bech32 addresses will start with 'bc1'.
To get the minimal fees, both sender and receiver should be using bech32 SegWit addresses. The more bech32 addresses that are utilised in transactions, the lower the fees are across the Bitcoin ecosystem.
Most wallets offer P2SH addresses. Some of the most popular Bitcoin wallets that offer bech32 addresses include; the Bitcoin Core client, Green wallet, Trezor, Ledger, and Samourai.
How was SegWit Implemented?
As a backward compatible upgrade for the Bitcoin protocol, SegWit was implemented as a soft fork so that nodes that updated to the newer version of the Bitcoin protocol could still communicate with older nodes that did not upgrade.
To deploy SegWit, miners were required signal readiness for the upgrade in a 2,016 block period, where 95% of blocks were required to signal support to move things forward.
Once the requirement was met, the SegWit upgrade would be activated. However, only around 30% of miners signalled support for reasons unknown. At the time, some miners were secretly optimising their mining machines with ‘AsicBoost’ which may have been a motivation. Other motivations may have involved disagreement on the technical merits of SegWit.
Thanks to the UASF (User Activated Soft Fork) movement spearheaded by Litecoin developer ‘shoalinfry’, SegWit was activated on bitcoin during August 2017. The UASF orphaned blocks that did not signal support for SegWit and essentially miners that did not follow suit would be wasting electricity.
A timeline of major events relating to SegWit is displayed below:
- November 15, 2016 - Bitcoin starts to signal for SegWit.
- January 24, 2017 - Groestlcoin becomes first coin to activate SegWit.
- January 28, 2017 - Litecoin starts to signal for SegWit.
- May 10, 2017 - Litecoin activates SegWit.
- August 1, 2017 - Bitcoin Cash continues the pre-SegWit Bitcoin chain with a User Activated Hard Fork.
- August 24, 2017 - SegWit activated on Bitcoin.
Activation of SegWit on Bitcoin was very controversial at the time, as the block size debate was raging. The block size debate was a major disagreement between ‘big blockers’, who supported on-chain scaling and wanted to lift the 1MB block size cap on Bitcoin, and ‘small blockers’, who wanted to keep the 1MB block size limit and implement SegWit to open up off-chain scaling solutions down the line.
The tensions between big blockers and small blockers eventually resulted in the Bitcoin community fracturing into two. The debate came to an end with the activation of SegWit and saw the creation of a new blockchain (Bitcoin Cash) and cryptocurrency (BCH).
There are several websites that track the adoption of SegWit, such as Segwit.space. At present, around 50 percent of all transactions are done using SegWit.