Is there a way to generate a bitcoin address from public key with openssl command line ?


2 Answers 2


Which kind of address do you want?

Assuming that you have compressed public key(compressed_public_key.txt), to generate P2PKH you can use these commands (hash160 and encoding with base58)

  ADDR_RIPEMD160=$(printf $(cat compressed_public_key.txt | xxd -r -p | openssl sha256| sed 's/^.* //') |xxd -r -p | openssl ripemd160 | sed 's/^.* //')
  ADDR=`printf $VERSION_PREFIX_ADDRESS$ADDR_RIPEMD160 | xxd -p -r | base58 -c`
  echo $ADDR

Where $VERSION_PREFIX_ADDRESS for P2PKH addresss are 0x00 for mainnet or 0x6F for testnet (https://en.bitcoin.it/wiki/List_of_address_prefixes)

  • I want an address for receiving bitcoin
    – Bob5421
    Commented May 4, 2020 at 12:44
  • Which kind of address? P2PKH or P2SH or Native segwit or P2SH-embed segwit?
    – monkeyUser
    Commented May 4, 2020 at 12:46
  • I don't really know. There are multiple kind of addresses for receiving bitcoins ?
    – Bob5421
    Commented May 4, 2020 at 12:48
  • Multiply kind of script.
    – monkeyUser
    Commented May 4, 2020 at 12:53
  • check this link bob en.bitcoin.it/wiki/Address
    – monkeyUser
    Commented May 4, 2020 at 12:54

No, it is not possible to use openssl for generation of a bitcoin address from a public key, unfortunately. Bitcoin addresses require base58, bech32 or bech32m encoding which are not supported by OpenSSL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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