Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: Dexter770221 on August 15, 2011, 09:02:05 AM



Title: Where can I find...
Post by: Dexter770221 on August 15, 2011, 09:02:05 AM
...exact description of one SHA256 round. I've found some algorithms but that doesn't helped me. Maybe you will know where to look. Step by step description would be best...
TIA.


Title: Re: Where can I find...
Post by: PLaci1982 on August 15, 2011, 09:26:33 AM
Wikipedia are your friend, use it! :)

http://en.wikipedia.org/wiki/SHA-2 (http://en.wikipedia.org/wiki/SHA-2)


Title: Re: Where can I find...
Post by: Dexter770221 on August 15, 2011, 10:54:49 AM
Well, I've looked at that before. And it didn't helped me. Things get even more complicated to me ;)


Title: Re: Where can I find...
Post by: JoelKatz on August 15, 2011, 12:46:45 PM
Middle of that page, middle of the pseudo-code, starting from "Initialize hash value for this chunk" and going on until "Add this chunk's result to the hash so far". Basically, it just does a bunch of bitwise operations to 'mash' all the data into the running hash total.


Title: Re: Where can I find...
Post by: Dexter770221 on August 15, 2011, 05:09:01 PM
After 3 cups of cofee and few hours of looking I think that finally I'm getting to understand that algorithm. Correct me if I'm wrong.
A to H are 32bit variables with 0h00000000 value at the begining. Wt and Kt are input values (data and nonce in terms of bitcoin?) After all operations (Ch function, Ma function, sigmas, modulo additions) result is moved to variable A and rest of them are moved one position. This happens 64 times and result of SHA256 operation is in A to H registers. Only unknown to me is that strange operand in Ch function (before second E). Is it NOT operand? Its not listed in table beneth.
TIA.


Title: Re: Where can I find...
Post by: JoelKatz on August 16, 2011, 02:10:18 AM
        ch := (e and f) xor ((not e) and g)

The 'not' operation is bitwise negation. Every 1 bit becomes a zero, every zero becomes a one.