Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: rklz on July 11, 2014, 04:24:22 AM



Title: Wallet Address hash generation
Post by: rklz on July 11, 2014, 04:24:22 AM
Hi, im using this tutorial https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses#How_to_create_Bitcoin_Address to understand how to creat bitcoin wallet addresses.

But, for example, if u start from step 5 and hash this string 445C7A8007A93D8733188288BB320A8FE2DEBD2AE1B47F0F50BC10BAE845C094 with sha 256 again the result is:

7760845DCFD8C366AE89620BE2F368D255D710BC7493628CA0DCDED9CA476E5A and not D61967F63C7DD183914A4AE452C9F6AD5D462CE3D277798075B107615C1A8A30 like the step 6 shows.

Where is my error? I cant' figure this out.


To hash with sha 256 im using: http://www.xorbin.com/tools/sha256-hash-calculator
or

NodeJS: var hash = crypto.createHash('sha256').update(p).digest('hex');

(same results)

Thanks in advance!


Title: Re: Wallet Address hash generation
Post by: DeathAndTaxes on July 11, 2014, 04:50:39 AM
The problem is your tool.   The tool you are using is hashing the input as "text".  Bitcoin public keys are byte arrays.  We may represent them as a hex values but you need to be hashing the actual bytes (i.e "0x77" is the value 119 not two numeric digits seven and seven).

You need a tool which hashes the bytes.  Here is one.   It supports RIPEMD160 as well so you can walk through the example from the beginning.
http://www.fileformat.info/tool/hash.htm?hex=445C7A8007A93D8733188288BB320A8FE2DEBD2AE1B47F0F50BC10BAE845C094



Title: Re: Wallet Address hash generation
Post by: Peter R on July 11, 2014, 05:00:38 AM
Damn, Gerald, you keep beating me by a few minutes!

https://i.imgur.com/01xAOwW.png


Title: Re: Wallet Address hash generation
Post by: Remember remember the 5th of November on July 11, 2014, 05:12:45 AM
This is a common mistake. I admit when I first did this I was baffled by the different results. The problem is indeed the online tool. In fact for the last 3 years I've wondered why nobody made an online SHA256 hashing tool that has the option to convert the HEX to actual binary and then hash it.


Title: Re: Wallet Address hash generation
Post by: DeathAndTaxes on July 11, 2014, 05:17:54 AM
In fact for the last 3 years I've wondered why nobody made an online SHA256 hashing tool that has the option to convert the HEX to actual binary and then hash it.

The tool I linked does (and it outputs RIPEMD-160 was well).


Title: Re: Wallet Address hash generation
Post by: rklz on July 11, 2014, 07:43:24 AM
Thanks you so much for your help guys!