Mining, what is it really like?

We have previously written about the role of proof-of-work in bitcoin and how it creates digital scarcity by converting energy into hashes. But what exactly is all that computing power doing? The goal of proof-of-work is to generate a piece of data that is difficult to replicate but easy for others to verify. Producing a valid piece of proof-of-work, a valid hash, is a random process. As a result, there is no algorithm that can find the solution faster or smarter. A valid proof-of-work is a value lower than the current target. In this article we explain how this works.

We hash it out

These are terms that have come up before: hashing, a hash, hashes and hash functions. A hash function is an algorithm that, given a certain input, generates a unique output. It is not possible to calculate back what the input was from the generated output, but it is possible, given the input, to check that the previously displayed output is correct by running the algorithm again with the input. In this case, the unique output is a hash .

Data hashing is a common principle that can be found throughout computer science. You also use it daily in the background when browsing the internet. For example, when you create a new password, it is stored hashed; completely unrecognizable. As a result, the party where you store your password cannot see your password and a potential hacker cannot just take off with your password.

The combined computing power of the bitcoin network (above and here) is all about executing a huge amount of hashes. This is done by specialized hardware, seen here. They do this in order to find a valid hash of a block, which allows them to claim the reward of freshly created bitcoins. A valid hash is one that satisfies a number of conditions.

Target?

The most important of these conditions is to find a value that is lower than the current target . The current target is an indication of the current difficulty level. We can best explain this with a simple example.

We are going to hash a simple piece of data with the SHA-256 algorithm, a commonly used algorithm and also the algorithm that the bitcoin miners use. The data we’re going to hash is the phrase “Hello, world!” and the intended target we set ourselves is to find a hash that starts with four zeros. So you could say that the difficulty level is “4”. When we simply hash the sentence once, the following sequence is obtained:

315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3

Unfortunately, this one doesn’t start with four zeros. But what else can we do to change this hash? However, each input has only one unique output. Bitcoin uses a nonce for this, which is an ordinary number that is added to the original data. For example: “Hello, world! 1 “. Adding a random number completely changes the hash:

e9afc424b79e4f6ab42d99c81156d3a17228d6e1eef4139be78e948a9332a7d8

Unfortunately, this again does not return a hash that starts with four zeros. We will have to change the number and try again, we do this by systematically incrementing the number; “Hello, world!2”, “Hello, world!3”, “Hello, world!500”, and so on. We do this until we encounter the desired hash. In this case we need to increase the number up to 4250. The data “Hello, world!4250” gives the hash:

0000c3af42fc31103f1fdc0151fa747ff87349a4714df7cc52ea464e12dcd4e9

Now we have reached our goal. Finding a valid proof-of-work in bitcoin works almost the same, only the entered data is different and the target changes regularly.

Once every 10 minutes

The data used in mining to calculate the valid hash is the data that goes into the current block and is therefore unique. Part of this data is the hash of the previous block. As a result, it is not possible to take a fixed lead and calculate the next block in advance. It is necessary to wait until the solution of the last block is known before the miners can start with the next block. This helps keep things fair.

The difficulty of finding a valid hash is such that it takes an average of 10 minutes before the next solution is found. But what if a miner adds a lot of extra computing power to the network, then the solution is found much faster? This would indeed be the case. As a solution to this, the difficulty is designed to automatically adjust itself to the amount of computing power in the network.

If there is a lot of computing power in the network, so that solutions are found on average faster than once every 10 minutes, the degree of difficulty is increased. This happens once every 2016 blocks, approximately every two weeks. When the difficulty level is increased, the target is lowered. This means that the value of the hash to be found is made smaller. Where this used to be four zeros in our example, the target now becomes a hash that starts with five zeros. As a result, a lot more attempts have to be made before the valid solution is found. The difficulty level can be lowered in the same way. When there is less computing power in the network than before, the target is increased from, for example, a hash that starts with five zeros back to a hash that starts with four zeros.

In this way, finding a new block is limited to an average of once every 10 minutes. This is important to keep mining fair for all participants, but also to ensure that the rest of the network has time to receive and process the most recent blocks. This prevents some participants in the network from falling behind and possibly not being able to catch up.

Egg, right?

Again in short: one takes the data for the next block, the hash of the last block and starts hashing it in combination with an extra number that increments with each attempt. When the hash is found with the correct number of zeros, currently 18 zeros, the right to claim fresh bitcoins is won and all miners get to work on the next block. Because the hash of the last block is always included in the next block, a chain of hashes is created: the blockchain.

Mining that? So simple guesswork, based on randomness and a completely self-regulating system that no one can influence. Perhaps not the most interesting part of bitcoin, with all those hashes and other technical terms, but at the same time it has a major impact on bitcoin as a whole.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

© 2024 Cryptocoin Budisma.net