user137069: 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?

user63872: 
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.

user85605: 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!

user13866: 
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.

137069: <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>
 63872: <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>
 85605: <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>
 13866: <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>
