Science | What is the SHA256 algorithm used for Bitcoin mining?

Video Source: Matthew Endures Teaching

Translation: Cobo Wallet

The most popular computer algorithm in the world is probably the SHA 256 hash algorithm. First look at its definition-a deterministic one-way hash function. Let's explain it word by word:

"Algorithm" is a series of steps / processes that perform operations;

"Hash function" is a mathematical function, the length of the input can be arbitrary, but the length of the output is fixed, it can be understood as the digital fingerprint of the file;

It has the characteristic of "deterministic", which means that the same input value can always get the same output value.

SHA 256 refers to a secure hash algorithm with an output value of 256 bits. What does "one-way" mean? One-way means that the function is difficult to reverse. Some functions are easy to reverse, such as adding 30, which can be reversed only by subtracting 30; but if you want to reverse the multiplication formula of two large primes, it is difficult.

The SHA 256 function is a one-way hash algorithm. The input value can be of any type and length, and the output value is 256 bits. It may be 256 1s and 0s. This is a long number, so it usually Written as a 64-bit hexadecimal number.

This formula has two interesting and practical features:

First, if you get the same hash value, or digital fingerprint, it is because you have entered the exact same input value, two different input values ​​will not result in the same output value (digital fingerprint).

What is the number of hashes-2 to the power of 256.

Another interesting feature is the butterfly effect, as long as the input value changes a little, the output value will change. For example, I'm taking a picture now, pixel: 1000×1000, file length: 24 million bits, run it with SHA 256 algorithm, and get a hash value. Now change a small unit of the input value, enlarge the pixels of this pole, change the green value from 0 to 1, and run it again with the SHA 256 algorithm to get a completely different output value. This has only changed. One of 24 million units.

The above two features help SHA 256 apply to various scenarios: cryptography, digital signature, authentication, and Bitcoin.

SHA 256 plays a key role in the Bitcoin protocol. Anyone can run this mathematical function on their own computer, but no one can reverse it. If you can reverse this algorithm, you can mine faster than others, and then make a lot of money.

The process of Bitcoin mining is to find the input value. This input value uses the SHA 256 algorithm to generate a series of output values ​​with about 70 zeros at the beginning. However, because there is no known formula, everyone can only try to count one by one by brute force until they find the correct input value. However, Bitcoin mining only needs to find a close hash value, and does not need an exact match. In fact, the difficulty of mining can be adjusted to ensure that miners can find a matching input value every ten minutes, and then earn 12.5 bitcoin block rewards, which is why I think it is the most popular algorithm on the planet, or should Said to be the most commonly used algorithm on earth.

In order to outperform the Bitcoin mining competition, people specifically use computers that can quickly run the SHA 256 algorithm. How fast?

If you add up all the Bitcoin miners in the world, they are currently calculating 600 billion hashes per second, every second, every day.

So I say that SHA 256 is the most popular algorithm, and this conclusion is quite fair. I think there may be other character processing algorithms competing with it, such as the Fourier transform function, but can it be calculated more than 600 billion times per second?

I do not know…

Anyway, I said these are to show that no one can find a shortcut to bitcoin mining. Although there is a huge economic incentive to find a shortcut, maybe someone can find it, but they will not do it, they will only choose to follow the rules …