These public keys are easy enough for anyone to obtain from a Bitcoin address.
... What? Aren't the receive addresses in fact the "public keys"?
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It only takes a minute to sign up.Sign up to join this community
No. There are multiple kinds of addresses in common use:
A Pay to Public Key Hash (P2PKH) address, beginning with a
1... uses a Hash160 (Sha256 followed by RipeMD160) of the public key. The public key is not revealed until this output is spent, as the spending transaction will include the public key in its scriptSig.
A Pay to Script Hash (P2SH) address, beginning with a
3... uses the Hash160 of the
redeemScript, which is not part of the scriptPubKey. The redeemScript is part of the scriptSig which spends the output.
The hashes of the above two are then encoded using Base58Check to generate the address.
There are also Pay to Witness Public Key Hash (P2WPKH) and Pay to Witness Script Hash (P2WSH) versions, which are for post-segwit transactions where the witness is a separate part of the spending transaction. These both begin with
bc1..., with the difference between the two being the length of the hash. These are both encoded using the bech32 encoding to give the final address. The publicKey again, is part of the spending transaction, but is instead included in the extra witness field rather than the scriptSig.
There does exist a legacy P2PK (Pay to Public Key) output type, but this is seldom used. In this, the public key was included directly in the scriptPubKey.
In the others besides P2PK, the public key is not revealed until an output is spent. There is no way to know a public key from the hash alone, as the hash is a one-way function.