TRUMP(特朗普币)芝麻开门交易所

How does the BTC mining algorithm work

Date:2024-04-08 18:24:21 Channel:Trade Read:
In today's digital currency craze, Bitcoin (BTC) is the leader, and its mining algorithm has attracted much attention. How does the BTC mining algorithm work? Next, we will delve into the mining code of this digital world.
Bitcoin’s mining algorithm is a complex and sophisticated calculation process designed to ensure the security of the network and the reliability of transactions. The algorithm is called Proof of Work (PoW), and its core principle is to verify transactions and create new blocks by calculating complex mathematical problems. This process requires large amounts of computing power and electricity, hence the name “mining.”

The four most famous international exchanges:

Binance INTL
OKX INTL
Gate.io INTL
Huobi INTL
Binance International Line OKX International Line Gate.io International Line Huobi International Line
China Line APP DL China Line APP DL
China Line APP DL
China Line APP DL

Note: The above exchange logo is the official website registration link, and the text is the APP download link.

First, let’s look at the basic principles of the BTC mining algorithm. Miners in the Bitcoin network compete to solve a mathematical puzzle to find a hash that meets specific requirements. This hash value must be smaller than the target value, which requires constantly trying different random numbers until a hash value that meets the conditions is found. This process is called "proof of work" because miners must put in a lot of computational work to complete it.
As the Bitcoin network grows, so does the difficulty of mining. This is because as more miners join the network, competition becomes more intense, requiring more computing power to earn Bitcoin rewards. To maintain the rate at which Bitcoin is issued, mining difficulty is adjusted based on the number of miners and computing power on the network.
In addition to the adjustment of mining difficulty, Bitcoin’s mining algorithm is also affected by block rewards and transaction fees. Whenever a miner successfully solves a block, he will be rewarded with a certain number of Bitcoins, as well as the transaction fees included in the block. This incentive mechanism is designed to attract more miners to participate in mining while ensuring the security and stability of the Bitcoin network.
During the Bitcoin mining process, miners also need to consider transaction confirmation time and network congestion. Due to the limited capacity of the Bitcoin network, when the transaction volume is too large, it may cause transaction delays and increased handling fees. Therefore, miners need to adjust their mining strategies according to actual conditions to obtain maximum benefits.
In general, the Bitcoin mining algorithm is a complex and changeable process, which requires miners to constantly adjust their strategies and computing power to adapt to changes in the network. Only through unremitting efforts and continuous innovation can we obtain rich returns in the mineral deposits of this digital world. Behind the BTC mining algorithm is the hard work and unremitting exploration of countless miners. It is this spirit that supports the stability and prosperity of the Bitcoin network.

Bitcoin mining is a critical part of the security of the Bitcoin system. The principle is that Bitcoin miners group a bunch of Bitcoin transactions into a block, and then repeatedly perform an encryption operation called Hash billions of times until someone finds a special target Hash value. At this point, the block is mined and becomes part of the Bitcoin blockchain. Hash
The task itself does not accomplish anything of value, but because it is very difficult to find a successful target value through it, it ensures that no one has the ability and resources to take over the Bitcoin system.

A hash function takes a block of data and creates a smaller, unpredictable output. Hash functions are designed so that there are no "shortcuts" to getting the desired output--
You can only keep hashing blocks until you find a valid result through brute force. For Bitcoin, Hash
The function is a function called SHA-256. To provide greater security, Bitcoin will repeat the SHA-256 function twice in a row, a process known as double SHA-256.

In Bitcoin, a successful hash value is a value that starts with enough zeros. Just like it's rare to find a phone number or license plate that ends with multiple zeros, it's rare to find a hash that starts with multiple zeros. But the difficulty of Bitcoin increases exponentially. Currently, a successful hash must start with approximately 17 zeros. In other words, finding a successful Hash is more difficult than finding a certain grain of sand among all the grains of sand on the earth.

The image below shows a block in the Bitcoin blockchain and its hash value. The yellow bytes are hashed to generate the block hash value. In this case, the generated hash value starts with enough 0s so that the mining is successful. However, Hash is difficult to get at once. In this case, miners will change the nonce value or other block content and then try again and again.

SHA-256Hash algorithm used by Bitcoin

The SHA-256 hash algorithm takes a 512-bit (i.e., 64 bytes) input block, cryptographically combines the data, and produces a 256-bit (32 bytes) output. The SHA-256 algorithm consists of relatively simple rounds repeated 64 times. The image below shows a round, which requires 8 4-byte inputs
--A to H, then perform some operations and generate new values from A to H.

The blue boxes mix values together in a nonlinear way, making them difficult to analyze cryptographically. Since the algorithm uses several different functions, the attack is harder to detect. (If you can figure out a mathematical shortcut to generate a successful hash value, you can take over Bitcoin mining).

The Ma majority box looks at the digits of A, B, and C. For each position, if the majority of digits is 0, it outputs 0, otherwise it outputs 1. In other words, for each position of A, B, C, look at the number of 1 bits. If it is 0 or 1, output 0; if it is 2 or 3, output 1.

The Σ0 box inverts the number of bits in A to form three inverted versions, then adds them modulo 2. In other words, if the number of 1 bits is odd, the sum is 1, otherwise it is 0, and the three values in the sum are A right-reversed 2 bits, 13 bits, and 22 bits respectively.

Ch "Select
" box selects the output bit according to the value of input E. If a certain bit of E is 1, the output bit is the corresponding bit of F. If a certain bit of E is 0, the output bit is the corresponding bit of G. In this way, F and G The bits are randomly selected based on the value of E.

The next box, Σ1, inverts the bits of E and is similar to Σ0 except that the shifts are 6, 11 and 25 bits.

The red box performs a 32-bit addition to generate new values for A and E. The input Wt is based on the input data and is slightly processed. (This is where the input block is fed into the algorithm.) The input Kt is a constant defined for each round.

As can be seen from the picture above, only A and E change in one round. Other values pass unchanged, the old A value becomes the new B value, the old B value becomes the new C value, and so on. While each round of SHA-256 won't change the data much, after 64 rounds, the input data will be completely scrambled.

What does this mean for mining hardware?

Each step of SHA-256 is very easy to implement in digital logic--
Simple Boolean operations and 32-bit addition. (If you studied electronics, you may already be able to visualize circuits). For this reason, custom ASIC chips can implement the SHA-256 algorithm in hardware very efficiently, putting hundreds of rounds in parallel on a single chip.

In comparison, Litecoin, Dogecoin and similar altcoins use Crypt
Hash algorithm, this algorithm is intentionally designed to be difficult to implement in hardware. It stores 1024 different hash values into memory and then combines them in unpredictable ways to get the final result. So, with SHA-256
Compared with Hash, Scrypt requires more circuits and memory. You can understand the impact by looking at the mining hardware, Scrypt (Litecoin, etc.) calculates thousands of times slower than SHA-256 (Bitcoin).

The SHA-256 algorithm is surprisingly simple and easy to do manually. (The elliptic curve algorithm used to sign Bitcoin transactions is very painful to calculate by hand because it has many multiplications of 32-byte integers). Doing one round of SHA-256 by hand took me 16 minutes and 45 seconds. At this rate, it would take 1.49 days to hash a full Bitcoin block (128 rounds), giving a hash rate of 0.67 times per day (although I may get faster with practice). In comparison, current Bitcoin mining hardware can do several trillion hashes per second, which is about 50 million times faster than my manual hash. Needless to say, manual Bitcoin mining is simply not practical.

A Reddit reader asked me about my energy consumption. In fact, it does not require much energy consumption, so assuming the resting metabolic rate is 1500kcal/day, the energy consumption of artificial hashing is almost 10 megajoules/hash. The energy consumption of general mining hardware is 1000 MJ/Hash. So, I'm 10¹⁶ less energy efficient. The next issue is energy costs. A cheap source of food energy is donuts, which cost 0.23 yuan for 200 kcal. Electricity here is $0.15/kWh, 6.7 times cheaper
--Closer than I expected. Therefore, my energy cost per hash is approximately 67 times that of the mining hardware. Obviously I'm not going to make a fortune doing manual mining, and I haven't even included the cost of all the paper and pencils I'll need.

I'll answer.

2480

Ask

970K+

reading

0

Answer

3H+

Upvote

2H+

Downvote