# 51% Attack Explained: The Attack on A Blockchain

Attackers use 51% attacks to reverse transactions that have already taken place, in a blockchain, in what has come to be known as double spend. For instance, one can spend 5 bitcoins to purchase a motorcycle. Once the bike is delivered, logic dictates that Bitcoins are to be transferred to cater for the cost of the bike and can activate the attack.

However, on performing a 51% attack, an attacker would be able to reverse a transaction resulting in all coins used to fund the transaction being refunded. In the end, the attacker will be the owner of the motorcycle as well as the bitcoins used to buy it.

## How A 51% Attack Occurs

Whenever a transaction is carried’ out on a blockchain, be it by Bitcoin or any other cryptocurrency, it is usually put in a pool of unconfirmed transactions. Miners in return are allowed to select transactions from the pool to form a block of transactions.

For a transaction to be added into a blockchain, a miner must find a correct answer to a puzzle. Miners find solutions to complex mathematical puzzles by using computational power. The higher the computational power a miner has, the likelihood of him finding the correct answer to be allowed to add a block to a blockchain.

A correct answer to a puzzle has to be broadcasted’ to other miners and can only be accepted if all transactions in a block are valid according to the existing record on a blockchain. Corrupt miners, on the other hand, don’t broadcast solutions to the rest of the network.

What this practice does is that it always results in the formation of two versions of a blockchain. One, which is the original blockchain followed by legitimate miners and a second block chain used entirely by a corrupt miner who is not broadcasting results of a puzzle to the original network.

A corrupt miner will most of the time continue to work on his own version of the blockchain, which in this case is not broadcasted to the rest of the network. With the second blockchain now isolated from the network, the corrupt miner can spend his or her bitcoins on the truthful version of the blockchain, the one that all the miners are following.

## Democratic Governance

Blockchain is programmed in such a way that it always follows the longest chain, which is always perceived as the legitimate blockchain. Whoever has the most hashing power/computing power is likely to add blocks to a chain much faster, resulting in the longest blockchain which would end up being seen as the most legitimate.

A corrupt miner will thus try to add blocks to his chain at a much faster rate in a bid to make it longer to be considered as the legitimate chain. Once the corrupted blockchain attains the threshold to be considered the longest one, a corrupt miner, in this case, would broadcast it to the network as part of the 51% attack initiation process.

The rest of the network on detecting the newly corrupted blockchain will cease using the original legitimate blockchain and switch to the new one.

## Transaction Reversal

As soon as the corrupted blockchain is considered as the truthful chain, protocol dictates that all transactions not included in it be reversed. In this case, an attacker would end up getting a refund on all his bitcoin spent on the previous blockchain that is now considered’ illegitimate.

This s what is commonly referred to as ‘double spend’ attack or 51% attack, as the attacker ends up owning both the Motorcycle and the Bitcoins used to purchase it.

## The probability of 51% Attack Occurring

51% attacks on Bitcoin blockchain are rare because an attacker would need computing power or hashing power superseding that of millions of miners all over the world. To be able to initiate such an attack one would need to spend an enormous amount of money to acquire mining hardware capable of competing with the rest of the network.

The fact that even the most powerful computers in the world cannot compete against a pool of millions of other computers makes it extremely hard to perform such an attack. Electricity costs needed to propagate such an attack would also make the operations unrealistic.

However, that does not mean that there no other ways of initiating 51% attacks.  A bug in the code of a blockchain could in some cases open the door for a miner to produce new blocks at a much faster rate thus is in a position to initiate a 51% attack.

Such attacks are common in smaller blockchains with proof of work system as less computational power is required in this case. Bitcoin blockchain has never suffered a 51% attack in part because it boasts of an active hashing power which is hard to compromise.

## Mining Hardware Technology

There have been growing concerns in the recent past over the amount of power that mining hardware companies have accrued in the business. ASIC mining companies have enhanced their mining hardware making them extremely powerful, to the concern of most developers.

There’s growing fear that the powerful mining hardware is set to make certain mining individuals and companies with substantial financial muscle powerful than other groups. Such a move would give them the power to be in control of blockchains to the extent that they would be in a position to initiate 51% attacks if they wish.

Concerned by the threat posed by powerful ASIC mining hardware, capable of commanding high hashing power, Monero recently updated its protocol consequently blocking an ASIC mining.