Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Reclaim3r on March 01, 2015, 02:15:06 AM



Title: SHA256 Compression?
Post by: Reclaim3r on March 01, 2015, 02:15:06 AM
I have been trying to design my own SHA256 ASIC for a while now and I'm starting to nearly grasp how the entire hashing algorithm works.
The only thing I seem to have difficulty understanding is how the hash function deals with "extended" strings of data.

That is, its ability to deal with varying lengths of data.
How does it deal with it and does it interfere much with ASIC hashing?


Title: Re: SHA256 Compression?
Post by: ncsupanda on March 01, 2015, 02:22:31 AM
You might have more luck in the technical forum.

https://bitcointalk.org/index.php?board=6.0


Title: Re: SHA256 Compression?
Post by: Reclaim3r on March 01, 2015, 02:24:18 AM
Thanks. Is it possible to get this moved?


Title: Re: SHA256 Compression?
Post by: ncsupanda on March 01, 2015, 02:37:04 AM
Thanks. Is it possible to get this moved?

Yep, you can even do it yourself. Look at the bottom left.


Title: Re: SHA256 Compression?
Post by: btchris on March 01, 2015, 02:59:12 AM
I don't know the first thing about ASIC programming.... but if you're writing software that requires a large iteration count (PBKDF2, etc.) I'd probably take the "easy" way out and just do the first iteration in software, and do the rest with a single hash block and a hard-coded data length in the ASIC (what I lazily do with GPU/OpenCL-based stuff).


Title: Re: SHA256 Compression?
Post by: TheRealSteve on March 01, 2015, 03:22:03 AM
Are you trying to design a generic SHA256 ASIC, or a Bitcoin mining ASIC?  There's a fair bit of difference there.

If the latter, I'd suggest looking at some of the public documents for the older FPGA miners, Avalon's chips, the data mining software sends to simple chips (i.e. not miners with their own controller board). etc.
For a quick "ahhh", see: http://crypto.stackexchange.com/questions/1862/how-can-i-calculate-the-sha-256-midstate


Title: Re: SHA256 Compression?
Post by: hhanh00 on March 01, 2015, 03:22:56 AM
1. In the general case, you add padding.
2. In the bitcoin case, the header has a fixed size. In fact, the nonce is in the 2nd block so you can reuse the state after you have done the first block.


Title: Re: SHA256 Compression?
Post by: Reclaim3r on March 01, 2015, 03:29:13 PM
Are you trying to design a generic SHA256 ASIC, or a Bitcoin mining ASIC?  There's a fair bit of difference there.

If the latter, I'd suggest looking at some of the public documents for the older FPGA miners, Avalon's chips, the data mining software sends to simple chips (i.e. not miners with their own controller board). etc.
For a quick "ahhh", see: http://crypto.stackexchange.com/questions/1862/how-can-i-calculate-the-sha-256-midstate

Bitcoin mining ASIC. Thanks for the link. I'll look it over  :)


Title: Re: SHA256 Compression?
Post by: Sergio_Demian_Lerner on March 01, 2015, 10:03:48 PM
You could start reading Dadda's paper.
"The design of a high speed ASIC unit for the hash function SHA-256 (384, 512)"
 


Title: Re: SHA256 Compression?
Post by: jeffhuys on March 02, 2015, 01:11:40 AM
You could start reading Dadda's paper.
"The design of a high speed ASIC unit for the hash function SHA-256 (384, 512)"
 

Great info! Thanks for sharing.

EDIT: Hmm. Probably no place to get this without paywall, right?


Title: Re: SHA256 Compression?
Post by: Sukrim on March 02, 2015, 03:09:23 AM
Maybe at university libraries?


Title: Re: SHA256 Compression?
Post by: TheRealSteve on March 02, 2015, 03:38:34 AM
Google → filetype:pdf "design of a high speed ASIC unit"
( you'll want to "View more results" on the last page - unless you get a different result order )

Or just pay the $31.. if you're designing an ASIC, that should be one of the rather small line items in your expenses :)


Title: Re: SHA256 Compression?
Post by: ncsupanda on March 02, 2015, 03:43:59 AM
Let me know if this is the one. If it is, I'll email you a copy and take this one down.

https://i.imgur.com/0N3Ch78.jpg


Title: Re: SHA256 Compression?
Post by: Reclaim3r on March 02, 2015, 02:54:21 PM
That looks like real useful piece of information. Is it possible to get that e-mailed please?


Title: Re: SHA256 Compression?
Post by: TheRealSteve on March 02, 2015, 03:01:55 PM
That looks like real useful piece of information. Is it possible to get that e-mailed please?

Instructions are hard, I guess:
Google → filetype:pdf "design of a high speed ASIC unit"
( you'll want to "View more results" on the last page - unless you get a different result order )
→ http://www.date-conference.com/proceedings/PAPERS/2004/DATE04/DF_FILES/04D_5.PDF


Title: Re: SHA256 Compression?
Post by: Reclaim3r on March 02, 2015, 03:05:34 PM
The instructions were easy. I had difficulty finding the right PDF. Thank you and sorry for the extra work you had to put in to link it.  ;)


Title: Re: SHA256 Compression?
Post by: TheRealSteve on March 02, 2015, 03:11:55 PM
The instructions were easy. I had difficulty finding the right PDF. Thank you and sorry for the extra work you had to put in to link it.  ;)
Tip me a coffee, I think that's fair recompense ;)
( wait, does that tip bot thing even monitor BCT yet? Dangit. )


Title: Re: SHA256 Compression?
Post by: Sukrim on March 02, 2015, 03:16:35 PM
No, that tip bot thingie is pure spam and only a centralized service - there would be next to no difference if Changetip was used together with PayPal instead of Bitcoin.


Title: Re: SHA256 Compression?
Post by: Reclaim3r on March 02, 2015, 04:38:27 PM
The instructions were easy. I had difficulty finding the right PDF. Thank you and sorry for the extra work you had to put in to link it.  ;)
Tip me a coffee, I think that's fair recompense ;)
( wait, does that tip bot thing even monitor BCT yet? Dangit. )

Maybe when I actually have BTC to start with.


Title: Re: SHA256 Compression?
Post by: TheRealSteve on March 02, 2015, 05:36:41 PM
Tip me a coffee, I think that's fair recompense ;)
( wait, does that tip bot thing even monitor BCT yet? Dangit. )
Maybe when I actually have BTC to start with.
Hah - was firmly tongue-in-cheek, though now I almost wish I could tip you ;)

No, that tip bot thingie is pure spam and only a centralized service - there would be next to no difference if Changetip was used together with PayPal instead of Bitcoin.
See above - don't want to derail the thread with a discussion on tipping systems :)


Title: Re: SHA256 Compression?
Post by: Reclaim3r on March 02, 2015, 06:26:54 PM
I've got a pretty good idea of how the hashing actually woks although I have difficulty wrapping my head around the compression.

From what I've gathered, the data is split into suitable chunks and then hashed. If its less then ideal, it becomes padded although I doubt Bitcoin hashing requires it.

The Avalon data sheets point to a method of sorts for preprocessing where the data is split up outside the chip before being sent to it.

I also remember TheRealSteve telling me that a difference exists between typical SHA256 and the Merkle-Damgard construct...or Merkle Tree, if my vernacular is correct.