Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: CanaryInTheMine on August 25, 2011, 11:09:54 PM



Title: looking for technical info
Post by: CanaryInTheMine on August 25, 2011, 11:09:54 PM
could someone point me to where I can see code /pseudo/code for the calculation of a hash.  step by step would be awesome, but anything would be helpful too.


Title: Re: looking for technical info
Post by: jackjack on August 25, 2011, 11:48:54 PM
could someone point me to where I can see code /pseudo/code for the calculation of a hash.  step by step would be awesome, but anything would be helpful too.
A hash of what?
Block, transaction, address?


Title: Re: looking for technical info
Post by: CanaryInTheMine on August 25, 2011, 11:51:40 PM
could someone point me to where I can see code /pseudo/code for the calculation of a hash.  step by step would be awesome, but anything would be helpful too.
A hash of what?
Block, transaction?

block


Title: Re: looking for technical info
Post by: etotheipi on August 26, 2011, 04:12:34 AM
Are you talking about SHA256?  The wiki is always a good place to start for that:  http://en.wikipedia.org/wiki/SHA-2 (http://en.wikipedia.org/wiki/SHA-2)

If you're talking about something more specific to BTC, there are three places that hashes are used that I can think of, off the top of my head:

(1) 80-byte block headers  {sha256(sha256((...)}
(2) Full transactions       {sha256(sha256(...))}
(3) Converting public keys to BTC addresses  {ripemd160(sha256(...))}
 

You can see illustrations of a full Transaction (2) and the conversion from ECDSA public key to BTC address (3) in my post: 
https://bitcointalk.org/index.php?topic=29416.0 (https://bitcointalk.org/index.php?topic=29416.0)



Title: Re: looking for technical info
Post by: WakiMiko on August 26, 2011, 01:01:33 PM
blockhashing example in C: https://gist.github.com/1173353