Coin Hopping Attack : How did c0ban (First ICO in Japan) deal with it using LWMA ?

Dayal Chand Aichara
5 min readFeb 7, 2019

--

Hopping attacks were started when crypto currencies prices were so high. In 2018, most hopping attacks happened. Hopping attack is a method to increase mining efficiency Which is caused by Malicious minor to increase their profit. Hopping attack create delay in new block generation.

What is coin hopping attack?

We consider the following attack involving an adversarial miner A:

— There are at least 2 possible coins (C1,C2) A can contribute to. Without a loss of generality, we assume that each of them provides about the same profitability of the mining activity.

— A is mining coin C2 before the beginning of an epoch A. At the beginning of A he is switching to mine coin C1.

— Without the contribution of miner A the total mining power of the C2 network for the epoch decreases.

— For an epoch B right after epoch A, the difficulty of C2 is to be readjusted to a lower value. So A starts mining C2 again with a lower difficulty.

We call this strategy a coin-hopping attack. (Reference)

What is c0ban?

c0ban , the first ICO from Japan, is a bitcoin based cryptocurrency. C0ban is named after Middle Ages Samurai coin called Koban.

Fig 1. c0ban’s Specifications

Let’s take a look when c0ban blockchain faced coin hopping attacks and how much that affected block generation. I will explain in details through visualization of hash rate, difficulty, blocks, average block generation interval, and latency in block generation.

Fig 2. Difficulty Vs Block Height

From figure 2, we can clearly see,

  1. Coin Hopping Attack (CHA)greatly affected block generation from March, 2018 to September, 2018.
  2. c0ban faced CHA from November 2017 to September 2018.
  3. After a point c0ban blockchain couldn’t resist CHA, that cause delay in block generation.
  4. Hopping attack period is quite large (around 11 months). But it affected chain only from March, 2018 to September, 2018.
Fig 3. Daily Hash Rate Vs Daily Difficulty

Figure 3 shows how CHA attack created variations in difficulty and hash rate. Hash rate reached over hundred billion MH/s in August, 2018 when CHA was extreme.

Fig 4. Daily Difficulty Vs Daily Blocks

Figure 4 indicates that as CHA increases, number of blocks decreases because CHA increase block generation interval.

To observe CHA affect more clearly on block generation interval, let’s make bar plot of weekly and monthly data (Difficulty and #Blocks).

Fig 5. Bar plot of weekly difficulty and weekly blocks.
Fig 6 Bar plot of monthly difficulty and monthly blocks

Bar plots (Fig. 5 and Fig 6) shows that coin hopping attack was at extreme in August 2018 which led to reduce block generation by 74.18 % (considering an ideal case 2700 blocks per day with an average block generation interval 32 seconds ). 1786 blocks were generated from July 30, 2018 to August 5, 2018 which is the lowest weekly count (9.45% of ideal case)of the all time.

Let’s visualize block generation interval before, during, and after coin hopping attacks.

Fig 7. Weekly average block generation time bar plot
Fig 8. Monthly average block generation time

Figure 7 shows weekly average block generation interval and figure 8 shows monthly average block generation interval in seconds. During CHA, weekly block generation interval has reached as high as 338.86 seconds which is more than 10 times of ideal block generation interval. Monthly average block generation interval was highest in august (123.97 seconds) which resulted in lowest blocks generation of all time.

Adoption of LWMA to deal with CHA

c0ban is a bitcoin based crypto currency which has been using bitcoin’s basic difficulty adjustment algorithm before adoption to LWMA. Linear Weighted Moving Average (LWMA) algorithm calculates new value based on last N values. In crypto, LWMA uses last N blocks’ difficulty to recalculated difficulty. The most import part, in implementing LWMA, is selection of averaging window size (number of blocks). Low N increases speed of response but it decreases stability because speed is proportional to 1/N while stability is proportional to SQRT(N). In other words, it’s easier to get speed from low N than it is to get stability from high N.

Mr. Naritaka Kobayashi and his team did four simulations at N = 64, 32, 8, ,4 using LWMA on c0ban blockchain. N =8 gave best results in terms of stability and speed of response. c0ban Project implemented LWMA with N =8 on September 7, 2018 at block height 1,450,888 which recalculate difficulty after every block. As result of LWMA adoption:

  1. Coin hopping attacks stopped completely. (See fig 2 and 4)
  2. Block generation interval become normal, and is within acceptable range. (See fig 7 and 8)
  3. Number of blocks increased. (see fig 5 and 6)

Note: There is little latency (4.28–5.34 %, Fig 9) after LWMA adoption because averaging window size (N) is 8 that causes delay in response, but good for stability. It is within acceptable range. c0ban Project team is working to decrease speed of response while maintaining stability.

Fig 9. Bar plot of monthly latency before, during and after CHA

C0ban Project is open source now. Therefore, anyone can suggest improvements and can use to develop blockchain services.

PS : This is my first article on Medium.I would appreciate your feedback. Thank You.

If you are into blockchain and cryptocurrencies analysis, please join our Telegram Channel.

--

--

Dayal Chand Aichara

Data Scientist at KPMG Ignition Tokyo , Blockchain Enthusiast, Traveller, Trekker — https://www.linkedin.com/in/dcaichara/