<blockquote>
<p>In a race, an athlete does not need to be faster than 50% of all the athletes combined. He just needs to be the fastest.</p>
</blockquote>
<p>Mining is simply not analogous to a race. Racers make progress towards the finish line, with the fastest racer eventually winning. There is no progress in bitcoin mining though: with each attempt (hash) you either find a correct block, or not.</p>
<p>So bitcoin mining is more akin to a dice-rolling game, with a poisson-distributed random chance of success for each attempt. The more hashpower you have, the more attempts you can make per second.</p>
<p>If you want to reliably out-compete the rest of the network (ie, 51% attack), you will need to have more hashpower than the rest of the network (ie, you'll need to control &gt;50% of the total hashpower pointed at the network).</p>
<blockquote>
<p>So, if there are miners M1, M2, ...Mn and mining Pools P1, P2, ..Pm in the network with Pi (1&lt;=i&lt;= m) having the highest hash power Hi, I as a dishonest miner (or pool) would need to have a mining power Hx &gt; Hi to eventually mine blocks quicker than than the rest of the network if I were working on a sidechain privately.</p>
</blockquote>
<p>In order to 51% attack, <code>Hx &gt; ((H1 + H2 + H3 + ... + Hm) / 2)</code>.</p>
<p>Considering only if <code>Hx &gt; Hi</code> is insufficient, since <code>Hi</code> is not the only other entity mining. Any miner with any amount of hashpower can win the next block (with a probability proportional to their share of the hashpower), so you need to consider all miners together in you calculation.</p>

CC BY-SA 4.0
2022-10-10T08:58:05.773Z
"Considering only if Hx > Hi is insufficient, since Hi is not the only other entity mining".
I understand this when I am competing with the other miners on the original chain. 
But, would the statement  also apply when I am mining on a secret sidechain?
For the honest miners, the algorithm works that a block takes 10 minutes on an average to be mined.
But, if I am working on a secret sidechain, I could take less than 10 minutes, and I will be the only one working on the sidechain, so I don't need to worry abt others.
So, I can build up faster than others?
I apologize if I am being thick
Shariq Hasan Khan
CC BY-SA 4.0
2022-10-10T09:13:57.610Z
Yes, the statement still applies. You can mine on your secret chain, but everyone else will be mining on the public chain, and if they collectively have more hashpower than you, then they will (on average) find more blocks per unit of time than you will on your secret chain. You *could* take less than ten minutes to find a secret block (or more), but so *could* they. Its a game of averages, and those averages are contingent upon the proportion of hashpower each miner controls.
chytrik
CC BY-SA 4.0
2022-10-10T09:51:38.713Z
I still don't get the concept of "collective hashpower". That would have made sense to me if mining was a parallel process. But it's not. As soon as a block is mined, all the work done(on finding that block) by the other miners is discarded. Only 1 miner's work wins..It is the mining power of THAT 1 miner that was eventually harnessed.
So, I don't get it.

Been reading lots on this, and still remain unclear on it.
I guess, I will have to cram this 51% hashing power thing, and forego the quest of actually understanding the WHY of it. At least for now.
Thnx for your help and @RedGrittyBrick
Shariq Hasan Khan
CC BY-SA 4.0
2022-10-10T10:48:15.153Z
Only one miner wins any given block, but that win only comes after all the miners have collectively attempted some number of hashes (on average). Failed attempts at finding a block are not 'wasted' work, they are not 'discarded', so to speak. See for example: https://bitcoin.stackexchange.com/a/113520/63872 , or this great article: https://grisha.org/blog/2018/01/23/explaining-proof-of-work/ (perhaps the "Difficulty is intergalactic" and subsequent sections in particular).
chytrik
CC BY-SA 4.0
2022-10-11T13:16:56.213Z
@chyrik. I think I understand it now. 
I will try to phrase it as a separate answer to see if I get it correct.
Shariq Hasan Khan
CC BY-SA 4.0
2022-10-10T08:36:27.703Z
2022-10-10T08:36:27.703Z
chytrik
<blockquote>
<p><strong>My understanding is that mining is like a race.</strong></p>
</blockquote>
<p>This is the misunderstanding.</p>
<p>It is more like a sandy beach where someone scattered some small diamonds. The miners rush along the beach repeatedly picking up grains of sand to see if they are worthless quartz or valuable diamond. As soon as one diamond is found the beach is closed and all miners rush to a new beach. There are a fixed number of diamonds on the beach so the more miners, the less chance one miner has. A miner with a huge fleet of $100000 500 hp sand sifting machines has a big advantage over a miner that is one man with a magnifying glass and a pair of tweezers.</p>

CC BY-SA 4.0
2022-10-10T09:04:00.630Z
I hear you. My racing analogy was bad. What would be analogous to a miner working on a private sidechain in your each-diamond example?
Shariq Hasan Khan
CC BY-SA 4.0
2022-10-10T09:09:38.130Z
Analogies always break down somewhere. Bitcoin mining is a unique game with unique characteristics. I could apply my imagination to the challenge but the result would be increasingly bizarre.
RedGrittyBrick
CC BY-SA 4.0
2022-10-10T08:41:05.480Z
2022-10-10T08:41:05.480Z
RedGrittyBrick
<p>In short, you don't. But in order to have a probability approaching 1 at time infinity, you need 50% + epsilon. There is actually a table of calculations of the chain lenghth vs overtaking probability at the end of the original white paper. Check it out!</p>

CC BY-SA 4.0
2022-10-11T06:57:46.560Z
2022-10-11T06:57:46.560Z
Hare Brained Brian
<p>I read a lot of answers and articles to try to understand it. Thankfully, it was @chytrik's answer that clicked for me.</p>
<p>Going to post my understanding here.</p>
<p>Just for this discussion, say there are 1200 possible hashes. The fastest (also the dishonest one) miner produces 60 hashes per second. Say the others are at 20 hashes per second. Further, let's assume there are a total of 11 miners (including the dishonest/fastest one) in the network.</p>
<p>The dishonest miner working on a secret sidechain alone would need 20 (1200/60) seconds to try out all possible hashes.
OTOH, the rest of the honest network is trying 200 (20*10) hashes per second. So, they would need only 6 seconds (1200/200) to try out all hashes.</p>
<p>[Sidenote] This is an oversimplified assumption though because not all of these hashes will be unique. BUT, not all of them would be identical either because one of the parameters (for generating hashes) is timestamp.
And timestamps can and will be unique for a number of nodes, because
a) not all miners start mining at the exact same moment
b) timestamps are picked from the users' machines and can be changed
c) in the real world, miners will have separate hashrate which means they will be trying the same nonce at different timestamps, resulting in different hashes.</p>
<p>So, even if all 200 hashes are not unique, many of them will still be unique, and hence even if the number of unique hashes produced by all the miners (even though working independently) might not be 200 (in the above example), they would still be much much more than the lone dishonest miner.</p>
<p>[/Sidenote]</p>
<p>In other words, the chances of one of the hashes produced by the honest miners being the right one are much higher than that of the dishonest miner being right.</p>
<p>For the dishonest miner to try out all the hashes before the rest of the network, they would have to produce more than 200 hashes per second i.e. (&lt;= 200 + x) hashes/sec . With the upgrade in the capacity of the dishonest miner, the collective capacity of the network is 200 (from the 10 honest miners) + (200 + x) from the dishonest miner = 400 + x</p>
<p>50 percent of the network power = (400 + x)/2 = 200 + (x/2)
And dishonest miner's hashing power = 200 + x  &gt; 200 + x/2
Hence, the term 51% attack</p>

CC BY-SA 4.0
2022-10-11T13:26:35.833Z
2022-10-11T13:26:35.833Z
Shariq Hasan Khan
<p>I am really struggling to understand this thing about the 51% attack.
Usually whoever mines a block first wins.
My understanding is that mining is like a race. In a race, an athlete does not need to be faster than 50% of all the athletes combined. He just needs to be the fastest.</p>
<p>It's not like the entire network is working together as a single unit to solve the puzzle. They are working as separate entities, so their computational power isn't being added up.</p>
<p>So, if there are miners <em>M1</em>, <em>M2</em>, ...<em>Mn</em> and mining Pools <em>P1</em>, <em>P2</em>, ..<em>Pm</em> in the network with <em>Pi</em> (1&lt;=i&lt;= m) having the highest hash power <em>Hi</em>, I as a dishonest miner (or pool) would need to have a mining power <em>Hx</em> <em>&gt;</em> <em>Hi</em> to eventually mine blocks quicker than than the rest of the network if I were working on a sidechain privately.
And when the time is apt, I can broadcast my sidechain which will became the main chain.</p>
<p>I understand my reasoning is flawed somehow, but I don't understand which part and why.
Can someone please shed some light on it?</p>

<proof-of-work><attack><majority-attack>
Why does an attacker need 51% mining power to overtake the blockchain?
Shariq Hasan Khan
# Why does an attacker need 51% mining power to overtake the blockchain?

(Asked by: username_0 on 2022-10-10)

I am really struggling to understand this thing about the 51% attack.
Usually whoever mines a block first wins.
My understanding is that mining is like a race. In a race, an athlete does not need to be faster than 50% of all the athletes combined. He just needs to be the fastest.

It's not like the entire network is working together as a single unit to solve the puzzle. They are working as separate entities, so their computational power isn't being added up.

So, if there are miners *M1*, *M2*, ...*Mn* and mining Pools *P1*, *P2*, ..*Pm* in the network with *Pi* (1<=i<= m) having the highest hash power *Hi*, I as a dishonest miner (or pool) would need to have a mining power *Hx* *>* *Hi* to eventually mine blocks quicker than than the rest of the network if I were working on a sidechain privately.
And when the time is apt, I can broadcast my sidechain which will became the main chain.

I understand my reasoning is flawed somehow, but I don't understand which part and why.
Can someone please shed some light on it?

**Tags:** proof-of-work, attack, majority-attack


---

## 4 answers

### Answer by username_1 on 2022-10-10. Score: 1 | Accepted answer

> In a race, an athlete does not need to be faster than 50% of all the athletes combined. He just needs to be the fastest.

Mining is simply not analogous to a race. Racers make progress towards the finish line, with the fastest racer eventually winning. There is no progress in bitcoin mining though: with each attempt (hash) you either find a correct block, or not.

So bitcoin mining is more akin to a dice-rolling game, with a poisson-distributed random chance of success for each attempt. The more hashpower you have, the more attempts you can make per second.

If you want to reliably out-compete the rest of the network (ie, 51% attack), you will need to have more hashpower than the rest of the network (ie, you'll need to control >50% of the total hashpower pointed at the network).

> So, if there are miners M1, M2, ...Mn and mining Pools P1, P2, ..Pm in the network with Pi (1<=i<= m) having the highest hash power Hi, I as a dishonest miner (or pool) would need to have a mining power Hx > Hi to eventually mine blocks quicker than than the rest of the network if I were working on a sidechain privately.

In order to 51% attack, `Hx > ((H1 + H2 + H3 + ... + Hm) / 2)`.

Considering only if `Hx > Hi` is insufficient, since `Hi` is not the only other entity mining. Any miner with any amount of hashpower can win the next block (with a probability proportional to their share of the hashpower), so you need to consider all miners together in you calculation.

> **Comments:**
> **username_0**: "Considering only if Hx > Hi is insufficient, since Hi is not the only other entity mining". I understand this when I am competing with the other miners on the original chain.  But, would the statement  also apply when I am mining on a secret sidechain? For the honest miners, the algorithm works that a block takes 10 minutes on an average to be mined. But, if I am working on a secret sidechain, I could take less than 10 minutes, and I will be the only one working on the sidechain, so I don't need to worry abt others. So, I can build up faster than others? I apologize if I am being thick  
> **username_1**: Yes, the statement still applies. You can mine on your secret chain, but everyone else will be mining on the public chain, and if they collectively have more hashpower than you, then they will (on average) find more blocks per unit of time than you will on your secret chain. You *could* take less than ten minutes to find a secret block (or more), but so *could* they. Its a game of averages, and those averages are contingent upon the proportion of hashpower each miner controls.  
> **username_0**: I still don't get the concept of "collective hashpower". That would have made sense to me if mining was a parallel process. But it's not. As soon as a block is mined, all the work done(on finding that block) by the other miners is discarded. Only 1 miner's work wins..It is the mining power of THAT 1 miner that was eventually harnessed. So, I don't get it.  Been reading lots on this, and still remain unclear on it. I guess, I will have to cram this 51% hashing power thing, and forego the quest of actually understanding the WHY of it. At least for now. Thnx for your help and @username_2  
> **username_1**: Only one miner wins any given block, but that win only comes after all the miners have collectively attempted some number of hashes (on average). Failed attempts at finding a block are not 'wasted' work, they are not 'discarded', so to speak. See for example: https://bitcoin.stackexchange.com/a/113520/63872 , or this great article: https://grisha.org/blog/2018/01/23/explaining-proof-of-work/ (perhaps the "Difficulty is intergalactic" and subsequent sections in particular).  
> **username_0**: @chyrik. I think I understand it now.  I will try to phrase it as a separate answer to see if I get it correct.  

---

### Answer by username_2 on 2022-10-10. Score: 3

> **My understanding is that mining is like a race.**

This is the misunderstanding.

It is more like a sandy beach where someone scattered some small diamonds. The miners rush along the beach repeatedly picking up grains of sand to see if they are worthless quartz or valuable diamond. As soon as one diamond is found the beach is closed and all miners rush to a new beach. There are a fixed number of diamonds on the beach so the more miners, the less chance one miner has. A miner with a huge fleet of $100000 500 hp sand sifting machines has a big advantage over a miner that is one man with a magnifying glass and a pair of tweezers.

> **Comments:**
> **username_0**: I hear you. My racing analogy was bad. What would be analogous to a miner working on a private sidechain in your each-diamond example?  
> **username_2**: Analogies always break down somewhere. Bitcoin mining is a unique game with unique characteristics. I could apply my imagination to the challenge but the result would be increasingly bizarre.  

---

### Answer by username_3 on 2022-10-11. Score: 1

In short, you don't. But in order to have a probability approaching 1 at time infinity, you need 50% + epsilon. There is actually a table of calculations of the chain lenghth vs overtaking probability at the end of the original white paper. Check it out!


---

### Answer by username_0 on 2022-10-11. Score: 0

I read a lot of answers and articles to try to understand it. Thankfully, it was @username_1's answer that clicked for me.

Going to post my understanding here.

Just for this discussion, say there are 1200 possible hashes. The fastest (also the dishonest one) miner produces 60 hashes per second. Say the others are at 20 hashes per second. Further, let's assume there are a total of 11 miners (including the dishonest/fastest one) in the network.

The dishonest miner working on a secret sidechain alone would need 20 (1200/60) seconds to try out all possible hashes.
OTOH, the rest of the honest network is trying 200 (20\*10) hashes per second. So, they would need only 6 seconds (1200/200) to try out all hashes.

[Sidenote] This is an oversimplified assumption though because not all of these hashes will be unique. BUT, not all of them would be identical either because one of the parameters (for generating hashes) is timestamp.
And timestamps can and will be unique for a number of nodes, because
a) not all miners start mining at the exact same moment
b) timestamps are picked from the users' machines and can be changed
c) in the real world, miners will have separate hashrate which means they will be trying the same nonce at different timestamps, resulting in different hashes.

So, even if all 200 hashes are not unique, many of them will still be unique, and hence even if the number of unique hashes produced by all the miners (even though working independently) might not be 200 (in the above example), they would still be much much more than the lone dishonest miner.

[/Sidenote]

In other words, the chances of one of the hashes produced by the honest miners being the right one are much higher than that of the dishonest miner being right.

For the dishonest miner to try out all the hashes before the rest of the network, they would have to produce more than 200 hashes per second i.e. (<= 200 + x) hashes/sec . With the upgrade in the capacity of the dishonest miner, the collective capacity of the network is 200 (from the 10 honest miners) + (200 + x) from the dishonest miner = 400 + x

50 percent of the network power = (400 + x)/2 = 200 + (x/2)
And dishonest miner's hashing power = 200 + x > 200 + x/2
Hence, the term 51% attack


---

