[Blah-Chain: Talk27. Protocol Update: SegWit]
Transaction Malleability
Computer programs always need to be updated to fix any bugs and problems. How about cryptocurrencies? Cryptocurrency software also needs to be improved and updated like computer programs do to fix bugs and any flaws.
The Bitcoin protocol has an issue that many consider as a major flaw; transaction malleability. To solve this, Pieter Wuille introduced an idea for Segwit as a solution at a Bitcoin conference in 2015 and after two years since its introduction, it was implemented to the Bitcoin protocol.
*Note that SegWit is a soft fork update, unlike a hard fork where new cryptocurrencies need to be created.
Before going through what SegWit is in details, let’s go over transaction malleability first.
Blockchain is a decentralized ledger of all transactions that are stored in the network. Each block contains transaction data, as well as the digital signature(witness) that approves each transaction. As the signature goes with input data, it can be manipulated.
Transaction malleability flaw allows users to intervene by modifying the signature which creates a duplicate transaction to steal Bitcoin. For a clear understanding, let’s have a look at an example.
Charles needs to send 5 bitcoins that he owes to Andy. Charles broadcasts the request to the Bitcoin network and miners will process the transaction(the information turns a computer code which is called the transaction ID). While the transaction is waiting in the queue to be confirmed, Andy alters Charles’s signature and changes its transaction ID with bad intentions. Now the network has two unconfirmed transactions.
If Andy’s altered transaction is confirmed by the network before Charles’s gets approved, it cancels out the original transaction. Now Andy can make a claim for the transaction and receive the 5 bitcoins. When Charles checks his transaction and finds out that the transaction did not sent through to Andy properly since the original transaction didn’t happen in the first place. Thus, Charles will re-send 5 bitcoins and Andy will receive 10 bitcoins in total.
This transaction malleability issue happened in 2014 to Mt. Gox, which was one of the largest Bitcoin exchanges available at that time.
SegWit, a short word for Segregated Witness, is a protocol upgrade that changes the way data is stored on a block.
When a block implements SegWit, it creates a sidechain where the signature data is stored away from the main blockchain.
This way, the signature data is stored separately so that the transaction IDs are no longer available to be altered.
SegWit not only protects from transaction malleability but also increases the block capacity to solve scalability issues.
We will go through this in the next episode.