I'm trying to follow this wiki on bitcoin address creation, but I'm getting different results when I walk through it myself

Starting from step 4, we have the extended RIPEMD-160 hash 00010966776006953D5567439E5E39F86A0D273BEE. From this point we need to

  1. Double SHA-256 hash it
  2. Concatenate the the first 4 bytes of that double hash result to the end of the extended RIPEMD-160 result
  3. Convert that concatenation to Base58Check

I would expect the flow to be (using this SHA-256 online tool):

  • First SHA-256: 3CC2243D50E87857A233965AA6B68B37563BFCC52B3C499FBB259B9AA87FFF40
  • Second SHA-256: 18BBE0347AB84B97940F388AAB120D40BE0B97F54975E50F10A8CA023ECFA4C3
  • First 4 bytes: 18BB
  • Concatenation result: 00010966776006953D5567439E5E39F86A0D273BEE18BB
  • Base58Check: 1HKZ4TX7A61kvTJm2PFHcVPu9ZJrF4

However there are 2 differences between my results and the wiki. First the wiki produces different SHA-256 results. Second, the 4 bytes selected in the SHA-256 result are 8 characters, but aren't strings 1 byte per character?

Why do I have these difference?

  • It is simply likely that the online tool is treating the input as a string instead of a byte array. – Raghav Sood Apr 4 '18 at 1:45
  • @RaghavSood Perhaps my understanding of SHA-256 is wrong, but doesn't the input always need to be binary? Meaning that for the tool to work it would need to do String->Binary->Sha256->Binary->String? – David Grinberg Apr 4 '18 at 1:49
  • 1
    The tool is most likely converting your input string to the ascii or utf-8 bytes of each character, instead of treating it as a hexadecimal string of bytes. – Raghav Sood Apr 4 '18 at 1:52
  • For instance, converting it to a byte array gives the right answers for the first two sha256 in this golang code: play.golang.org/p/NIOdmkfh_7m – Raghav Sood Apr 4 '18 at 1:53
  • a quick verification shows, that the online tool is working with the strings. In bitcoin world we are using binary, see also here: bitcoin.stackexchange.com/questions/73388/… and also good for testing in the bitcoin world: gobittest.appspot.com/Address – pebwindkraft Apr 4 '18 at 3:19

Your Answer

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

Browse other questions tagged or ask your own question.