Cryptocurrency transactions are secure and trustworthy thanks to blockchain technology. However, as with most innovative systems, the blockchain has exploitable vulnerabilities, which can lead to double spending. But what is double spending, and how is it prevented?
What Is Double Spending?
Double spending occurs when a single entity spends the same cryptocurrency token more than once. This is caused by a flaw in digital currencies that makes them easily reproducible.
The information on the blockchain network can be modified during transactions, provided certain conditions are met. When these conditions are fulfilled, the altered blocks of transactions can enter the blockchain, allowing the perpetrator to reacquire previously spent crypto tokens.
To better understand how this happens, here is a simplified process description. When a transaction is carried out on a blockchain network, say Bitcoin, it creates a block that contains the transaction data, the data from the previous block, and a time stamp. The block has an encrypted code called a hash.
The people who mine Bitcoin on the Bitcoin network then verify the transaction via a proof-of-work consensus algorithm, close the block, and create a new block. The new block contains the timestamp, the previous block’s hash, and the new transaction data. Afterward, the victorious miner receives block rewards (BTC) for verifying the hash.
To successfully execute double spending, the perpetrator has to mine a secret block that outpaces the creation of the actual block. To do this, the perpetrator has to introduce the secret block before the new block so that the network, deceived into thinking it is the latest set of the growing block, adds the fake block to the ever-increasing chain. The perpetrator can then reclaim the previously used crypto tokens.
Even though double spending is a well-known phenomenon in the crypto space, there is no documented case. That’s because verifying transactions is a complex process that requires tremendous computational power. Falsifying or duplicating a block is intense, as perpetrators must work ahead of every other miner on the blockchain.
Why Is Double Spending a Problem?
Double spending is an insult to the security of the blockchain network. It happens when there’s an exploitable weakness.
Furthermore, the blockchain network is supposed to be secure and trustworthy. If double spending occurs on a cryptocurrency network, it creates distrust for that cryptosystem, disincentivizing investors. And eventually, the value of the token will fall.
Additionally, double spending is digital theft. The hacker gains while someone else on the network, usually a merchant, loses. The perpetrator retains ownership of the merchant’s goods and the crypto token.
Examples of Double Spending Attacks
There are different forms of double-spending attacks that cyber criminals employ. Here are some of them:
51% Attack
The 51% attack is the most widely discussed form of double-spending. It occurs when a miner (or a group of miners) controls the majority (more than 50%) of the computational power validating transactions on the network.
When this happens, they can dictate transactions, create new blocks, reclaim already spent crypto, and award crypto tokens. That gives them the power to double-spend digital coins.
The 51% attack is less likely to occur in more established cryptocurrencies, like Bitcoin. This is due to the huge number of miners on the network and the hashing difficulty. However, cryptocurrencies with smaller networks, like new or forked ones, might be at risk.
In 2014, GHash.io, a mining pool that operated from 2013 to 2016, briefly surpassed 51% of Bitcoin’s computational power on Bitcoin. This development generated significant concerns over the security of the network. Then, Gnash.io voluntarily capped its computational power at 39.99% to restore trust in the network.
Finney Attack
This type of double-spending attack was popularized and named after Hal Finney. In a Finney attack, a hacker doesn’t require 51% of the hashing power. For it to be successful, a merchant must accept an unverified transaction from the hacker, who is a miner.
The hacker generates a block where he credits crypto tokens to himself by initiating a transaction from address X to address Y (both belonging to him) without broadcasting it to the network. He proceeds to make another payment with the same crypto tokens from address X to address Z, which belongs to a merchant.
If the merchant accepts the unconfirmed transactions without verification from the blockchain, the hacker then releases the block that includes his initial transaction. The network invalidates the transaction with the merchant after the merchant has released goods or services to the hacker. That permits the hacker to double-spend.
Race Attack
This attack is easier to pull off than the 51% and Finney attacks. In a race attack, a “race” exists between two transactions.
The hacker uses different machines to send the same token to two merchants. If the merchant sends goods or services before the transaction is confirmed, he’ll discover that the transaction was not accepted during the mining process.
How Blockchain Prevents Double Spending
Blockchains safeguard against double-spending through consensus algorithms, such as:
Proof-of-Work (PoW)
Proof-of-work is a highly competitive process that requires a tremendous amount of energy. In this consensus mechanism, miners use complex computers to guess the hash of transaction blocks.
A hash is an encrypted, unique 64-digit hexadecimal code every transaction possesses. This process expends computational power to prove the authenticity of a transaction.
Once the transaction is verified, the successful miner adds the transaction to the decentralized digital ledger. At the end of the process, the successful miner receives block rewards in the native digital token.
Bitcoin, Bitcoin Cash, Litecoin, Monero, and Dogecoin are popular cryptocurrencies that use this consensus algorithm.
Proof-of-Stake (PoS)
In Proof-of-Stake, the participants on the crypto network authenticate block transactions and are called validators. Validators offer (or “stake”) some of their crypto tokens in a smart contract to earn the right to verify transactions before adding them to the growing blockchain.
The network selects an honest validator based on their staked tokens and staking duration. Once selected, the winner verifies the transaction, which the other validators confirm.
Just like PoW, validators also receive a reward in the form of income after authenticating new transactions. If the network finds any validator dishonest, they lose part or all of their staked tokens as a penalty.
This process is faster and requires less computational power and energy than PoW. Therefore, participants on the blockchain can efficiently act as validators.
Ethereum 2.0, Cardano, Tezos, and Solana each use PoS.
Delegated Proof-of-Stake (DPoS)
This type of PoS consensus algorithm mandates users on the blockchain to use their digital tokens to vote for honest validators called “delegates.” One delegate is chosen randomly to validate new transactions and add them to the blockchain.
After payment, the delegate distributes the block rewards to the users that voted for them.
Cryptocurrencies that employ the DPoS algorithm include EOS, Ark, Tron, and Lisk.
No Case Yet, But Double Spending Is a Possibility
Although there are no confirmed cases, the emergence of new and forked cryptos and recent technological advancements may spring double spending surprises. Therefore, you should protect yourself by transacting on secure cryptocurrency blockchains. And as a rule, wait for miners to confirm transactions before releasing your tokens, goods, or services.