Bitcoin Forum
May 28, 2024, 10:01:47 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Is it possible to compute nonce and header separately?  (Read 789 times)
coinscashout (OP)
Jr. Member
*
Offline Offline

Activity: 45
Merit: 1


View Profile
June 18, 2015, 03:50:20 PM
 #1

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?
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3402
Merit: 6659


Just writing some code


View Profile WWW
June 18, 2015, 04:20:52 PM
 #2

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.

coinscashout (OP)
Jr. Member
*
Offline Offline

Activity: 45
Merit: 1


View Profile
June 18, 2015, 04:32:13 PM
 #3

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
coinscashout (OP)
Jr. Member
*
Offline Offline

Activity: 45
Merit: 1


View Profile
June 18, 2015, 04:40:14 PM
 #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
DannyHamilton
Legendary
*
Offline Offline

Activity: 3402
Merit: 4656



View Profile
June 18, 2015, 05:35:44 PM
 #5

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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!