Bitcoin Forum

Other => Beginners & Help => Topic started by: Zanetti on March 27, 2013, 03:31:22 PM



Title: !!!OP_EQUALVERIFY!!!!
Post by: Zanetti on March 27, 2013, 03:31:22 PM
Hello!!

My name is Ander

I'm working searching information about Bitcoins, and after staying lot of time reading articles and all the information on the Wiki, now I'm trying to understand how Bitcoins works internally. I'm learning more about the encryptation of Bitcoins but there's one thing that I can't understand.

<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

In standard transaction, we need the scriptSig and the scriptPubKey. First of all the signature and the sender's public key is combined. Then the public key of the sender is duplicated and then this key is hashed. After thar we put the receiver's public key hash, and taking this two hashes then we checked both.
But my problem is if the function of OP_EQUALVERIFY check if this two hashes are equal or not, because is imposible that they are equal, or I'm wrong about this process and this function is not that I think it is.

I read this topic on this forum but I'm not sure if I understand what two hashes compares the OP_EQUALVERIFY.

https://bitcointalk.org/index.php?topic=40100.0

I hope and answer for my question.

Thank you in advance for the help, and sorry for my english. I'm not used to write in English.

Ander


Title: Re: !!!OP_EQUALVERIFY!!!!
Post by: Zanetti on March 29, 2013, 12:49:53 PM
Code:
{
  "hash":"8d752783af0112c91a8a0d0c8c2416c4955cc121ca0a7b9861d0eb2756c3ec7e",
  "ver":1,
  "vin_sz":1,
  "vout_sz":2,
  "lock_time":0,
  "size":259,
  "in":[
    {
      "prev_out":{
        "hash":"b1b7c0c5dcc03446b0be9ea4e03d93aa033c20ddc43ff463b608ce9646fbfa2e",
        "n":0
      },
      "scriptSig":"3046022100cf2e18c2797efdadeeebdd87024f751fda107e6f24fdca8a8a94b10c97d68654022100d61c23594319c2b37b613764994509ed884a1e48c18cdf6cfee7b40687dcee1c01 0484c7d0c1e0134144cc965c6cf98976927307944e0f5f664ca1e1815bf65434420de0fe1eee3e1ac9cf47ff5e5bedc1e6569be63d900244222e0ba226f66da594"
    }
  ],
  "out":[
    {
      "value":"82.90000000",
      "scriptPubKey":"OP_DUP OP_HASH160 4f235d60866662c0b1713572d6931bce82acd313 OP_EQUALVERIFY OP_CHECKSIG"
    },
    {
      "value":"50.00000000",
      "scriptPubKey":"OP_DUP OP_HASH160 5c434d48a40bc2a91c4f0319e65117df361cb914 OP_EQUALVERIFY OP_CHECKSIG"
    }
  ]
}

If we have this transaction what is the function of OP_EQUALVERIFY? I'm not quite sure if this function compares the public key of the receiver with the hash inside the ScriptSig or compare the receiver's public key with the signature of the next transaction that this receiver's will do in the future. I'm a little confused.

I need help please.

Thanks


Title: Re: !!!OP_EQUALVERIFY!!!!
Post by: theymos on March 29, 2013, 01:10:18 PM
Quote
is imposible that they are equal

No. The hashes are equal if the public keys are equal.

The processing table here may help you understand how the script is processed:
https://en.bitcoin.it/wiki/Script#Standard_Transaction_to_Bitcoin_address


Title: Re: !!!OP_EQUALVERIFY!!!!
Post by: Zanetti on March 29, 2013, 01:49:14 PM
Then the OP_EQUALVERIFY compares the whole public key of this scriptsig of this transaction
Code:
0484c7d0c1e0134144cc965c6cf98976927307944e0f5f664ca1e1815bf65434420de0fe1eee3e1ac9cf47ff5e5bedc1e6569be63d900244222e0ba226f66da594
with the ScriptPubKey of the previous transaction because the receiver of the previous transaction and the sender of this transaction is the same address no?
I think that finally catch that. In this way is normal that two hashes will be the same.

https://en.bitcoin.it/wiki/Script#Standard_Transaction_to_Bitcoin_address (https://en.bitcoin.it/wiki/Script#Standard_Transaction_to_Bitcoin_address)

Here I see the sentence that I needed to understand.

Note: scriptSig is in the input of the spending transaction and scriptPubKey is in the output of the previously unspent i.e. "available" transaction.


Thank you for your help, theymos.