狠狠撸

狠狠撸Share a Scribd company logo
Class 15:
Scripting
Transactions
Cryptocurrency Cabal
cs4501 Fall 2015
David Evans and Samee Zahur
University of Virginia
Plan for Today
Scripting Transactions
Review/PS2
1
Reminders
Extra office hours (see notes)
Midterm Wednesday (in class)
Problem Set 3
2
https://github.com/bitcoin/bitcoin/blob/v0.1.5/script.cpp#L41
3
https://github.com/bitcoin/bitcoin/blob/v0.1.5/script.cpp#L58
4https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp
5https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp
Interpreting Script
6
https://github.com/bitcoin/bitcoin/blob/41e6e4caba9899ce7c165b0784461c55c867ee24/src/script/interpreter.cpp#L524
7
https://github.com/bitcoin/bitcoin/blob/41e6e4caba9899ce7c165b0784461c55c867ee24/src/script/interpreter.cpp#L524
Version 0.1
Project idea: look at how bitcoin
core code has evolved over time
Latest
8
9
Vout: ([]btcjson.Vout) (len=2 cap=4) {
(btcjson.Vout) {
Value: (float64) 229,
N: (uint32) 0,
ScriptPubKey: (btcjson.ScriptPubKeyResult) {
Asm: (string) (len=85) "OP_DUP OP_HASH160
d6980467719f0e93e9742b6389e09117b6b630a3 OP_EQUALVERIFY OP_CHECKSIG",
Hex: (string) (len=50) "76a914d6980467719f0e93e9742b6389e09117b6b630a388ac",
ReqSigs: (int32) 1,
Type: (string) (len=10) "pubkeyhash",
Addresses: ([]string) (len=1 cap=4) {
(string) (len=34) "PsVSrUSQf72X6GWFQXJPxR7WSAPVRb1gWx"
}
}
},
10
OP_DUP
OP_HASH160
d6980467719f0e93e9742b6389e09117b6b630a3
OP_EQUALVERIFY
OP_CHECKSIG
OP_DUP [x] Duplicates the top stack item
OP_HASH160 [x] Replaces top of stack with RIPEMD160(SHA256([top]))
OP_EQUALVERIFY [x1] [x2] If top two items are equal, outputs True;
otherwise, marks transaction as Invalid.
OP_CHECKSIG [pubkey] [sig] Checks that E_pubkey(sig)([entire transaction])
LockingScript
11
12
OP_DUP
OP_HASH160
d6980467719f0e93e9742b6389e09117b6b630a3
OP_EQUALVERIFY
OP_CHECKSIG
LockingScriptUnlockingScript
Unlocking Script
13
Unlocking Script
14
<signature>
<pub key>
“Pay-to-Script-Hash”
15
OP_HASH160
[20-byte hash]
OP_EQUAL
LockingScript
Unlocking/Locking (pre-2010)
16
OP_DUP
OP_HASH160
<bitcoin address (hash of public key)>
OP_EQUALVERIFY
OP_CHECKSIG
LockingScript
<signature>
<public key>
UnlockingScript
OP_RETURN
17
Original meaning: terminate script execution, leaving stack unchanged.
https://github.com/bitcoin/bitcoin/blob/v0.1.5/script.cpp#L170
Steal any output!
18
OP_DUP
OP_HASH160
<bitcoin address (hash of public key)>
OP_EQUALVERIFY
OP_CHECKSIG
LockingScriptUnlockingScript
Steal any output!
19
OP_DUP
OP_HASH160
<bitcoin address (hash of public key)>
OP_EQUALVERIFY
OP_CHECKSIG
LockingScriptUnlockingScript
This is the by far biggest bug in bitcoin (discovered so far!).
OP_RETURN (fixed July 2010)
20
https://github.com/btcsuite/btcd/blob/c153596542b3d87dd774c29aa5be5117ac01a234/txscript/opcode.go#L1239
https://github.com/bitcoin/bitcoin/blob/41e6e4caba9899ce7c165b0784461c55c867ee24/src/script/interpreter.cpp#L397
Actual Scripts in Bitcoin
21
22
(first 290,000 blocks, through 2014-03-11)
23
OP_RETURN
OP_DATA_40
More Powerful Scripts
24
OP_CHECKMULTISIG [x] [sig]k [pub key]k
valid := 0
for each signature [1, k]:
if checksig(sigk, pubk): valid += 1
if valid >= x: 1
else: 0
Has this Changed?
25
26
https://github.com/SabaEskandarian/CryptocurrencyProject
Saba
Eskandarian’s
project last
semester
27
Charge
Wednesday: Midterm
Upcoming office hours:
Today: 5-6:30 (Ori, Rice 442)
Tomorrow: 2-3:30pm (Dave, Rice 507)
Tomorrow: 3:30-4:30pm (Samee, Rice 442)
28
Ad

Recommended

More Mining
More Mining
David Evans
?
Mining
Mining
David Evans
?
Midterm Confirmations
Midterm Confirmations
David Evans
?
Computer network (8)
Computer network (8)
NYversity
?
Cregit Recovering token level authorship from Git
Cregit Recovering token level authorship from Git
dmgerman
?
Transaction Ordering System
Transaction Ordering System
JasonGilchrist3
?
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
Trick or Treat?: Bitcoin for Non-Believers, Cryptocurrencies for Cypherpunks
David Evans
?
Hidden Services, Zero Knowledge
Hidden Services, Zero Knowledge
David Evans
?
Script
Script
David Evans
?
Introduction to Bitcoin's Scripting Language
Introduction to Bitcoin's Scripting Language
Jeff Flowers
?
A simplified Bitcoin Implementation in GO
A simplified Bitcoin Implementation in GO
Brian Yap
?
Ethereum VM and DSLs for Smart Contracts (updated on May 12th 2015)
Ethereum VM and DSLs for Smart Contracts (updated on May 12th 2015)
Zvi Avraham
?
Bitcoin Technology Presentation No.1.pptx
Bitcoin Technology Presentation No.1.pptx
scottjones511
?
Libbitcoin slides
Libbitcoin slides
swansontec
?
Bitcoin’s blockchain - from hashes to Escrow and beyond
Bitcoin’s blockchain - from hashes to Escrow and beyond
Grzegorz Gawron
?
以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)
以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)
Nicholas Lin
?
“Technical Intro to Blockhain” by Yurijs Pimenovs from Paybis at CryptoCurren...
“Technical Intro to Blockhain” by Yurijs Pimenovs from Paybis at CryptoCurren...
Dace Barone
?
Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!
David Evans
?
Anonymity in Bitcoin
Anonymity in Bitcoin
David Evans
?
How to Live in Paradise
How to Live in Paradise
David Evans
?
Bitcoin Script
Bitcoin Script
David Evans
?
Mining Economics
Mining Economics
David Evans
?
The Blockchain
The Blockchain
David Evans
?
Becoming More Paranoid
Becoming More Paranoid
David Evans
?
Asymmetric Key Signatures
Asymmetric Key Signatures
David Evans
?
Introduction to Cryptography
Introduction to Cryptography
David Evans
?
Class 1: What is Money?
Class 1: What is Money?
David Evans
?
Multi-Party Computation for the Masses
Multi-Party Computation for the Masses
David Evans
?
Proof of Reserve
Proof of Reserve
David Evans
?
Silk Road
Silk Road
David Evans
?

More Related Content

Similar to Scripting Transactions (9)

Script
Script
David Evans
?
Introduction to Bitcoin's Scripting Language
Introduction to Bitcoin's Scripting Language
Jeff Flowers
?
A simplified Bitcoin Implementation in GO
A simplified Bitcoin Implementation in GO
Brian Yap
?
Ethereum VM and DSLs for Smart Contracts (updated on May 12th 2015)
Ethereum VM and DSLs for Smart Contracts (updated on May 12th 2015)
Zvi Avraham
?
Bitcoin Technology Presentation No.1.pptx
Bitcoin Technology Presentation No.1.pptx
scottjones511
?
Libbitcoin slides
Libbitcoin slides
swansontec
?
Bitcoin’s blockchain - from hashes to Escrow and beyond
Bitcoin’s blockchain - from hashes to Escrow and beyond
Grzegorz Gawron
?
以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)
以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)
Nicholas Lin
?
“Technical Intro to Blockhain” by Yurijs Pimenovs from Paybis at CryptoCurren...
“Technical Intro to Blockhain” by Yurijs Pimenovs from Paybis at CryptoCurren...
Dace Barone
?
Introduction to Bitcoin's Scripting Language
Introduction to Bitcoin's Scripting Language
Jeff Flowers
?
A simplified Bitcoin Implementation in GO
A simplified Bitcoin Implementation in GO
Brian Yap
?
Ethereum VM and DSLs for Smart Contracts (updated on May 12th 2015)
Ethereum VM and DSLs for Smart Contracts (updated on May 12th 2015)
Zvi Avraham
?
Bitcoin Technology Presentation No.1.pptx
Bitcoin Technology Presentation No.1.pptx
scottjones511
?
Libbitcoin slides
Libbitcoin slides
swansontec
?
Bitcoin’s blockchain - from hashes to Escrow and beyond
Bitcoin’s blockchain - from hashes to Escrow and beyond
Grzegorz Gawron
?
以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)
以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)
Nicholas Lin
?
“Technical Intro to Blockhain” by Yurijs Pimenovs from Paybis at CryptoCurren...
“Technical Intro to Blockhain” by Yurijs Pimenovs from Paybis at CryptoCurren...
Dace Barone
?

More from David Evans (20)

Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!
David Evans
?
Anonymity in Bitcoin
Anonymity in Bitcoin
David Evans
?
How to Live in Paradise
How to Live in Paradise
David Evans
?
Bitcoin Script
Bitcoin Script
David Evans
?
Mining Economics
Mining Economics
David Evans
?
The Blockchain
The Blockchain
David Evans
?
Becoming More Paranoid
Becoming More Paranoid
David Evans
?
Asymmetric Key Signatures
Asymmetric Key Signatures
David Evans
?
Introduction to Cryptography
Introduction to Cryptography
David Evans
?
Class 1: What is Money?
Class 1: What is Money?
David Evans
?
Multi-Party Computation for the Masses
Multi-Party Computation for the Masses
David Evans
?
Proof of Reserve
Proof of Reserve
David Evans
?
Silk Road
Silk Road
David Evans
?
Blooming Sidechains!
Blooming Sidechains!
David Evans
?
Useful Proofs of Work, Permacoin
Useful Proofs of Work, Permacoin
David Evans
?
Alternate Cryptocurrencies
Alternate Cryptocurrencies
David Evans
?
Selfish Mining
Selfish Mining
David Evans
?
Quiz 2: Bitcoin Protocol, Mining, Supsersizing
Quiz 2: Bitcoin Protocol, Mining, Supsersizing
David Evans
?
Mostly About Superfish
Mostly About Superfish
David Evans
?
Mining Pools and Profits
Mining Pools and Profits
David Evans
?
Cryptocurrency Jeopardy!
Cryptocurrency Jeopardy!
David Evans
?
Anonymity in Bitcoin
Anonymity in Bitcoin
David Evans
?
How to Live in Paradise
How to Live in Paradise
David Evans
?
Becoming More Paranoid
Becoming More Paranoid
David Evans
?
Asymmetric Key Signatures
Asymmetric Key Signatures
David Evans
?
Introduction to Cryptography
Introduction to Cryptography
David Evans
?
Class 1: What is Money?
Class 1: What is Money?
David Evans
?
Multi-Party Computation for the Masses
Multi-Party Computation for the Masses
David Evans
?
Blooming Sidechains!
Blooming Sidechains!
David Evans
?
Useful Proofs of Work, Permacoin
Useful Proofs of Work, Permacoin
David Evans
?
Alternate Cryptocurrencies
Alternate Cryptocurrencies
David Evans
?
Quiz 2: Bitcoin Protocol, Mining, Supsersizing
Quiz 2: Bitcoin Protocol, Mining, Supsersizing
David Evans
?
Mostly About Superfish
Mostly About Superfish
David Evans
?
Mining Pools and Profits
Mining Pools and Profits
David Evans
?
Ad

Recently uploaded (20)

CHAKRABORTY (2022) - Gelatinization prop influencing Modified Starches - REVI...
CHAKRABORTY (2022) - Gelatinization prop influencing Modified Starches - REVI...
melinadick1
?
Exploring Ghanaian Cuisine and Its Unique Flavours Rooted in Culture and Trad...
Exploring Ghanaian Cuisine and Its Unique Flavours Rooted in Culture and Trad...
Sarvesh Bose
?
NUTRITION AND FOOD SECURITY NUTRITION AND FOOD
NUTRITION AND FOOD SECURITY NUTRITION AND FOOD
wigabih748
?
Factors causing spoilage - fats- rancidity ,oxidative.pptx
Factors causing spoilage - fats- rancidity ,oxidative.pptx
ASHWATHI K C
?
nomadic empire.pdfgreegxwegrhcwrthchthcerh
nomadic empire.pdfgreegxwegrhcwrthchthcerh
ParthChauhan522968
?
lecture_01_introduction to wireless networks.pdf
lecture_01_introduction to wireless networks.pdf
VnSn26
?
Human nutrition concept and introduction .pdf
Human nutrition concept and introduction .pdf
KusiAgyemang
?
sd401-issue-4-self-assessment-tool-v1-15092020-th.pdf
sd401-issue-4-self-assessment-tool-v1-15092020-th.pdf
4z9jx7cbmc
?
最新版美国康奈尔大学毕业证(颁鲍毕业证书)原版定制
最新版美国康奈尔大学毕业证(颁鲍毕业证书)原版定制
taqyea
?
food allergy and food intolarance (1) (1).pptx
food allergy and food intolarance (1) (1).pptx
z6znrhjj6h
?
Savor the Delightful Oysters by Galuppi's
Savor the Delightful Oysters by Galuppi's
Galuppi's
?
Best Spots to Eat Sushi in Dubai - The Dubai Street
Best Spots to Eat Sushi in Dubai - The Dubai Street
The Dubai Street
?
MATIGNON (2017) - Starch retrogradation - from starch comp. to cereal product...
MATIGNON (2017) - Starch retrogradation - from starch comp. to cereal product...
melinadick1
?
Tracii Show Hutsona Proves How Bold Branding, Great Food, and Clear Vision Cr...
Tracii Show Hutsona Proves How Bold Branding, Great Food, and Clear Vision Cr...
Tracii Show Hutsona
?
西班牙卢森堡商学院成绩单水印调尝厂叠毕业完成信尝厂叠学历认证范本皑如何制作
西班牙卢森堡商学院成绩单水印调尝厂叠毕业完成信尝厂叠学历认证范本皑如何制作
taqyed
?
Boyle_CommunityNutritionInAction_8e_PPT_Chapter11.pptx
Boyle_CommunityNutritionInAction_8e_PPT_Chapter11.pptx
pegjpope
?
Lecture 5.2 Understanding Demographic Change .pptx
Lecture 5.2 Understanding Demographic Change .pptx
shofalbsb
?
Boyle_CommunityNutritionInAction_8e_PPT_Chapter5(1).pptx
Boyle_CommunityNutritionInAction_8e_PPT_Chapter5(1).pptx
pegjpope
?
Title Lorem Ipsum.pptx math tasty coffee
Title Lorem Ipsum.pptx math tasty coffee
cdiem040
?
pdfresizer.com-pdf-resize (2).pdfajhdbcnc
pdfresizer.com-pdf-resize (2).pdfajhdbcnc
naitikbansal61
?
CHAKRABORTY (2022) - Gelatinization prop influencing Modified Starches - REVI...
CHAKRABORTY (2022) - Gelatinization prop influencing Modified Starches - REVI...
melinadick1
?
Exploring Ghanaian Cuisine and Its Unique Flavours Rooted in Culture and Trad...
Exploring Ghanaian Cuisine and Its Unique Flavours Rooted in Culture and Trad...
Sarvesh Bose
?
NUTRITION AND FOOD SECURITY NUTRITION AND FOOD
NUTRITION AND FOOD SECURITY NUTRITION AND FOOD
wigabih748
?
Factors causing spoilage - fats- rancidity ,oxidative.pptx
Factors causing spoilage - fats- rancidity ,oxidative.pptx
ASHWATHI K C
?
nomadic empire.pdfgreegxwegrhcwrthchthcerh
nomadic empire.pdfgreegxwegrhcwrthchthcerh
ParthChauhan522968
?
lecture_01_introduction to wireless networks.pdf
lecture_01_introduction to wireless networks.pdf
VnSn26
?
Human nutrition concept and introduction .pdf
Human nutrition concept and introduction .pdf
KusiAgyemang
?
sd401-issue-4-self-assessment-tool-v1-15092020-th.pdf
sd401-issue-4-self-assessment-tool-v1-15092020-th.pdf
4z9jx7cbmc
?
最新版美国康奈尔大学毕业证(颁鲍毕业证书)原版定制
最新版美国康奈尔大学毕业证(颁鲍毕业证书)原版定制
taqyea
?
food allergy and food intolarance (1) (1).pptx
food allergy and food intolarance (1) (1).pptx
z6znrhjj6h
?
Savor the Delightful Oysters by Galuppi's
Savor the Delightful Oysters by Galuppi's
Galuppi's
?
Best Spots to Eat Sushi in Dubai - The Dubai Street
Best Spots to Eat Sushi in Dubai - The Dubai Street
The Dubai Street
?
MATIGNON (2017) - Starch retrogradation - from starch comp. to cereal product...
MATIGNON (2017) - Starch retrogradation - from starch comp. to cereal product...
melinadick1
?
Tracii Show Hutsona Proves How Bold Branding, Great Food, and Clear Vision Cr...
Tracii Show Hutsona Proves How Bold Branding, Great Food, and Clear Vision Cr...
Tracii Show Hutsona
?
西班牙卢森堡商学院成绩单水印调尝厂叠毕业完成信尝厂叠学历认证范本皑如何制作
西班牙卢森堡商学院成绩单水印调尝厂叠毕业完成信尝厂叠学历认证范本皑如何制作
taqyed
?
Boyle_CommunityNutritionInAction_8e_PPT_Chapter11.pptx
Boyle_CommunityNutritionInAction_8e_PPT_Chapter11.pptx
pegjpope
?
Lecture 5.2 Understanding Demographic Change .pptx
Lecture 5.2 Understanding Demographic Change .pptx
shofalbsb
?
Boyle_CommunityNutritionInAction_8e_PPT_Chapter5(1).pptx
Boyle_CommunityNutritionInAction_8e_PPT_Chapter5(1).pptx
pegjpope
?
Title Lorem Ipsum.pptx math tasty coffee
Title Lorem Ipsum.pptx math tasty coffee
cdiem040
?
pdfresizer.com-pdf-resize (2).pdfajhdbcnc
pdfresizer.com-pdf-resize (2).pdfajhdbcnc
naitikbansal61
?
Ad

Scripting Transactions