<p>The first <code>00000000</code> is for the nonce. The nonce is changed in order to get a different block header without reselecting transactions. It is what is used primarily for finding a valid block hash.</p>

<p>The long string of bytes beginning with <code>0000008</code> is SHA-256 padding. It is not actually part of the block header and whatever is doing the SHA-256 hashing should figure out and append this padding for you. It is part of the pre-processing step for SHA-256.</p>

CC BY-SA 3.0
2018-03-13T00:45:07.613Z
Yeah I pulled this fragment out of the section of the code where they're doing that pre-processing.  Since the string beginning with "0000008" is padding, can it be anything?  Does it have to be that specific sequence?
Dave
CC BY-SA 3.0
2018-03-13T01:47:24.693Z
Yes. The padding is fixed and must be the same for all blocks. It should really be calculated dynamically by the SHA-256 function instead of something that you are hard coding.
Ava Chow
CC BY-SA 3.0
2018-03-13T13:51:14.003Z
To clarify your "Yes", do you mean "Yes it can be anything" or "yes it must be that specific sequence"?
Dave
CC BY-SA 3.0
2018-03-13T14:38:15.033Z
Yes, it must be that specific sequence.
Ava Chow
CC BY-SA 3.0
2018-03-13T00:40:01.563Z
2018-03-13T00:40:01.563Z
Ava Chow
<p>I'm going to screw up a lot of the terminology here.  I'm trying to understand the Bitcoin algortihm and wanted to use this JS miner -- <a href="https://github.com/howardchung/jsminer" rel="nofollow noreferrer">https://github.com/howardchung/jsminer</a> .  Specifically, I'm trying to understand how to build the data that someone attempts to hash.  They attempt to do this in the JS miner by the following</p>

<pre><code>    var header = version + prevhash + merkle_root + ntime + nbits + '00000000' + '000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000';
    curr_block.data = header;
</code></pre>

<p>I'm following most of this, using the Bitcoin wiki as a reference, but what I can't figure out at all is what are these last two numerical constants -- '00000000' and the bigger one beginning with "0000008".  I have seen these come up in other examples but I can't figure out why these are needed or if these are hard-coded values in the JS miner that shouldn't be there in real life.  Any help is appreciated.</p>

<mining-theory><hash><difficulty><block-header>
When computing the hash, do you need anything after the number of difficulty bits?
Dave
# When computing the hash, do you need anything after the number of difficulty bits?

(Asked by: username_0 on 2018-03-12)

I'm going to screw up a lot of the terminology here.  I'm trying to understand the Bitcoin algortihm and wanted to use this JS miner -- https://github.com/howardchung/jsminer .  Specifically, I'm trying to understand how to build the data that someone attempts to hash.  They attempt to do this in the JS miner by the following
    var header = version + prevhash + merkle_root + ntime + nbits + '00000000' + '000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000';
    curr_block.data = header;

I'm following most of this, using the Bitcoin wiki as a reference, but what I can't figure out at all is what are these last two numerical constants -- '00000000' and the bigger one beginning with "0000008".  I have seen these come up in other examples but I can't figure out why these are needed or if these are hard-coded values in the JS miner that shouldn't be there in real life.  Any help is appreciated.

**Tags:** mining-theory, hash, difficulty, block-header


---

## 1 answers

### Answer by username_1 on 2018-03-13. Score: 0 | Accepted answer

The first `00000000` is for the nonce. The nonce is changed in order to get a different block header without reselecting transactions. It is what is used primarily for finding a valid block hash.

The long string of bytes beginning with `0000008` is SHA-256 padding. It is not actually part of the block header and whatever is doing the SHA-256 hashing should figure out and append this padding for you. It is part of the pre-processing step for SHA-256.

> **Comments:**
> **username_0**: Yeah I pulled this fragment out of the section of the code where they're doing that pre-processing.  Since the string beginning with "0000008" is padding, can it be anything?  Does it have to be that specific sequence?  
> **username_1**: Yes. The padding is fixed and must be the same for all blocks. It should really be calculated dynamically by the SHA-256 function instead of something that you are hard coding.  
> **username_0**: To clarify your "Yes", do you mean "Yes it can be anything" or "yes it must be that specific sequence"?  
> **username_1**: Yes, it must be that specific sequence.  

---

