4

From the wiki page https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses the example of "How to Create Bitcoin Address" shows the SHA256 of:

0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6

to be

600FFE422B4E00731A59557A5CCA46CC183944191006324A447BDB2D98D4B408

If I use this online tool http://www.xorbin.com/tools/sha256-hash-calculator

I get: 32511e82d56dcea68eb774094e25bab0f8bdd9bc1eca1ceeda38c7a43aceddce

Am I missing something?

9

The problem is that you're treating the pubkey as string data. What you need to do is treat it as raw binary hexadecimal. If you use fileformat.info and calculate it using Binary Hash hex bytes you do indeed get 600FFE422B4E00731A59557A5CCA46CC183944191006324A447BDB2D98D4B408.

  • Ah, of course. Rookie mistake! Cheers. – cloudnthings Mar 31 '16 at 3:54
0

ASCII-encoded hex strings are easily handled by Bitcoin-Explorer. The following recreates results from en.bitcoin.it properly:

% echo -n 0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6 | bx base16-decode | shasum -a 256 600ffe422b4e00731a59557a5cca46cc183944191006324a447bdb2d98d4b408 -

% echo 0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6 | bx sha256

600ffe422b4e00731a59557a5cca46cc183944191006324a447bdb2d98d4b408

% echo 0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6 | bx sha256 | bx ripemd160 | bx base58check-encode -v 0

16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM

% echo 0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6 | bx ec-to-address -v 0 16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM

0

actually the public key:

0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6

is hex string, so you need transform it to bytes before you calculate the correct value.

You can use Python3 to get the correct value:

>>> import hashlib
>>> public_key_hexstr = '0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6'
>>> public_key_bytes = bytes.fromhex(public_key_hexstr)
>>> hashlib.sha256(public_key_bytes).hexdigest()
'600ffe422b4e00731a59557a5cca46cc183944191006324a447bdb2d98d4b408'

Or you can install bx tool in macOS using brew:

$ brew install bx

then:

$ bx sha256 0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6
600ffe422b4e00731a59557a5cca46cc183944191006324a447bdb2d98d4b408

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.