introduction to bitcoin's scripting language

19
Bitcoin Scripting Language Presented by: Jeff Flowers [email protected]

Upload: jeff-flowers

Post on 12-Aug-2015

133 views

Category:

Technology


6 download

TRANSCRIPT

Page 1: Introduction to Bitcoin's Scripting Language

Bitcoin Scripting LanguagePresented by: Jeff Flowers

[email protected]

Page 2: Introduction to Bitcoin's Scripting Language

Overview

Function Execution

Components

Transactions Review

The Language

Examples

Page 3: Introduction to Bitcoin's Scripting Language

Computers as FunctionsGeneral purpose function execution units

von Neumann Lens

Classical Approach Towards Understanding

Page 4: Introduction to Bitcoin's Scripting Language

Text

Page 5: Introduction to Bitcoin's Scripting Language

Stack

Memory Where Execution Takes Place

LIFO ordering

Highly Structured Allocation and Deallocation Protocols

Page 6: Introduction to Bitcoin's Scripting Language

Script

Forth Like Programming Language

Reverse Polish Notation

Composed of OP_Codes

Turing incomplete

Page 7: Introduction to Bitcoin's Scripting Language

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

Page 8: Introduction to Bitcoin's Scripting Language

Turing Incompleteness

Looping Forbidden

Transaction Scripts Must Halt

Health of the Network

Page 9: Introduction to Bitcoin's Scripting Language

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

Page 10: Introduction to Bitcoin's Scripting Language

Example: Alice Pays Bob

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

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

Page 11: Introduction to Bitcoin's Scripting Language

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

Page 12: Introduction to Bitcoin's Scripting Language

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

Page 13: Introduction to Bitcoin's Scripting Language

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

Page 14: Introduction to Bitcoin's Scripting Language

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

Page 15: Introduction to Bitcoin's Scripting Language

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

Page 16: Introduction to Bitcoin's Scripting Language

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

Page 17: Introduction to Bitcoin's Scripting Language

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

Page 18: Introduction to Bitcoin's Scripting Language
Page 19: Introduction to Bitcoin's Scripting Language

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