In Bitcoin and most other cryptocurrencies, the public key is not typically displayed in the blockchain. Instead, what you see are addresses, which are often the result of cryptographic operations applied to the public key. A Bitcoin address is generated by taking the public key and applying a hash function to it, followed by a checksum and an encoding process (usually with Base58Check encoding).
However, a public key is revealed on the blockchain only when a transaction is made from an address. Here’s how you can see it:
-
When bitcoins are spent from a Bitcoin address, the spender creates a digital signature using their private key. This signature, along with the public key, is included in the transaction's scriptSig for each input when the transaction is broadcast to the network.
-
The digital signature and the public key are then verified against the address (or, more directly, the scriptPubKey of the previous output being spent) by anyone on the Bitcoin network to ensure the transaction is valid.
You can observe this process using a block explorer:
-
Go to a block explorer like Blockstream.info, Blockchain.com, or another service.
-
Enter the transaction ID (TXID) if you know it, or you can browse blocks to find specific transactions.
-
Once you are viewing a transaction, look at the inputs. Each input was a previously unspent output (UTXO) from an older transaction. For each input, there will usually be a scriptSig section that contains the hexadecimal representation of the signature and the public key.
-
The public key can be seen in the form of a long hexadecimal string. This string represents the original public key that corresponds to the private key used to generate the address.
-
For Pay-to-Public-Key-Hash (P2PKH) transactions, which are the most common, the public key is revealed when the bitcoins are spent rather than when they are received. For other types of transactions, such as Pay-to-Script-Hash (P2SH) or Pay-to-Witness-Public-Key-Hash (P2WPKH), you may not see the public key directly in the input, as these may involve advanced scripts or witness data.
Do note that revealing the public key does not compromise the security of an address unless the underlying cryptographic primitives are broken or the private key is mishandled. After the public key is revealed in a transaction, that address should not be used again for receiving funds for security purposes, which is a common practice known as address reuse. This is because, theoretically, if quantum computers become powerful enough in the future, they could use the exposed public key to determine the private key.