What is Double Spending Attack?

Last Modified:1 Mar 2021 15:35:45
What is Double Spending Attack?

Bitcoin, which works on the infrastructure of Blockchain, was the first cryptocurrency to enter the market; but it wasn’t the first attempt at creating a digital monetary system.

Before Bitcoin, there have been attempts to create a digital monetary system, but all of them failed. A reason for all this failure is that in digital currencies you can copy transactions twice and effectively spend them twice. By resolving the double spending attack issue, Bitcoin was able to enter the market.

“Double Spending Attack” in Simple Terms

Since cryptocurrencies do not have a physical nature, they can easily be copied and spent again.

The nature of paper money is that by paying it the service provider confirms the payment, and you receive your chosen service; after you spent your paper money you no longer have access to it, thus you cannot spend it again. For example, imagine you have ordered a 10-dollar coffee. Then you pay it in cash with paper money. Now, this money is in the hands of the seller, and you cannot easily regain this money and spend it again unless you steal it! After you pay, the seller confirms the payment and gives you your coffee.

However, this problem exists in the field of cryptocurrencies. Bitcoin is a cryptocurrency and does not have a physical nature. Thus, Bitcoin transactions can be copied and be used again. In this example, we saw that the seller confirmed your $10 payment after you paid it. If the confirmation mechanism is lost in Bitcoin, it may lead to the “double spending” of the paid amount.

Resolving the “Double Spending” Issue by Bitcoin

The double spending issue of Bitcoin has been resolved by registering confirmations in a public ledger called “Blockchain,” whose mechanism is like that of the conventional monetary system.

Bitcoin Blockchain holds all the Bitcoin transactions (from the very creation of Bitcoin in 2009 up to now). A new block containing a large number of Bitcoin transactions is added to the public ledger. All nodes in the Bitcoin network have a copy of this public ledger (Blockchain).

How “Double Spending Attack” Occurs

The double spending attack occurs in the form of two attacks called the 51-percent attack and race attack.

In the 51-percent attack, if a person succeeds in having 51 percent of the hash power, he can perform double spending. Since controlling 51 percent of the Bitcoin network requires a high hardware power, this attack has not taken place in Bitcoin yet. This hash power depends on the network difficulty, electricity consumption, and hardware, which make performing this attack impossible.

Race attack is when you send a Bitcoin quickly and simultaneously to two addresses, one of them will surely not be confirmed. If as a seller who is awaiting payment, you do not wait for six confirmations, it is possible that the Bitcoin does not enter your account. Although this possibility is nominal, it is recommended to sellers to wait for at least six confirmations.

These attacks have not been successful in Bitcoin so far, and in order to keep a global trade according to confirmation, the Bitcoin system has not yet been the victim of these attacks.

How Bitcoin Deals with “Double Spending” Attacks

To understand this matter, suppose you have a Bitcoin, and you send it to someone. After sending it, you want to cheat and send this Bitcoin again for someone else.

These transactions enter the pool of non-confirmed transactions. Your first transaction will be put in the confirmation queue by the Bitcoin miner. However, your first transaction is confirmed and gets put in the next block; then your next transaction is regarded as non-valid by the miners and exits the network because the amount of Bitcoins in your wallet is not registered in the public ledger.

But what if both of your transactions come in the hands of the miner simultaneously? In this case, the transaction with the most confirmations is done and gets put in the block, and the other transaction does not get completed. It may not seem fair to you that the transaction of the second seller is sent out of the network, but this is the process that takes place anyway. Moreover, so, it is recommended to sellers to wait for at least six confirmations. Six confirmations mean that six other blocks each containing several transactions are added after that. These confirmations mean adding more blocks to the Blockchain. In Blockchain, each transaction and block is dependent on the previous blocks and transactions based on complicated mathematical calculations. All these confirmations are stored on the blocks like a chain, and thus reversibility becomes impossible. Consequently, the seller can only spend the coin again if all the six confirmations that are registered in six blocks after the trade are reversed. Computationally, this is impossible! If the seller gets these confirmations, he can be hopeful that the buyer has not spent his Bitcoins twice.