What type of data is used during Bitcoin mining?
Software receives the data packet which has to be processed. Data block for mining (as per Bitcoin protocol is called Data block Header) and the hash’s target value are being distracted from the input data packet. The order and the alignment of the data fields are given below:
| Name | bits | dwords | bytes | |
| 1 | Version | 32 | 1 | 4 |
| 2 | Previous block hash | 256 | 8 | 32 |
| 3 | Merkel root | 256 | 8 | 32 |
| 4 | Timestamp | 32 | 1 | 4 |
| 5 | Bits | 32 | 1 | 4 |
| 6 | Nonce | 32 | 1 | 4 |
The meaning of the fields are described in details in the original Bitcoin protocol. From hardware point, we only need data packet size and leave Header construction to the software. The only thing hardware is interested in would be nonce, i.e nonce location and size in the incoming Header. We’ll have to loop through all the possible values of nonce field in hope
Target is a 256-bit number and is represented шт the form of eight double-words, Table 2.
| Name | bits | dwords | bytes | |
| 1 | target[0] | 32 | 1 | 4 |
| 2 | target[1] | 32 | 1 | 4 |
| 3 | target[2] | 32 | 1 | 4 |
| 4 | target[3] | 32 | 1 | 4 |
| 5 | target[4] | 32 | 1 | 4 |
| 6 | target[5] | 32 | 1 | 4 |
| 7 | target[6] | 32 | 1 | 4 |
| 8 | target[7] | 32 | 1 | 4 |
Table 2. Target
What is more, target correlates with calculated value of the hash sha256(sha256(Header)) bit by bit and word by word.
Perhaps, someone has mentioned that the value of the argument in the double-hash function differs: it was a “message” in the previous article and now it is a “header” one. It is all about the inconsistency of terms between the FIPS (Federal Information Processing Standards) /2/ and the Bitcoin documentations. We shall regard them as synonyms.
We shouldn’t do anything with “target” because it is just a limit value which stands above the calculated “golden” hash.
Otherwise, header provides us with the wide range of the mental activity.
The volume of “header” is 640-bit which can be seen in the Table 1. The length of “message” is 512-bit which is determined by the standard /2/. In case we have to calculate the hash of a «message” which outreaches the length of 512-bit, the input data has to be complemented and the result has to be a multiple of 512-bit and be blocked with M0,M1 etc. Each of them has a volume of 512-bit.
Therefore, Header is represented in the form of the 1024-bit number, Table 3:
| Name | bits | dwords | ||
| 1 | Version | 32 | 1 | – |
| 2 | Prev. block hash | 256 | 8 | – |
| 3 | Merkel root | 256 | 8 | – |
| 4 | Timestamp | 32 | 1 | – |
| 5 | Bits | 32 | 1 | – |
| 6 | Nonce | 32 | 1 | – |
| 7 | The “1” | 32 | 1 | 32’h8000 0000 |
| 8 | zeroes | 288 | 9 | – |
| 9 | Header number bits | 64 | 2 | 64’h0000 0000 0000 0280 |
Table 3. Extended Header
Thus, we receive blocks M0 and M1 in order to calculate the inner function sha256(sha256(Header)), Table 4 and Table 5:
| Name | bits | dwords | ||
| 1 | Version | 32 | 1 | – |
| 2 | Prev. block hash | 256 | 8 | – |
| 3 | Merkel root [223:0] | 224 | 7 | – |
Table 4. M0
| 3 | Merkel root [255:224] | 32 | 1 | – |
| 4 | Timestamp | 32 | 1 | – |
| 5 | Bits | 32 | 1 | – |
| 6 | Nonce | 32 | 1 | – |
| 7 | The “1” | 32 | 1 | 32’h8000 0000 |
| 8 | zeroes | 288 | 9 | – |
| 9 | Header number bits | 64 | 2 | 64’h0000 0000 0000 0280 |
Table 5. M1
As you can see, the variable parameter “nonce” contains only in the second block which means that the value of the sha256(М0) stays untouched for the current data block. Of course, there is possibly a simple solution: why don’t let the soft accomplish these tasks?
I.e., the hardware’s problem is to take the calculation result of the sha256(М1), compute all of the possible hashes and outer functions sha256(sha256({М0,M1})), then compare all of the hashes’ values to the “target”.
As a result, we could determine what is the midstate data that is transmitted to the hardware for the mining process, Table 6:
| Name | bits | dwords | ||
| 1 | H[0] | 32 | 1 | |
| 2 | H[1] | 32 | 1 | |
| 3 | H[2] | 32 | 1 | |
| 4 | H[3] | 32 | 1 | |
| 5 | H[4] | 32 | 1 | |
| 6 | H[5] | 32 | 1 | |
| 7 | H[6] | 32 | 1 | |
| 8 | H[7] | 32 | 1 | |
| 9 | Merkel root [255:224] | 32 | 1 | |
| 10 | Timestamp | 32 | 1 | |
| 11 | Bits | 32 | 1 | |
| 12 | Nonce | 32 | 1 | |
| 13 | The “1” | 32 | 1 | 32’h8000 0000 |
| 14 | Zeroes | 288 | 9 | |
| 15 | Header number bits | 64 | 2 | 64’h0000 0000 0000 0280 |
Table 6 Initial data for hardware mining
Here’s H[7;0] – the M0 block’s hash which is the initial value for a calculation of the M1’s hash for all “nonce” values. If we look carefully at the Table 6 we can see that items from 13th to 15th stay the same and, thus, can be represented as constants.
In conclusion, software transmits eight “target” double-words(hash of the M0) and twelve double-words(important part of the M1 block).


