Segregated Witness, abbreviated as SegWit, is a solution that, in a simplistic way, is only recommended for the feature of increasing Bitcoin’s scalability and reducing its cost.
This, however, is its least significant benefit: as you can read in the developers’ discussion, the benefits have been listed in order of importance:
- Malleability Fixes
- Linear scaling of sighash operations
- Signing of input values
- Increased security for multisig via pay-to-script-hash (P2SH)
- Script versioning
- Reducing UTXO growth
- Efficiency gains when not verifying signatures
- Block capacity/size increase
- Moving towards a single combined block limit
The “Block capacity/size increase” benefit is only in eighth place, as the main improvement is the Malleability Fixes, which permanently solves the problem of transaction malleability, offering efficiency and security to:
- Wallets that keep track of spent bitcoins;
- Anyone who spends unconfirmed transactions;
- Lightning Network;
- Anyone who uses the blockchain and smart contracts.
The “Script versioning” is also very interesting for developers. It allows introducing some changes to Bitcoin’s consensus.
If we want to focus on the best known element, i.e. increasing the capacity and size of blocks, and reducing transaction costs, we need to look into some purely technical aspects of how Bitcoin operates.
Bitcoin as a store of value
For financial reasons, Satoshi Nakamoto – when he created Bitcoin – chose to set a limit and then “check” mathematically the number of BTCs that were created each year. Actually every four years, that’s when the number of BTCs created is halved.
Bitcoin – in the mind of its creator – had to be a store of value, and in fact, it does have all the characteristics: it is an asset scarce in nature, with a very expensive and complex production and with a predetermined and immutable monetary supply.
In terms of code, bitcoin has been designed so as not to be subject to inflation because the algorithm, which previously produced 50 coins every 10 minutes, now creates 12.5 due to a process called halving.
Every 4 years this reward is halved and will continue so until it reaches a value equal to one Satoshi, or one hundred millionth of a bitcoin.
Since the number of BTCs created per block is fixed and only halves every four years, it is essential to check with some precision the number of blocks created each year. From the very beginning, it has been decided to make sure that only one block is created and added to the blockchain every 10 minutes or so.
These blocks cannot be larger than 1 MB, otherwise, the blockchain would become too heavy: adding 1 MB every 10 minutes is equivalent to adding 144 MB per day, or more than 52 GB per year.
This maximum fixed size meant that there could be no more than 2,000 transactions per block. In order for transactions to be validated, they must be placed in a block added to the blockchain, this limit prevented to validate more than 2,000 transactions every 10 minutes.
Not being able to increase the size of the block, the solution to increase the number of transactions was to reduce the weight of individual transactions so that there could be more than 3,000 in each block.
The solution chosen was to segregate some information on individual transactions outside the blocks, so as to minimize the weight of information recorded on the blockchain.
In particular, with SegWit a transaction is divided into 2 segments, removing the unlocking signature (the “witness”) from the portion that is recorded on the blockchain and adding it at the bottom as a separate structure. The original section records the data of the sender and the recipient on the blockchain, while the scripts and signatures remain in the other section.
The digital signature accounts for about 65% of the weight in a transaction, so SegWit actually increases the 1 MB block size limit to just under 4 MB.
Segregated Witness – as a soft fork – was first presented by Pieter Wuille in December 2015 at the second edition of the Scaling Bitcoin workshop in Hong Kong.
Parallel to the development of SegWit, a political and ideological war broke out in the community, and it came to a clash between some companies and Bitcoin miners, led by Bitmain CEO Jihan Wu, determined to implement a hard fork to increase the block size limit to 2 megabytes.
On the Bitcoin Core Slack channel, developer Luke Dashjr decided to continue with the idea of a SegWit UASF – user activated soft fork – regardless of what the rest of the Bitcoin ecosystem would do.
This “intolerant minority” managed to prevail and for this reason on August 1st, 2017 the “Bitcoin Independence Day” was declared.
The adoption and full introduction occurred on August 23rd, 2017. Despite requiring special wallets, it is still compatible with the previous version of the protocol without SegWit, so to date, you can add both SegWit transactions and transactions without SegWit on the blockchain. The former are lighter, so they have lower costs, while the latter are the same as before.
The lower cost is due to the fact that the bytes registered on the blockchain are less, since the cost of a transaction depends, albeit indirectly, on the number of bytes.
It should be noted that SegWit transactions are now almost half of those that are added on the blockchain, as several exchanges and BTC exchange services have updated their wallets implementing this new solution.