introduction to bitcoin's scripting language

Post on 12-Aug-2015

137 Views

Category:

Technology

6 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Bitcoin Scripting LanguagePresented by: Jeff Flowers

jeff@siliconian.com

Overview

Function Execution

Components

Transactions Review

The Language

Examples

Computers as FunctionsGeneral purpose function execution units

von Neumann Lens

Classical Approach Towards Understanding

Text

Stack

Memory Where Execution Takes Place

LIFO ordering

Highly Structured Allocation and Deallocation Protocols

Script

Forth Like Programming Language

Reverse Polish Notation

Composed of OP_Codes

Turing incomplete

Goals of Script

The validation of a Bitcoin transaction

bitcoin will have conditions that must be met in the future to be moved - the scriptPubKey (locking script)

The script that meets these conditions - the scriptSig (unlocking script)

Bitcoin clients must run the locking and unlocking scripts to validate each transaction

Turing Incompleteness

Looping Forbidden

Transaction Scripts Must Halt

Health of the Network

scriptSig —> scriptPubKey<sig> <PubK> + DUP HASH160 <PubKHash> EQUALVERIFY CHECKSIGBoth must return not null to be valid.

Example: Alice Pays Bob

Standard Transaction used: Pay-to-Public-Key-Hash (P2PKH)

<BobSig> <BobPubK> + OP_DUP OP_HASH160 <BobPubKHash> OP_EQUAL OP_CHECKSIG

Example: Alice Pays Bob

Standard Transaction used: Pay-to-Public-Key-Hash (P2PKH)

<BobSig> <BobPubK> + OP_DUP OP_HASH160 <BobPubKHash> OP_EQUAL OP_CHECKSIG

BobSig

BobPubK

Example: Alice Pays Bob

Standard Transaction used: Pay-to-Public-Key-Hash (P2PKH)

<BobSig> <BobPubK> + OP_DUP OP_HASH160 <BobPubKHash> OP_EQUAL OP_CHECKSIG

BobSig

BobPubK

BobSig

BobPubK

BobPubK

Example: Alice Pays Bob

Standard Transaction used: Pay-to-Public-Key-Hash (P2PKH)

<BobSig> <BobPubK> + OP_DUP OP_HASH160 <BobPubKHash> OP_EQUAL OP_CHECKSIG

BobSig

BobPubK

BobSig

BobPubK

BobPubK

BobSig

BobPubK

BobPubKHash

Example: Alice Pays Bob

Standard Transaction used: Pay-to-Public-Key-Hash (P2PKH)

<BobSig> <BobPubK> + OP_DUP OP_HASH160 <BobPubKHash> OP_EQUAL OP_CHECKSIG

BobSig

BobPubK

BobSig

BobPubK

BobPubK

BobSig

BobPubK

BobPubKHash

BobSig

BobPubK

BobPubKHash

BobPubKHash

Example: Alice Pays Bob

Standard Transaction used: Pay-to-Public-Key-Hash (P2PKH)

<BobSig> <BobPubK> + OP_DUP OP_HASH160 <BobPubKHash> OP_EQUAL OP_CHECKSIG

BobSig

BobPubK

BobSig

BobPubK

BobPubK

BobSig

BobPubK

BobPubKHash

BobSig

BobPubK

BobPubKHash

BobPubKHash

BobSig

BobPubK

BobPubKHash

BobPubKHash

Example: Alice Pays Bob

Standard Transaction used: Pay-to-Public-Key-Hash (P2PKH)

<BobSig> <BobPubK> + OP_DUP OP_HASH160 <BobPubKHash> OP_EQUAL OP_CHECKSIG

BobSig

BobPubK

BobSig

BobPubK

BobPubK

BobSig

BobPubK

BobPubKHash

BobSig

BobPubK

BobPubKHash

BobPubKHash

BobSig

BobPubK

Bitcoin Script IDEhttp://www.cs.princeton.edu/~tongbinw/bitcoinIDE/build/editor.html

Resources:Bitcoin Script IDE

http://www.cs.princeton.edu/~tongbinw/bitcoinIDE/build/editor.html

Script Explorer

http://paulkernfeld.com/bse/

JS Script Interpreter

http://www.followthecoin.com/build-bitcoin-script-interpreter-javascript/

Wiki

https://en.bitcoin.it/wiki/Script

Mastering Bitcoin Chapter 5

ISBN-13: 978-1449374044

top related