0

I am pursuing a deeper understanding of Bitcoin. Reading Grokking Bitcoin now. I am trying to asess the understanding of different concepts by exploring a BTC RPC explorer. I got some understanding about the key types and keys structure and key derivation in hierarchical deterministic wallets. The book says: the PKH (double hashed from public key) is used in order to not reveal directly the public key (for better privacy), but then the public key gets revelead in the spending transaction.

In this screenshot of a random transaction I see only BTC addresses (bc1q) derived from PKH. Where is the "revelead" public key? I am quite sure I misunderstood something. Random transactionEntities relationship

1 Answer 1

1

What you show in your screenshot is some program's summary of a transaction which omits details of the spending script. You need to look at a more detailed view of the raw transaction data.

There are several types of Bitcoin transaction. The type known as Pay to Public Key Hash (P2PKH) requires that the recipient reveal their public key in a later transaction where they spend the received money.

There are several places that explain this. One is https://learnmeabitcoin.com/technical/p2pkh

The P2PKH script pattern contains a hashed public key surrounded by these opcodes:

scriptPubKey:

OP_DUP OP_HASH160   
12ab8dc588ca9d5787dde7eb29569da63c3a238c OP_EQUALVERIFY OP_CHECKSIG

To solve this script, the owner of the hashed public key above needs to provide the original public key, along with a valid signature for it:

scriptSig:

304502203f004eeed0cef2715643e2f25a27a28f3c578e94c7f0f6a4df104e7d   
163f7f8f022100b8b248c1cfd8f77a0365107a9511d759b7544d979dd152a955  
c867afac0ef78601   

044d05240cfbd8a2786eda9dadd520c1609b8593ff8641018d57703d02ba687c  
f2f187f0cee2221c3afb1b5ff7888caced2423916b61444666ca1216f2618139  
8c

In short, when this script runs:

  • The original public key is DUPlicated and then HASH160’ed.
  • This hashed value is compared with the hashed public key in the scriptPubKey to make sure it is EQUALVERIFY.
  • If it matches, the script continues and the CHECKSIG checks the signature against the public key (just like a P2PK script).

Note that the locking script is only present in the transaction in which a person received this money. The transaction in which they spend the received money has a reference to the earlier transaction and contains a spending script that is prepended to the earlier transaction's locking script and then evaluated.

The transaction you show is a P2WPKH which is a little more complex and has some advantages over P2PKH.

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.