Segregated witness, or SegWit as it is commonly called, has just been implemented on the Bitcoin Blockchain and was deployed on the LiteCoin network back in May of this year. Although this has become so much of the public lexicon, you may have no idea of what Segregated Witness is.
Essentially, SegWit is a space saving initiative to free up storage on Bitcoin Blocks among other things. All of the data that is related to the signature of the transaction is removed. The hope was that this freeing up of space on blocks could mean more transactions per block.
The SegWit idea was released in October of 2016. It was the result of one long year of discussion and work that was undertaken at the Bitcoin Scaling Conference in Hong Kong. The idea was the initial proposal by Pieter Wuille who was part of the Bitcoin core team.
Page Contents 👉
Technical Explanation of Segregated Witness
We have covered Bitcoin blocks and mining in greater detail before so for this explanation we will assume that you have a basic understanding. In every Bitcoin transaction there is a scriptSig and scriptPubKey. The former is where the signature data is saved whereas the latter is information about the public key.
What was noticed about the manner in which the signature data was stored is that signatures take up about 60% of the space but are only ever really needed at the time of validation of the block. The idea was therefore to separate these unlocking codes from the transaction in a segregated witness.
This segregated portion of the transaction will not be hashed together with the other transaction data. This new structure of a Bitcoin transaction is backwards compatible and hence can be implemented with a soft fork. Not all miners have to be able to validate segregated witness enabled transactions. In order for it to work effectively, at least 95% of miners have to signal their support for it.
What are the Benefits
As most Bitcoin users will have picked up recently, Bitcoin transactions are taking much longer than usual. This is to do with usual capacity constraints which is impacting on the speed of the network. The block size limit has also been a point of contention.
However, by separating out the signature data as a segregated witness, more space is saved and hence more transactions can be processed per block. There are a number of other benefits to the Segregated Witness proposal though.
Transaction Malleability Fixes
Transaction malleability is when a transaction ID can be changed by altering information contained in the unlocking code. Essentially, when you send a transaction on the network, any other node has the ability to change the transaction ID before passing sending it to the next node. This can be somewhat annoying for the users who are tracking their transactions.
With Segwit, the signing data is not included in the transaction data so no node can alter the transaction ID. This will make the transaction reliable. It will also benefit all of those individuals who are spending unconfirmed transactions. Yet, most importantly, this lays the groundwork for the Lightning Network implementation.
Increased Security for Multisig Transactions
The current security protocols for Multi Signature transactions is the P2SH which uses a 160 bit hash function. Using incredibly powerful computer resources, an attacker could try and find a “collision” between a valid address as part of a multisig script and a script that transfers them all the funds.
With SegWit, script payments are hashed with a 256-bit SHA256 hashing algorithm. This means that the chances of a collision from a brute force attack are dramatically reduced for multisig payments. This is also of great benefit to anyone paying via multisig or smart contract.
Linear Scaling of SigHash Operations
When it comes the amount of data that has to be hashed for a transaction, current protocol has it as a quadratic function in the signature operations. Doubling the size of a transaction usually doubles both the number of signature operations as well the amount of data that has to be hashed for those signatures.
SegWit is able to resolve this by changing the calculation of the transaction hash for the signature such that each byte of data only has to be hashed once. This means that the verification time is a linear function. This will make scaling block size safer and allow for much larger transactions like those being paid to miners or crowdfunders.
The 95% consensus requirement was eventually met and SegWit was officially activated on the Bitcoin network on the 23 August 2017. There were a number of parties to celebrate this important milestone in the Bitcoin journey. Indeed, many of those who had been waiting for the moment were excited about the implications of eventually Lightning Network implementation.
How long it takes before the majority of transactions are SegWit transactions is not certain but you can easily track the adoption on sites such as segwit.party.
Featured Image via Fotolia