How Does Proof of Work Prevent Double Spending?
Assume that Younghee runs an online shopping mall that supports Bitcoin as a payment method. Cheol-su ordered an iPhone from Young-hee’s website. Cheol-su chooses Bitcoin as the payment method, and Young-hee will wait for the payment to be confirmed before sending the iPhone to Cheol-su.
Assume that Younghee runs an online shopping mall that supports Bitcoin as a payment method. Cheol-su ordered an iPhone from Young-hee’s website. Cheol-su chooses Bitcoin as the payment method, and Young-hee will wait for the payment to be confirmed before sending the iPhone to Cheol-su.
When Young-hee confirms the transaction message that she is sending money to her, Young-hee will send the goods to Cheol-su. However, if the transaction that sent him money was added to the blockchain before that, he would get the iPhone for free.
At this time, you might think that this problem will be solved if Young-hee does not send the iPhone after the transaction is announced, but waits for the transaction sent to her to be added to the blockchain.
However, this method is still not a sufficient solution.
This is because sometimes more than one transaction is added at the same time, creating a fork in the chain. In this situation, after completing the block, the miner can choose which transaction he wants to add. At this time, the branch formed by a certain transaction becomes longer than others. When this happens, the short branch is discarded and all transactions added to it are returned to the mempool.
For this reason, it is recommended to wait for at least 6 blocks to be added to the chain before determining that the transaction is complete. Transactions recently added to the blockchain are sometimes referred to as popular transactions.
Here again we can see how proof-of-work secures transactions.
But let’s look at another hypothesis here. What if the withdrawal creates both a branch of a block containing legitimate transactions and a branch of a block for fraudulent transactions? And let’s say the withdrawal adds to the fraudulent block at the same rate that other miners added to the legitimate transaction. After confirming that the branches with legitimate transactions are growing, Young-hee can send iPhones with confidence. However, in the end, the withdrawal will make the fraudulent branch longer, sending legitimate transactions to Mempool. However, since this legitimate transaction has the same signature as the fraudulent transaction, it will be considered invalid if selected again.
This is a very interesting hypothesis, and in theory it is possible.
In practice, however, there is no possibility that this hypothesis can be put into practice.
This is because it takes computational power and time to solve and add blocks. Even with a massive power processor, the withdrawal would have to control more than half of the CPUs on the Bitcoin network. That’s why it’s called a 51% attack.
In reality, the branch containing the legitimate transaction is longer, and the branch containing the false transaction information is sent to the mempool. Since the signature has already been used in a legitimate transaction, it cannot be valid if another miner chooses a branch with false information .
Taking all this into account, even if the withdrawal somehow gained control of the network, the time and resources it takes would be too much to spend on just cheating the system. In principle, when you mine, you can earn more bitcoins.