Author

Topic: Is it possible to compute nonce and header separately? (Read 798 times)

legendary
Activity: 3472
Merit: 4801
Yes. In fact, it is used by many pools. They compute the first part of the header which will not change during the current block mining, and send that to the miners. This is called the midstate. Then the nonce and everything else in the header is computed by the miner and somehow added to the midstate and the whole thing is sent back to the pool.

Hold on..I think i misunderstood what you said first.

You say the header is calculated first then the rest of the header is calculated with the nonce. What I meant was can the whole of the header be calculated separately and then nonce separate and then combined. It seems unlikely but I thought I'd ask here in case someone figured out how to

Please explain what you mean when you say "compute the header".  The header is not "computed", it is built. The only piece of the header that is "computed" is the Merkle Root.  The nonce is also not "computed", it is chosen.

So, first the header is built, then the nonce is chosen, then a double SHA256 hash is computed of the assembled header and nonce together.  If the hash is lower than the current difficulty target, then the block is complete and gets broadcast.  If it is not lower than the current difficulty target, then a new nonce is chosen and the double SHA256 hash is computed again.  This process of choosing a nonce and computing the hash is repeated until all possible nonce values have been tried or a hash is found to be lower than the current difficulty target.

Since the nonce is at the very end of the header, and since the process of computing a SHA256 hash involved processing 64 bytes at a time, it is possible to get half way through the first calculation of the SHA256 hash and store that value.  Then each time a new nonce is chosen, it's possible to start from the stored value rather than needing to recompute the entire hash from the beginning.
jr. member
Activity: 45
Merit: 4
Yes. In fact, it is used by many pools. They compute the first part of the header which will not change during the current block mining, and send that to the miners. This is called the midstate. Then the nonce and everything else in the header is computed by the miner and somehow added to the midstate and the whole thing is sent back to the pool.

Hold on..I think i misunderstood what you said first.

You say the header is calculated first then the rest of the header is calculated with the nonce. What I meant was can the whole of the header be calculated separately and then nonce separate and then combined. It seems unlikely but I thought I'd ask here in case someone figured out how to
jr. member
Activity: 45
Merit: 4
Yes. In fact, it is used by many pools. They compute the first part of the header which will not change during the current block mining, and send that to the miners. This is called the midstate. Then the nonce and everything else in the header is computed by the miner and somehow added to the midstate and the whole thing is sent back to the pool.


Thanks...I've been trying to do this for many days now and can't seem to figure out how to get it together accurately; I'm either not separating it properly or not bringing it together properly.

If anyone has a good reference (for a person like me with basic knowledge) of how the pools are doing this, please share it here.

Thanks
staff
Activity: 3458
Merit: 6793
Just writing some code
Yes. In fact, it is used by many pools. They compute the first part of the header which will not change during the current block mining, and send that to the miners. This is called the midstate. Then the nonce and everything else in the header is computed by the miner and somehow added to the midstate and the whole thing is sent back to the pool.
jr. member
Activity: 45
Merit: 4
Don't really know if I should put this in the 'newbie' section but last time I did my post was moved here.

Is it possible to calculate the nonce and header separately and then combine the two right near the end to give the same values if they were computed together in the first instance?

eg:

Calculated together       Nonce (separate)    Header (separate)
12345                    =   1000                    2345

I know with the back and forward and reverse etc it seems impossible but would there then be a calculation which can figure out how to put these two separate things together again accurately?
Jump to: