Bitcoin Forum
May 21, 2018, 09:34:34 PM *
News: Latest stable version of Bitcoin Core: 0.16.0  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Skipping first block of SHA-256  (Read 878 times)
littleblackhat
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
April 08, 2013, 04:32:32 AM
 #1

Since the nonce is part of the second block of the first (inner) call to SHA-256, it seems like an obvious optimization to only re-calculate the whole hash if new blocks or transactions come in. Is this practice currently being employed in mining software?
1526938474
Hero Member
*
Offline Offline

Posts: 1526938474

View Profile Personal Message (Offline)

Ignore
1526938474
Reply with quote  #2

1526938474
Report to moderator
1526938474
Hero Member
*
Offline Offline

Posts: 1526938474

View Profile Personal Message (Offline)

Ignore
1526938474
Reply with quote  #2

1526938474
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1526938474
Hero Member
*
Offline Offline

Posts: 1526938474

View Profile Personal Message (Offline)

Ignore
1526938474
Reply with quote  #2

1526938474
Report to moderator
1526938474
Hero Member
*
Offline Offline

Posts: 1526938474

View Profile Personal Message (Offline)

Ignore
1526938474
Reply with quote  #2

1526938474
Report to moderator
1526938474
Hero Member
*
Offline Offline

Posts: 1526938474

View Profile Personal Message (Offline)

Ignore
1526938474
Reply with quote  #2

1526938474
Report to moderator
BenTuras
Hero Member
*****
Offline Offline

Activity: 826
Merit: 1000



View Profile
April 08, 2013, 07:52:54 AM
 #2

simplified:
nonce is part of data.
data leads to hash1 in call to runhash1.
hash1 leads to hash in call to runhash2. (runhash1 and runhash2 are the same method: runhash)
potential valid block if hash[7] is zero.

Code:
runhash1(hash1, data, midstate);
runhash2(hash, hash1, sha256_init_state);

how would you like to optimize this ?

I am selling in stock OneStringMiner boards, based on the Bitfury chips. Have a look here: https://bitcointalk.org/index.php?topic=495536.0
Schleicher
Hero Member
*****
Offline Offline

Activity: 673
Merit: 500



View Profile
April 08, 2013, 04:27:40 PM
 #3

Since the nonce is part of the second block of the first (inner) call to SHA-256, it seems like an obvious optimization to only re-calculate the whole hash if new blocks or transactions come in. Is this practice currently being employed in mining software?
Yes. The hash of the first part is the "midstate".

littleblackhat
Newbie
*
Offline Offline

Activity: 16
Merit: 0


View Profile
April 08, 2013, 07:05:53 PM
 #4

Thanks. midstate was the key word to search for. I guess it was so obvious that it was (at least at one point) returned by the getwork function.  Smiley
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!