Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Prostoyarko on March 08, 2021, 12:33:07 PM



Title: Bitcoin address manual generetion
Post by: Prostoyarko on March 08, 2021, 12:33:07 PM
Hi, I'm trying to generate Bitcoin address from private key manually following this article https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses
But when I apply SHA-256 to public key mentioned in example I'm getting another hash then shown in this article. Same happens when I perform RIPEMD-160 hashing of SHA-256 hash.
It happens not only when I follow this article but any other article too.
Could someone suggest what did I do wrong?


Title: Re: Bitcoin address manual generetion
Post by: BlackHatCoiner on March 08, 2021, 12:40:45 PM
Could someone suggest what did I do wrong?
You're probably hashing a string and not a hex. On the third step, you'll have to hash it as a hex and not as a string. Based on the wiki's example if you hash the corresponding public key as a hex you'll get the correct result:

Code:
0b7c28c9b7290c98d7438e70b3d3f7c848fbd7d1dc194ff83f4f7cc9b1378e98

But if you hash it as a string you'll get a different result, which is:
Code:
a9ce83de3a0ff3516b7c50cdd787e9f69f152f227d93c9512774231e7132e925

You can hash a hex through emn178.github.io (https://emn178.github.io/online-tools/sha256.html). Just choose "hex" instead of "text" in the input type dropdown. Same thing must happen on RIPEMD-160.


Title: Re: Bitcoin address manual generetion
Post by: Prostoyarko on March 08, 2021, 01:33:36 PM
Great! This is it. Maybe you may suggest any tool which can encode HEX values using RIPEMD-160?


Title: Re: Bitcoin address manual generetion
Post by: BlackHatCoiner on March 08, 2021, 02:07:19 PM
Great! This is it. Maybe you may suggest any tool which can encode HEX values using RIPEMD-160?
But this is not an encoding. It's a hash function. Encoding means that it can also be decoded, for example a base64 text. Anything that has passed through a hash function like SHA256 or RIPEMD-160 means that there is no way back. As for recommended tools, what exactly are you looking for? Tool can be a line of code, a library or a site just like the one I posted. You have to clarify what you want to do.


Title: Re: Bitcoin address manual generetion
Post by: Prostoyarko on March 08, 2021, 02:23:59 PM
I mean tool for performing RIPEMD160 hashing for HEX values. Because all online hash tools work only with String input data


Title: Re: Bitcoin address manual generetion
Post by: ranochigo on March 08, 2021, 02:28:54 PM
I mean tool for performing RIPEMD160 hashing for HEX values. Because all online hash tools work only with String input data
I've used this before: https://www.pelock.com/products/hash-calculator.

Go to the page and input the values in hash hex bytes and scroll down for RIPEMD160.


Title: Re: Bitcoin address manual generetion
Post by: BlackHatCoiner on March 08, 2021, 02:29:02 PM
I mean tool for performing RIPEMD160 hashing for HEX values. Because all online hash tools work only with String input data

https://learnmeabitcoin.com/tools/ripemd160/


Title: Re: Bitcoin address manual generetion
Post by: Prostoyarko on March 08, 2021, 02:34:04 PM
Thanks!!!


Title: Re: Bitcoin address manual generetion
Post by: Husires on March 09, 2021, 11:10:54 AM
i used this https://www.mobilefish.com/services/cryptocurrency/cryptocurrency.html to learn how to generate bitcoin address from random numbers.


Use it to learn how bitcoin works and never send bitcoin to it.


Title: Re: Bitcoin address manual generetion
Post by: Cazemiro on March 09, 2021, 11:44:49 AM
Hi, I'm trying to generate Bitcoin address from private key manually following this article https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses
But when I apply SHA-256 to public key mentioned in example I'm getting another hash then shown in this article. Same happens when I perform RIPEMD-160 hashing of SHA-256 hash.
It happens not only when I follow this article but any other article too.
Could someone suggest what did I do wrong?

I had the same problems, the study is the key. For educational purpose a made this:
https://bitcointalk.org/index.php?topic=5322103.0
And use this site to learn how hash works:
https://www.fileformat.info/tool/hash.htm
This forum has a lot of material, for increase your  learning.