Computer Science 595/686 Home Page

P2PKH: Pay to Public Key Hash

CSC595/686-D: (The Real) Blockchain

by: burt rosenberg
at: university of miami

Lecture 5

Authorizing the transaction

Digital signatures are used to authorize transactions. Recall that a digsig is a public key technology that emulates a signature by producing publicly verifiable evidence of agreement by a party to a statement. A pair of keys is created, a public and a private which are matched through mathematics such at that a number created by the private key can be verified using the public key, and the only numbers that can be verified by the public key are numbers calculated by the private key.

Each TXO is paired with a public key. The meaning is that the holder of the matching private key is the owner of that TXO. Using a TXO as a TXI will require that the TXI carry a signature, by that public key, over a synopsis of the transaction in which the TXI appears. In this way, the owner of the output is agreeing to use that output as input to the transaction under consideration. For each TXI in the transaction, there must be a signature using the associated private key for that input. In this way, only if all owners of all inputs agree is the transaction valid.

The signatures are include in the transaction, paired with its TXI. In this way, all the information to verify a transaction is permanently available on the block chain. While the miners best not mine blocks which include transactions which are not properly signed, that is because the block will be rejected by all honest players, and will eventually not be included in the consensus chain. Not being on the consensus chain, the transaction will never have officially occurred, and coinbase and fees will not be usable by the cheating miner.

The public keys, when written in a proper format, are called Bitcoin addresses. In order to give you bitcoin, I suggest a transaction that has a TXO with the agreed bitcoin amount and your "address" paired with the TXO. Since this information is a member of a block, and the blockhash connects block to block, once on the consensus chain, the ownership of the bitcoin is permanent and publicly visible.

Blockchain scripting

The design of blockchain understood as typical the sort of signing described above, but did not want to limit transactions to be only according to that mechanism. To accommodate an unforeseen multitude of transaction types, Blockchain created a stack based computer language that would run scripts to carry out the transaction verification.

What is paired with the TXO is not so much a public key, but a ScriptPubKey, which is a script that will eventually test whether the request for spending will be honored. It typically includes the public key (address) of the TXO owner, to express in some manner that that owner must be involved in verifying the spending.

The TXI is paired with a ScriptSig, that in the typical case just self evaluates to the information needed by ScriptPubKey to perform the verification.

First ScriptSig runs, and leaves the public key and signature on a stack, as input for ScriptPubKey. Then ScriptPubKey runs, using the stack data to check that the public key on the stack is correct, and that the signature verifies. If all goes well, the pair of scripts have evaluated true and the transaction is valid.

The scripting language uses a stack, and has no branching or looping operations. Therefore the power of the language is limited. For instance, there is no uncertainty about the maximum run time for the script, since each step consumes a script item, and the run only proceeds from the start to the end of a fixed number of script items. A stack is used to organize the data.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

author: burton rosenberg
created: 4 Mar 2019
update: 4 Mar 2019