The Real Blockchain

OpCheckSig diagram

CSC 597: Blockchain and Ethereum

by: burt rosenberg
at: university of miami

Authentication in Bitcoin

The authorization to spend the UTXO's (unspent transaction outputs) is provided by the mathematical technology of a digital signature. A digsig is a form of public key cryptography that can provide proof that a owner of the bitcoin has authorized the transaction involving the bitcoin.

A digital signature consists of three procedures,

  1. A key generation procedure GEN.
  2. A signing procedure SIGN.
  3. A verification procedure VERIFY.
The subject, the entity that can own bitcoin, runs GEN with input a string of random bits to provide two outputs, sk, the secret or signing key, and pk, the public of verification key.
    (sk, pk) := GEN(ω ∈ Ω)

The key sk must remain secret and the key pk will be associate with a TxOut, and forms the identity of the owner of the Bitcoin.

A proposed transaction tr is hashed to a value H(tr). The sign procedure input that hash, the signing key sk and perhaps randomness to produce σ the signature,

    σ := SIGN(sk,H(tr),ω ∈ Ω)
The verification procedure has the correctness guarantee that, with this notation,
    VERIY(pk, σ, H(tr)) → True  autentic σ
and has the security guarantee that for any s that the adversary can effectively compute, even after having witnessed man signatures on many messages, even suggested messages for the signer to sign, with over whelming probability,
    VERIFY(pk, s, H(tr)) → False forged s

Transaction Verification

Bitcoin as several different ways to do the verification. We will detail Pay-to-PubkeyHash verification.

The TxOut has a scriptPubKey, a standardized script that includes a hash of pk, the public key of the owner of the TxOut.

The TxIn has a scriptSig, a standardized script that includes the public key pk and the signature σ. The signature is on a hash of transaction reformatted.

In the case of a simple SIGHASH_ALL verification, verify each TxIn individually as,

This verification (for each TxIn) includes,

Other Possible Verifications

The scriptSig can ask for these sorts of verifications,

Transaction Malleability and SegWit

There is a question of how to identify a transaction, for instance, to prevent a transaction once mined being mined again, as it has not be chased from some mempools. Bitcoin solved the piece of the problem it cared about. The transaction will not be included again in the block chain not because it is a duplicate, but because as a duplicate it would double spend.

However this does not identify the transaction. It may be a different transaction identical in its TxIn's and TxOut's. The paper describes a situation where the lack of a clear identification of the transaction can lead to problems.

We have described how the transaction is stripped of the scriptSig before hashed. The signatures are on this stripped version of the transaction. That means that two transaction differing in unimportant ways in their scriptSig's are both signed with the given signatures. However they will hash differently for purposes of the identity of the transaction (say in TxIn references to TxOut's).

If the mempool contains both variants, one gets mined and the other will later be rejected for double spending. This can be exploited. See

  • Bitcoin Transaction Malleability and MtGox, Christian Decker and Roger Wattenhofer, ESORICS 2014.

    Signature Details


    Pay-to-PubkeyHash
    The TxOut has a scriptPubKey script. The TxIn has a scriptSig script. The script is in a stack-based non-Turing equivalent programing language invented for BitCoin. The TxOut can be called the locking script and the TxIn can be called the unlocking script.

    Both scripts are brought together, lock with the unlock, and run. See the diagram to the right.

    1. In this order: sig and PubKey are pushed onto the stack.
    2. The opcode DUP duplicated the PubKey, because it is top of stack.
    3. The opcode HASH160 applied to the PubKey on the top of the stack to yield a hashed public key.
    4. The PubKHash is pushed on the stack; the opcode EQUALVERIFY checks the two two stack elements are equal.
    5. The script fails if they are not equal. If it succeeds the two elements are popped of the stack and the script continues.
    6. The opcode CHECKSIG hashes the transaction and verifies that sig on the top of stack is valid signature on that hash.
    7. If not, the transaction is not signed and honest miners will not include it in a block.
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

    author: burton rosenberg
    created: 5 Sep 2024
    update: 20 Sep 2024