Bitcoin Forum
November 23, 2017, 06:21:32 AM *
News: Latest stable version of Bitcoin Core: 0.15.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Pay to public key hash  (Read 266 times)
victorkimba17
Jr. Member
*
Offline Offline

Activity: 44


View Profile
November 10, 2017, 03:35:59 PM
 #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?
1511418092
Hero Member
*
Offline Offline

Posts: 1511418092

View Profile Personal Message (Offline)

Ignore
1511418092
Reply with quote  #2

1511418092
Report to moderator
1511418092
Hero Member
*
Offline Offline

Posts: 1511418092

View Profile Personal Message (Offline)

Ignore
1511418092
Reply with quote  #2

1511418092
Report to moderator
1511418092
Hero Member
*
Offline Offline

Posts: 1511418092

View Profile Personal Message (Offline)

Ignore
1511418092
Reply with quote  #2

1511418092
Report to moderator
Join ICO Now A blockchain platform for effective freelancing
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1511418092
Hero Member
*
Offline Offline

Posts: 1511418092

View Profile Personal Message (Offline)

Ignore
1511418092
Reply with quote  #2

1511418092
Report to moderator
DannyHamilton
Legendary
*
Offline Offline

Activity: 1988



View Profile
November 10, 2017, 03:59:10 PM
 #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
Member
**
Offline Offline

Activity: 80


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
Jr. Member
*
Offline Offline

Activity: 44


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: 1134



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
Jr. Member
*
Offline Offline

Activity: 44


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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!