paint-brush
How Profitable it is to do a 51% attack — a very simple step by step calculationby@brucefeynman
1,088 reads
1,088 reads

How Profitable it is to do a 51% attack — a very simple step by step calculation

by Bruce FeynmanAugust 2nd, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

A series of attacks happens recently, from <a href="https://hackernoon.com/tagged/bitcoin" target="_blank">Bitcoin</a> Gold to Verge and now Litecoin cash. At first, people were shocked by those “accidents”, the price dropped significantly and everyone was worrying about their investment.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail

Coin Mentioned

Mention Thumbnail
featured image - How Profitable it is to do a 51% attack — a very simple step by step calculation
Bruce Feynman HackerNoon profile picture

“With adequate profit, capital is very bold. A certain 10 per cent. will ensure its employment anywhere; 20 per cent. certain will produce eagerness; 50 per cent., positive audacity; 100 per cent. will make it ready to trample on all human laws; 300 per cent., and there is not a crime at which it will scruple, nor a risk it will not run, even to the chance of its owner being hanged. ”

(T. J. Dunning, l. c., pp. 35, 36.)

A series of attacks happens recently, from Bitcoin Gold to Verge and now Litecoin cash. At first, people were shocked by those “accidents”, the price dropped significantly and everyone was worrying about their investment.

However, after the event, those dev teams would make announcements that they had changed their crypto for a safer hash algorithm or adding more confirmation blocks. Investors finally took a deep breath and thanked god, their assets were protected.

This cycle repeats again and again. To be frank, after those three attacks in 2018, I am accustomed to this newly trend. 51% attack is the new fashion in crypto world.

Although a lot of measures have been taken to deal with this problem, most of them are barely procrastinations. They only slow the attackers down and never stop the boom. For those coins which are currently safe at the moment, Great danger is waiting for them ahead.

In order for us to understand the deep reason for those attacks, we have to absorb a criminal or attacker’s motive. Why are they doing this? Money, reputation? When we shift our attention to Money and to be specific, the return ratio of an attack, things start to sort out……

Cost and Profit Analysis

Here, we use a simple cost and profit analysis for a 51% attack. Every one with basic Algebra knowledge will be able to analyze the data and get the result.

The current time is 15:00 Aug 2nd, 2018. All the following analysis is based on this time.

For example, we will use Monoeci……

It is a very small coin but you get the general idea.

First, we want to know Monoeci’s entire netHash. I use whattomine to get its NetHash, 2.47Th/s. And the Block time is 2 minutes.

https://whattomine.com/asic

And we can easily see the hash function it uses is X11.

Then we go to niceHash to buy some X11 hashing power.

https://www.nicehash.com/marketplace/x11?lang=en

From niceHash’s order book, we can see that currently there are 267+225 Th/s to sell. So we can buy more than 51% hashing power to attack Monoeci.

And we need to be careful here. Because we are pouring new hashing power into the network, we actually have to buy 2.47*51/50= 2.519 Th/s to compress others and be able to attack as we wish.

Then we calculate the price to buy those hashing power for 1 second.

https://www.nicehash.com/doc-api

Using niceHash’s API, we can get the average price for X11. Here, X11 is algorithm 3.

So the average price is 0.0196. We also should be careful here. the price is 0.0196 BTC/TH/DAY as we can see from the order book above. And we need to exchange it into USD/TH/s for us to calculate the cost.

https://api.nicehash.com/api?method=stats.global.24h

Today’s BTC price is 7707 USD. So 0.0196 BTC/TH/DAY =0.0196*7707/(24*3600) = 0.001748 USD TH/s. We have to buy additional 51% hash, that is 2.519 Th. The final result for 51% attack 1s is 0.004404 USD.

https://coinmarketcap.com/

But we can not attack for 1s and successfully double spend. We need to attack for several blocks before the transaction is confirmed valid. From whattomine API, the block time for Monoeci is 2 minutes, 120s. So attacking for one block’s cost is 0.528USD.

Now we arrive at a very interesting part. I’ve heard of 51% attack, but what is the narrative? How does it work?

How Double Spend works?

51% attack doesn’t mean you can get everybody’s money, (BTW, if you are interest in that, look for smart contract attack.) but double spending one’s coins to another address rather than the original address.

Usually, attacker may choose to double spend their coins to Exchange. If you want to get someone’s money, you will always look for someone’s vault. Here, attacker just target Exchange’s wallet. That’s one of the wealthiest wallet in the crypto world.

Attacker will deposit their coins into exchange(the coin they are going to attack), then they exchange them into other coins with more liquidity.(BTC/ETH) Next, they withdraw the other coins back to their wallet and double spend the previous transaction into their wallet.

A detailed explanation can be seen here:https://cryptoattack.io/51attack/intro

That’s how 51% attack/double spend attack usually works. And we get back to our analysis.

Back to Our Analysis

If the target is an exchange, the attacker may exchange all their current coins into other coins, so they are looking for max liquidity here and price is not that matters.

In real scenario, attacker may choose to take all the orders in an order book to achieve max liquidity and get other coins back ASAP. So, in our analysis, we just assume that an attacker may take 2h trading volume of the biggest exchange for that specific coin.

For Monoeci, the biggest exchange is cryptopia and the volume is 231494. For 2h’s trading volume, we get 19,291.17 USD. That is the possible profit of an 51% attack.

https://coinmarketcap.com/currencies/monacocoin/#markets

What about the cost?

Usually Exchange may take 3–6 blocks’ time as confirmation time. We just assume the attacker will wait for 6 blocks, then exchange their coins out and double spend. To continue our calculation, the cost for one 51% attack is 3.168USD.

Can you see the result here?

The return ratio is huge !!!

608900% !!!

This is much more profitable than invest in Ethereum in the beginning…… When there is a strong motive, there are attackers. You guess……

Just like time complexity analysis, we can focus on the magnitude instead of the constant.

So will increasing block confirmation time work? For some, it works, but for others, you have to prolong the confirmation time to another magnitude.

Changing Algorithm may work. it depends on what hash algorithm you are changing into. If it is a popular one, you are still under enormous risk cause people can buy hash power very easy and cheap.

A better solution is to use POS instead of POW. But copy paste seems not working here. This is not like fork Bitcoin or Litecoin code, you simple click fork on Github…... The developing team may still searching for some solutions on Google 😎.

For Investors

Investors should be warned. So my friend and I create this website: https://cryptoattack.io/ to give you some insight on the attack risk on some of the coins and help you make better decisions.

https://cryptoattack.io/

We use the same calculation here and the data is updated every 10 minutes.

https://cryptoattack.io/risk/coin/5b29c97821903d6ebc560374

Be wise!