The writer of this article https://pastebin.com/raw/jCDFcESz explains that

Sha256('sender') x 2 yields the address 18aMGf2AxQ3YXyNv9sKxiHYCXcBJeJv9d1

I am however getting the address 1DcTtaa37w971TmoafPpE9Pk16xc42YA87

What am I doing wrong?

closed as unclear what you're asking by Nate Eldredge, hedgedandlevered, Andrew Chow Mar 12 at 18:21

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Please post your code; it's hard to guess what the problem might be just by looking at the output. – Nate Eldredge Mar 6 at 14:43

A few things to check:

  1. Make sure you are computing the HASH256 on the decoded byte values of the string. In other words, HASH256(0x73656e646572)
  2. Make sure you are doing 2 rounds of SHA256
  3. Using secp256k1 to generate a compressed public key
  4. This is a P2PKH address (prefix is 1) so the steps to generate the address from the public key are:
    1. pubkeyhash = HASH160(compressed pubkey) i.e.RIPEMD160(SHA256(compressed pubkey)
    2. prepend 00 byte prefix for P2PKH
    3. BASE58CHECK(pubkeyhash)
$ echo -n sender | openssl sha256
(stdin)= 0a367b92cf0b037dfd89960ee832d56f7fc151681bb41e53690e776f5786998a

$ echo 0a367b92cf0b037dfd89960ee832d56f7fc151681bb41e53690e776f5786998a | xxd -r -p | openssl sha256
(stdin)= 098f6d68ce86adb2d8ba672a06227f7d177baca3568092e4cda159acca5eb0c7

$ openssl ec -inform DER -text -noout -in <(cat <(echo -n "302e0201010420") <(echo -n "098f6d68ce86adb2d8ba672a06227f7d177baca3568092e4cda159acca5eb0c7") <(echo -n "a00706052b8104000a") | xxd -r -p) 2>/dev/null | tail -6 | head -5 | sed 's/[ :]//g' | tr -d '\n' && echo

# result is even (ends in 0xf6) so prefix first 32 bytes with 02 (for odd use 03)
$ echo 02f4e5977bcb050452289ebc750b56be65086bfdf3411bb9c346430716545d66b8 | xxd -r -p | openssl sha256
(stdin)= cb59a26ae2e385719a66f568476bace40a8789c5fe91d74be6381e29feb20ecb

$ echo cb59a26ae2e385719a66f568476bace40a8789c5fe91d74be6381e29feb20ecb | xxd -r -p | openssl ripemd160
(stdin)= 53178717ab3d70c50fe8ec8598a9c2a8a703abc5

$ echo 0053178717ab3d70c50fe8ec8598a9c2a8a703abc5 | xxd -r -p | base58 -c && echo

using base58

  • Your second command is missing | openssl sha256 and output; you can combine the first two and save xxd with echo -n sender | openssl sha256 -binary | openssl sha256 and similarly for the two from pubkey to address. Instead of cat with three <(echo) you can do one echo -- or one herestring: -in <(xxd -r -p <<<"hexprefix""hexprivkey""hexsuffix") – dave_thompson_085 Mar 8 at 22:34
  • @dave_thompson_085 thanks, edited – JBaczuk Mar 8 at 23:04
static void test ( )
  const MyByteArray x ( QByteArray ( "sender" ) );
  _trace ( x.sha256  ( ).getAddressHashCompressed ( ).toString ( ) );
  _trace ( x.sha256d ( ).getAddressHashCompressed ( ).toString ( ) );

the output is:


So, your code runs sha256 only once, but not twice


% echo -n "sender" | bx base16-encode | bx sha256 | bx sha256 | bx ec-to-public | bx ec-to-address -v 0


% echo -n "sender" | bx base16-encode | bx sha256 | bx ec-to-public | bx ec-to-address -v 0


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