Hello!

© 2024 Kishan Kumar. All rights reserved.

What does Hashrate mean in the Bitcoin Network?

Hashrate is a measure of the computing power of a network that uses the Proof-of-Work (PoW) consensus mechanism, such as Bitcoin.

Jun 18, 2023

Hero

If you are active on Twitter, you often see tweets like the Bitcoin network is at its all-time high Hashrate. A tweet like this:

These numbers are stupendously large. At the time of writing, the hashrate is 391.96 EH/s or 391,958,260,757,078,500,000 H/s.

These numbers will only make sense if you know what hashrate is and what it means in the context of the Bitcoin network. In this article, I'll explain it using examples so that by the end of this article, you'll be able to make sense of it.

If I ask you what 5 * 5 is, and you take 1 sec to answer me, you can solve one math problem per second. Does that make sense?

What if I gave you the following mathematical problems, and how long did it take you to answer me?

  • 23 * 7, 2.5s
  • 5 * 5, 1s
  • 1 * 9, 0.5s
  • 4 * 40, 1s
  • 13 * 15, 5s
Total questions asked = 5
Total time taken = 10s (2.5 + 1 + 0.5 + 1 + 5)

Suppose someone asks me how many mathematics problems you solved in 1 second. Using the Unitary method, we'll come up with 5 / 10 = 0.5 maths/sec.

Please keep this analogy in mind. This will help us understand the hashrate. Now let's explain what a hashrate is:

Hashrate is a measure of the computing power of a network that uses the Proof-of-Work (PoW) consensus mechanism, such as Bitcoin. It indicates how many times per second the miners can attempt to solve a mathematical puzzle that validates transactions and creates new blocks.

Now using our analogy, consider yourself a miner and the puzzle as the mathematical problem I gave you. We do not measure it as maths/sec because that'll be hilarious.

Hashrate is usually measured in hashes per second (H/s) or multiples of it, such as kilohashes per second (KH/s), megahashes per second (MH/s), gigahashes per second (GH/s), terahashes per second (TH/s), petahashes per second (PH/s), and exahashes per second (EH/s). We'll soon understand why one is using the term hash.

Hell yeah. To the Moon.

Does an increase in hashrate makes the network secure?

The higher the hashrate, the more secure and efficient the network is. A high hashrate means that more miners are competing to solve the puzzle, making it harder for anyone to attack or manipulate the network by creating a long chain of blocks that overrides the existing one. To do so, an attacker would need to have more than 50% of the network's total hashrate, which is very unlikely and expensive.Therefore, a higher hashrate means higher trust and confidence in the network. It also means the network can process more transactions faster and with lower fees.

Hashrates aren't constant; they fluctuate depending on various factors, such as the number and performance of miners, the puzzle's difficulty, the price and profitability of the cryptocurrency, and external events such as regulations, hacks, or forks.

When the hashrate increases, this means more miners are joining the network or upgrading their equipment. This makes the network more secure and faster but also increases the puzzle's difficulty, which requires more energy and resources from the miners. When the hashrate decreases, it means that some miners are leaving the network or reducing their activity. This makes the network less secure and slower but also decreases the puzzle's difficulty, making it easier and cheaper for the remaining miners to mine.

What are the miners solving?

In our example, you were solving simple arithmetic. Do miners solve that only? No, miners solve way complex problems or puzzles.

Miners be Mooooo

The Puzzle

I'll simplify this puzzle using our simple arithmetic example. If I say, can you find the value x that satisfies 2 * x = 100 without using any division operation? All you are required to do is hit and trial.

How will you go about this problem?

Well, you can try every number and see if it holds equality. Such as, you'll begin a loop and first put x = 1, then 2, 3, 4, 5, 6.. and so on, until you hit x = 50. At that point, the equation will hold the equality, and the solution to the above problem will be 50.

If you took one second for each step, i.e., 2 * 1 = 2 (1s), 2 * 2 = 4 (1s), 2 * 3 = 6 (1s), and so on.

How many seconds would it take you to find the answer?

Of course, 50s, because each operation took 1s.

Our miners solve something similar.

A mathematical puzzle miners must solve is a one-way function that takes an input and produces an output that meets specific criteria.For example, in Bitcoin, the input is the block header, which contains information such as the previous block hash, the transactions in the block, and a random number called a nonce. The output is the block header's hash, which is a fixed-length string of alphanumeric characters.

To compute the hash, the miner has to use a hash function, which is a mathematical algorithm that maps any input to an output of a fixed size. For example, Bitcoin uses the SHA-256 hash function, which produces a 256-bit output.

A hash function has the property that it is easy to compute the output given the input but hard to find the input given the output.

The puzzle miners have to solve is finding a nonce (a random number) that makes the block header's hash start with a certain number of zeros. The number of zeros required depends on the network's difficulty, which adjusts every 2016 block to keep the average time between blocks at 10 minutes. The more zeros are needed, the harder it is to find a valid nonce.

To solve the puzzle, miners must try different nonces until they find one that produces a valid hash. This process is essentially guessing and checking and requires a lot of computational power. The first miner who discovers a valid nonce gets to add the block to the blockchain and claim the block reward and transaction fees.

Confused? Don't worry; I'll try to clear the smoke.

Let's assume the block data is as follows. It contains information about transactions made by people.

BlockData:
{
  "nonce": 1,
  "prevhash": "232975iocsbc2984590zhdfkekro00kqabfosrf8349109",
  "timestamp": 1687029267,
  "transactions": [
    {
      "from": "alice",
      "to": "kishan",
      "amount": 1
    },
    {
      "from": "bob",
      "to": "mathew",
      "amount": 0.1
    }
  ]
}
If we pass this data to our hash function SHA256(block data), we'll get the following output: 8deba7ad61c29d9ebe58fc9cf90ca40f49514c7d6de2045b3819097708d01d75

You can verify it yourself by copying the above data and pasting it to an online SHA256 function such as Online SHA-246

But what if I told you this differs from the output I am looking for? It starts with two zeros in front. Such as: 00ad61ad61c29d9ebe58fc9cf90ca40f49514c7d6de2045b3819097708d01d75
Note: the only thing matters is the two zeros; the following values can differ.

What will you do?

The only thing you can change in the block data is nonce; others can't change. So you'll put nonce = 2 (just like we changed the value of x).

Let's try with nonce: 2; we again put it in the SHA256 function and wait for the output. The output is: 419820f168b9fb70d0b272241ab879f08f54651b4d82a2cef3f78f2a50765b7e

We check the first two digits are still not 0s. We change it to 3, 4, 5, and so on.

I've written a simple Java program to help you find the nonce. All it needs is the block data and how many zeros you expect it to have in the output. You can copy the file content from here: SHA256 Example

After knowing all these things, one shall ask the question:

Does a system capable of attempting only one nonce per second indicate that its hashrate is 1?

A big Yes. If a system can only try one nonce per second, its hashrate is one hash per second (H/s). However, most modern systems can try much more than one nonce per second, and the current hashrate of the Bitcoin network is over 300 exahashes per second (EH/s), which is 100 quintillion hashes per second.

Thank You

.   .   .

References:

    .   .   .

    The 0xkishan Newsletter

    Subscribe to the newsletter to learn more about the decentralized web, AI and technology.

    © 2024 Kishan Kumar. All rights reserved.