Bitcoin Forum
May 04, 2024, 06:00:32 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Pay to public key hash  (Read 449 times)
victorkimba17 (OP)
Jr. Member
*
Offline Offline

Activity: 113
Merit: 5


View Profile
November 10, 2017, 03:35:59 PM
Merited by ABCbits (1)
 #1

In P2PKH, the public key

scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
scriptSig: <sig> <pubKey>

is the public key of the sender? the hash is from the sender public key? the signature is of the sender?
1714802432
Hero Member
*
Offline Offline

Posts: 1714802432

View Profile Personal Message (Offline)

Ignore
1714802432
Reply with quote  #2

1714802432
Report to moderator
1714802432
Hero Member
*
Offline Offline

Posts: 1714802432

View Profile Personal Message (Offline)

Ignore
1714802432
Reply with quote  #2

1714802432
Report to moderator
1714802432
Hero Member
*
Offline Offline

Posts: 1714802432

View Profile Personal Message (Offline)

Ignore
1714802432
Reply with quote  #2

1714802432
Report to moderator
No Gods or Kings. Only Bitcoin
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4615



View Profile
November 10, 2017, 03:59:10 PM
Merited by ABCbits (2)
 #2

In P2PKH, the public key

scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
scriptSig: <sig> <pubKey>

is the public key of the sender? the hash is from the sender public key?

No.

The hash is of the receiver's public key.

the signature is of the sender?

Yes.  The sender generates the signature using their private key.

Notes:

The scriptPubKey is in the OUTPUT of the transaction and is used to encumber the bitcoin value with a requirement that can only be satisfied by the recipient when they later want to spend the output that they have received.

The scriptSig is in the INPUT of the transaction and is how the sender satisfies the requirements of the previously received outputs that they are spending in the new transaction.
pebwindkraft
Sr. Member
****
Offline Offline

Activity: 257
Merit: 343


View Profile
November 10, 2017, 09:41:04 PM
 #3

next to bitcoin.org and the developpers section and  Andreas' book "Mastering Bitcoin", this helped me alot to understand the underlying details:
http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html

victorkimba17 (OP)
Jr. Member
*
Offline Offline

Activity: 113
Merit: 5


View Profile
November 11, 2017, 02:26:34 AM
 #4

next to bitcoin.org and the developpers section and  Andreas' book "Mastering Bitcoin", this helped me alot to understand the underlying details:
http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html



I read the link. I am still not clear. In
scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
scriptSig: <sig> <pubKey>

The scriptSig contains the <sig> sender signature and <pubKey> sender public key, the scriptPubKey contains <pubKeyHash> which is the hash of receiver public key.

Then, how can the hash of sender <pubKey> matches with the receiver <pubKeyHash>  ?
Taras
Legendary
*
Offline Offline

Activity: 1386
Merit: 1053


Please do not PM me loan requests!


View Profile WWW
November 11, 2017, 05:23:28 AM
 #5

next to bitcoin.org and the developpers section and  Andreas' book "Mastering Bitcoin", this helped me alot to understand the underlying details:
http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html



I read the link. I am still not clear. In
scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
scriptSig: <sig> <pubKey>

The scriptSig contains the <sig> sender signature and <pubKey> sender public key, the scriptPubKey contains <pubKeyHash> which is the hash of receiver public key.

Then, how can the hash of sender <pubKey> matches with the receiver <pubKeyHash>  ?

The scriptSig part is what the receiver uses to spend the money that they got from pay-to-public-key-hash. Because they're spending the money, at that point they'd be the new sender. The <pubKey> for this new transaction hashes to the receiver's <pubKeyHash> from the old transaction when they first got the money.

Here's an example P2PKH transaction. It pays 0.00063664 BTC to my address with the script OP_DUP OP_HASH160 0507135dd0ec75f539b304d8641bf00372989b27 OP_EQUALVERIFY OP_CHECKSIG. Then, in the next transaction, I spend that 0.00063664 BTC, and you can see in the input script (scriptSig) that there is both a signature and the public key that hashes to 0507135dd0ec75f539b304d8641bf00372989b27, which is the pubKeyHash in the script of the other transaction where I was the receiver.
victorkimba17 (OP)
Jr. Member
*
Offline Offline

Activity: 113
Merit: 5


View Profile
November 11, 2017, 07:24:12 AM
 #6


The scriptSig part is what the receiver uses to spend the money that they got from pay-to-public-key-hash. Because they're spending the money, at that point they'd be the new sender. The <pubKey> for this new transaction hashes to the receiver's <pubKeyHash> from the old transaction when they first got the money.


Thank you very much. finally understand it.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!