1

( I have almost no background of coding, so please explain this in relatively easy words :) )

I want to know what are pubkey script, signature, full public key and the roles of these.

Specifically, I want to understand this diagram:

enter image description here

Here is how I understand this diagram;

Say, A wants to send 1btc to B.

Then, A gets something called Pubkey script from the most recent block in a block chain (Let’s call it PubkeyScript 1). Again, A uses something which is also called Pubkey script using the public key of B. (Let’s call it PubkeyScript 2) After that, A types a message “A sends 1btc to B”. Now, using A’s private key, convert the PubkeyScript1 to something called signature. Now, a chunk of signature and A’s public key and PubkeyScipt2 and the message “A sends 1btc to B” is called a transaction.

Am I understanding it correctly?

3

I try to explain it, that no coding is required :-) Taking more of a process view...

Assembly and sending of a tx:

the wallet software of A looks up it's internal database, if there is a transaction with required amount of 1 BTC on it. If yes, it then looks up this transaction's details in the blockchain, and finds in this transaction the pk script (spending condition), and assembles a new transaction, which shall move the funds to B's address. The wallet software then signs a hash of this transaction. The signature of this hash and the public key are placed in the [scriptsig] field of the transaction. So the final transaction contains the previous tx hash, signature and pubkey, and also an output section, with a pub key script (for B's target address) and the amount. That's what the picture shows. The transaction is then sent to the network.

Transaction Verification:

In the network are verifying nodes, that check for validity of the tx. Amongst others, these nodes check that you have the right to spend the funds. They take the current tx' sigscript (<signature> and <public key>), and from the previous tx the output script (pubkey script). Then basically two comparisons take place:

1.) can the public key of the previous tx' sigscript be hashed to the same value as the presented hash in the current tx' pubkey script?

2.) is the signature a valid signature for the public key

With the first check, it is assured, that the current transaction moves the funds to the previously defined target address. And with the second check it is verified, if the signature aligns to the presented public key.

For the second test: the wallet software creates a signature, which requires the private key of the owner of the public address. The private key is used to sign the hash of the current transaction.

The picture you provided has a presentation of the parts to create the spending tx. Not the verifying part. That makes it a bit more complex to derive functionality... I had a very good reading with Ken Shirrif's article here:

http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html

and also (of course) Andreas' book "Mastering Bitcoin" (Second Edition), which is also online available.

2

Some of your understanding is not entirely correct. I will explain it with a series of question

What exactly is a transaction? What are its components?

A transaction is a statement of transfer of value from one account(e.g Alice) to another account(e.g Bob). In bitcoin to transfer an amount, x Alice needs to first prove to the community that she has at least x amount with her. This proves in bitcoin is achieved by showing the whole community a previous transaction where Alice has received x(or more) amounts. Observe that it is even possible that Alice has received x amount from multiple transactions combined in which case Alice needs to give a list of the previous transaction which is called as inputs transaction.

Assume that if Alice has B bitcoins where B is greater than x, then Alice needs to send the change amount back to itself and x to bob. Alice can form this list out all the receiver's address with the corresponding amount which is called as outputs of a transaction.

What are Pubkey Scripts in the diagram?

Bitcoin and several other cryptocurrencies provide us with an option to mention some conditions under which a transaction can be spent. Pubkey Scripts are nothing but these conditions. Example of Pubkey Scripts is "Only Alice is allowed to spend this with her signature", under which case Alice needs to show a legitimate signature to spend the transaction.

In your case, PubkeyScript1 contains the condition under which Alice is eligible to spend the transaction and PubkeyScript2 contains the condition which bob must satisfy to spend the transaction.

  • What is “txn”? {}{}{} – Rubertos Jan 14 '18 at 12:58
  • "txn" is the short form of transaction. It is very standard. apologies. – sourav Jan 14 '18 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.