Is the SHA256 value in the bitcoin address wiki accurate?

3

2

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?

cloudnthings

Posted 2016-03-31T02:23:40.837

Reputation: 377

Answers

8

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.

greatwolf

Posted 2016-03-31T02:23:40.837

Reputation: 591

Ah, of course. Rookie mistake! Cheers. – cloudnthings – 2016-03-31T03:54:34.340

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

skaht

Posted 2016-03-31T02:23:40.837

Reputation: 2 751

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

Chengcheng Zhang

Posted 2016-03-31T02:23:40.837

Reputation: 101