address and format Q&a

+2 votes

Hello, i have looked at your example of how to generate multichain address and private key

http://www.multichain.com/developers/address-key-format/

Based on your example on generating a private address, step 2 to step 3

  1. Start with a raw private ECDSA key:
    283D01856115B7970B622EAA6DAFF2B9ECE30F1B66927592F6EA70325929102B
  2. Take the corresponding public key generated with it, which can be in compressed or uncompressed format. The uncompressed version contains 65 bytes, consisting of 0x04, 32 bytes for the X coordinate and 32 bytes for the Y coordinate. The compressed version contains 33 bytes, consisting of 0x02 (Y is even) or 0x03 (Y is odd), followed by 32 bytes for the X coordinate. Below is a compressed example:
    0284E5235E299AF81EBE1653AC5F06B60E13A3A81F918018CBD10CE695095B3E24
  3. Calculate the SHA-256 hash of the public key:
    1C72D90868DBCD0252A54EFFB25FB535B4C89B67D57B75FD88465C5F173DCAB5

when i try to take 0284E5235E299AF81EBE1653AC5F06B60E13A3A81F918018CBD10CE695095B3E24 to hash on any online SHA-256 hash calculator, they gave me different answer from the one stated in step 3. Why is that so?

asked Mar 19, 2017 by anonymous

1 Answer

+1 vote

You are probably entering that hexadecimal string into an online SHA-256 hash calculator, instead of calculating the hash of the binary equivalent of that hexadecimal string. Try this on a command line instead:

php -r 'echo hash("sha256",hex2bin("0284E5235E299AF81EBE1653AC5F06B60E13A3A81F918018CBD10CE695095B3E24"));'

answered Mar 20, 2017 by MultiChain
...