Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: guitarplinker on November 21, 2020, 01:09:10 AM



Title: Address Generation Procedure
Post by: guitarplinker on November 21, 2020, 01:09:10 AM
I'm trying to understand the steps for generating a bitcoin address on this wiki page (https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses), but the step 2 (SHA256 hash of ECDSA pub key) value isn't lining up:

Code:
user@computer:~$ echo -n "0250863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b2352" | sha256sum
a9ce83de3a0ff3516b7c50cdd787e9f69f152f227d93c9512774231e7132e925  -


The expected value is 0b7c28c9b7290c98d7438e70b3d3f7c848fbd7d1dc194ff83f4f7cc9b1378e98. I tried following the steps on this page (http://gobittest.appspot.com/Address) but encountered the same behavior. Does anyone see where I'm going wrong in following these guides?


Title: Re: Address Generation Procedure
Post by: Entontothekeseczi on November 21, 2020, 02:07:07 AM
Code:
 echo -n "0250863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b2352" | xxd -r -p | sha256sum
sha256sum needs the bytes not the ascii representation of the hex-encoded, compressed public key.
xxd takes care of the conversion and should come with vim package in case you don't have it yet.


Title: Re: Address Generation Procedure
Post by: ranochigo on November 21, 2020, 02:17:21 AM
Your SHA256 value, are you calculating it using ASCII or hex? Most online converters tend to treat the value that you've entered as ASCII while Bitcoin treats it as hex.


Title: Re: Address Generation Procedure
Post by: guitarplinker on November 21, 2020, 02:31:52 PM
Thank you both for clarifying, converting the hex values to their corresponding character values before hashing did the trick!