lecture 6 - cs.jhu.eduabhishek/classes/cs601-641-441-spring2018/lectur… · lecture 6 mechanics of...
TRANSCRIPT
![Page 1: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/1.jpg)
Lecture 6Mechanics of Bitcoin
![Page 2: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/2.jpg)
Bitcoin transactions
![Page 3: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/3.jpg)
An account-based ledger (not Bitcoin)
Create 25 coins and credit to AliceASSERTED BY MINERS
SIMPLIFICATION: only one transaction per block
time
![Page 4: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/4.jpg)
An account-based ledger (not Bitcoin)
Create 25 coins and credit to AliceASSERTED BY MINERS
Transfer 17 coins from Alice to BobSIGNED(Alice)
SIMPLIFICATION: only one transaction per block
time
![Page 5: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/5.jpg)
An account-based ledger (not Bitcoin)
Create 25 coins and credit to AliceASSERTED BY MINERS
Transfer 17 coins from Alice to BobSIGNED(Alice)
Transfer 8 coins from Bob to CarolSIGNED(Bob)
Transfer 5 coins from Carol to AliceSIGNED(Carol)
SIMPLIFICATION: only one transaction per block
time
![Page 6: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/6.jpg)
An account-based ledger (not Bitcoin)
Create 25 coins and credit to AliceASSERTED BY MINERS
Transfer 17 coins from Alice to BobSIGNED(Alice)
Transfer 8 coins from Bob to CarolSIGNED(Bob)
Transfer 5 coins from Carol to AliceSIGNED(Carol)
SIMPLIFICATION: only one transaction per block
time
Transfer 15 coins from Alice to DavidSIGNED(Alice)is this valid?
![Page 7: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/7.jpg)
An account-based ledger (not Bitcoin)
Create 25 coins and credit to AliceASSERTED BY MINERS
Transfer 17 coins from Alice to BobSIGNED(Alice)
Transfer 8 coins from Bob to CarolSIGNED(Bob)
Transfer 5 coins from Carol to AliceSIGNED(Carol)
SIMPLIFICATION: only one transaction per block
time
Transfer 15 coins from Alice to DavidSIGNED(Alice)
might need to scan backwards until genesis!
is this valid?
![Page 8: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/8.jpg)
A transaction-based ledger (Bitcoin) Inputs: Ø Outputs: 25.0→Alice
SIMPLIFICATION: only one transaction per block
time1
![Page 9: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/9.jpg)
A transaction-based ledger (Bitcoin) Inputs: Ø Outputs: 25.0→Alice
Inputs: 1[0]
Outputs: 17.0→Bob, 8.0→Alice SIGNED(Alice)
SIMPLIFICATION: only one transaction per block
time1
2
![Page 10: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/10.jpg)
A transaction-based ledger (Bitcoin) Inputs: Ø Outputs: 25.0→Alice
Inputs: 1[0]
Outputs: 17.0→Bob, 8.0→Alice SIGNED(Alice)
SIMPLIFICATION: only one transaction per block
time
Inputs: 2[0]
Outputs: 8.0→Carol, 7.0→Bob SIGNED(Bob)
1
2
3
![Page 11: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/11.jpg)
A transaction-based ledger (Bitcoin) Inputs: Ø Outputs: 25.0→Alice
Inputs: 1[0]
Outputs: 17.0→Bob, 8.0→Alice SIGNED(Alice)
SIMPLIFICATION: only one transaction per block
time
is this valid?
Inputs: 2[0]
Outputs: 8.0→Carol, 7.0→Bob SIGNED(Bob)
Inputs: 2[1]
Outputs: 6.0→David, 2.0→Alice SIGNED(Alice)
1
2
3
4
![Page 12: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/12.jpg)
A transaction-based ledger (Bitcoin) Inputs: Ø Outputs: 25.0→Alice
Inputs: 1[0]
Outputs: 17.0→Bob, 8.0→Alice SIGNED(Alice)
SIMPLIFICATION: only one transaction per block
time
is this valid?
finite scan to check for validityInputs: 2[0]
Outputs: 8.0→Carol, 7.0→Bob SIGNED(Bob)
Inputs: 2[1]
Outputs: 6.0→David, 2.0→Alice SIGNED(Alice)
1
2
3
4
![Page 13: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/13.jpg)
A transaction-based ledger (Bitcoin) Inputs: Ø Outputs: 25.0→Alice
Inputs: 1[0]
Outputs: 17.0→Bob, 8.0→Alice SIGNED(Alice)
SIMPLIFICATION: only one transaction per block
time
is this valid?
finite scan to check for validityInputs: 2[0]
Outputs: 8.0→Carol, 7.0→Bob SIGNED(Bob)
Inputs: 2[1]
Outputs: 6.0→David, 2.0→Alice SIGNED(Alice)
we implement this with hash pointers
1
2
3
4
![Page 14: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/14.jpg)
Referencing Transactions
● Hash pointers for blocks ● Hash pointers for transactions ● Within a transaction, refer to a
particular output via serial numbers
![Page 15: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/15.jpg)
Merging value
Inputs: ...
Outputs: 17.0→Bob, 8.0→Alice SIGNED(Alice)
SIMPLIFICATION: only one transaction per block
time
Inputs: 1[1]
Outputs: 6.0→Carol, 2.0→Bob SIGNED(Carol)
...
...
1
2
![Page 16: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/16.jpg)
Merging value
Inputs: ...
Outputs: 17.0→Bob, 8.0→Alice SIGNED(Alice)
SIMPLIFICATION: only one transaction per block
time
Inputs: 1[1]
Outputs: 6.0→Carol, 2.0→Bob SIGNED(Carol)
Inputs: 1[0], 2[1]
Outputs: 19.0→Bob SIGNED(Bob)
...
...
1
2
3
![Page 17: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/17.jpg)
Joint payments
Inputs: ...
Outputs: 17.0→Bob, 8.0→Alice SIGNED(Alice)
SIMPLIFICATION: only one transaction per block
time
Inputs: 1[1]
Outputs: 6.0→Carol, 2.0→Bob SIGNED(Carol)
...
...
1
2
![Page 18: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/18.jpg)
Joint payments
Inputs: ...
Outputs: 17.0→Bob, 8.0→Alice SIGNED(Alice)
SIMPLIFICATION: only one transaction per block
time
Inputs: 1[1]
Outputs: 6.0→Carol, 2.0→Bob SIGNED(Carol)
Inputs: 2[0], 2[1]
Outputs: 8.0→David SIGNED(Carol), SIGNED(Bob)
...
...
1
2
3
![Page 19: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/19.jpg)
Joint payments
Inputs: ...
Outputs: 17.0→Bob, 8.0→Alice SIGNED(Alice)
SIMPLIFICATION: only one transaction per block
time
Inputs: 1[1]
Outputs: 6.0→Carol, 2.0→Bob SIGNED(Carol)
Inputs: 2[0], 2[1]
Outputs: 8.0→David SIGNED(Carol), SIGNED(Bob)
...
...
two signatures!
1
2
3
![Page 20: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/20.jpg)
The real deal: a Bitcoin transaction{ "hash":"5a42590fbe0a90ee8e8747244d6c84f0db1a3a24e8f1b95b10c9e050990b8b6b", "ver":1, "vin_sz":2, "vout_sz":1, "lock_time":0, "size":404, "in":[ { "prev_out":{ "hash":"3be4ac9728a0823cf5e2deb2e86fc0bd2aa503a91d307b42ba76117d79280260", "n":0 },
"scriptSig":"30440..." }, { "prev_out":{ "hash":"7508e6ab259b4df0fd5147bab0c949d81473db4518f81afc5c3f52f91ff6b34e", "n":0 }, "scriptSig":"3f3a4ce81...." } ], "out":[ { "value":"10.12287097", "scriptPubKey":"OP_DUP OP_HASH160 69e02e18b5705a05dd6b28ed517716c894b3d42e OP_EQUALVERIFY OP_CHECKSIG" } ]
}
![Page 21: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/21.jpg)
The real deal: a Bitcoin transaction{ "hash":"5a42590fbe0a90ee8e8747244d6c84f0db1a3a24e8f1b95b10c9e050990b8b6b", "ver":1, "vin_sz":2, "vout_sz":1, "lock_time":0, "size":404, "in":[ { "prev_out":{ "hash":"3be4ac9728a0823cf5e2deb2e86fc0bd2aa503a91d307b42ba76117d79280260", "n":0 },
"scriptSig":"30440..." }, { "prev_out":{ "hash":"7508e6ab259b4df0fd5147bab0c949d81473db4518f81afc5c3f52f91ff6b34e", "n":0 }, "scriptSig":"3f3a4ce81...." } ], "out":[ { "value":"10.12287097", "scriptPubKey":"OP_DUP OP_HASH160 69e02e18b5705a05dd6b28ed517716c894b3d42e OP_EQUALVERIFY OP_CHECKSIG" } ]
}
input(s)
metadata
output(s)
![Page 22: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/22.jpg)
The real deal: transaction metadata{ "hash":"5a42590...b8b6b", "ver":1, "vin_sz":2, "vout_sz":1, "lock_time":0, "size":404, ... }
![Page 23: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/23.jpg)
The real deal: transaction metadata{ "hash":"5a42590...b8b6b", "ver":1, "vin_sz":2, "vout_sz":1, "lock_time":0, "size":404, ... }
housekeeping
housekeeping
![Page 24: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/24.jpg)
The real deal: transaction metadata{ "hash":"5a42590...b8b6b", "ver":1, "vin_sz":2, "vout_sz":1, "lock_time":0, "size":404, ... }
housekeeping
housekeeping
transaction hash
![Page 25: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/25.jpg)
The real deal: transaction metadata{ "hash":"5a42590...b8b6b", "ver":1, "vin_sz":2, "vout_sz":1, "lock_time":0, "size":404, ... }
housekeeping
housekeeping
transaction hash
“not valid before” more on this later...
![Page 26: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/26.jpg)
The real deal: transaction inputs "in":[ { "prev_out":{ "hash":"3be4...80260", "n":0 },
"scriptSig":"30440....3f3a4ce81" }, ... ],
![Page 27: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/27.jpg)
The real deal: transaction inputs "in":[ { "prev_out":{ "hash":"3be4...80260", "n":0 },
"scriptSig":"30440....3f3a4ce81" }, ... ],
signature
previous transaction
(more inputs)
![Page 28: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/28.jpg)
The real deal: transaction outputs "out":[ { "value":"10.12287097", "scriptPubKey":"OP_DUP OP_HASH160 69e...3d42e OP_EQUALVERIFY OP_CHECKSIG" }, ... ]
![Page 29: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/29.jpg)
The real deal: transaction outputs "out":[ { "value":"10.12287097", "scriptPubKey":"OP_DUP OP_HASH160 69e...3d42e OP_EQUALVERIFY OP_CHECKSIG" }, ... ]
output value
(more outputs)
![Page 30: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/30.jpg)
The real deal: transaction outputs "out":[ { "value":"10.12287097", "scriptPubKey":"OP_DUP OP_HASH160 69e...3d42e OP_EQUALVERIFY OP_CHECKSIG" }, ... ]
output value
recipient address??
(more outputs)
![Page 31: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/31.jpg)
Bitcoin scripts
![Page 32: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/32.jpg)
Output “addresses” are really scripts
OP_DUP OP_HASH160 69e02e18... OP_EQUALVERIFY OP_CHECKSIG
![Page 33: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/33.jpg)
Input “addresses” are also scripts
OP_DUP OP_HASH160 69e02e18... OP_EQUALVERIFY OP_CHECKSIG
30440220... 0467d2c9...
![Page 34: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/34.jpg)
Input “addresses” are also scripts
OP_DUP OP_HASH160 69e02e18... OP_EQUALVERIFY OP_CHECKSIG
30440220... 0467d2c9...
scriptSig
scriptPubKey
![Page 35: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/35.jpg)
Input “addresses” are also scripts
OP_DUP OP_HASH160 69e02e18... OP_EQUALVERIFY OP_CHECKSIG
30440220... 0467d2c9...
scriptSig
scriptPubKey
TO VERIFY: Concatenated script must execute completely with no errors
![Page 36: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/36.jpg)
Bitcoin scripting language (“Script”)
Design goals ● Built for Bitcoin ● Simple, compact ● Support for cryptography ● Stack-based ● Limits on time/memory ● No looping
![Page 37: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/37.jpg)
Bitcoin scripting language (“Script”)
Design goals ● Built for Bitcoin ● Simple, compact ● Support for cryptography ● Stack-based ● Limits on time/memory ● No looping
image via Jessie St. Amand
I am not impressed
![Page 38: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/38.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
![Page 39: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/39.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
![Page 40: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/40.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
<sig>
![Page 41: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/41.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
<sig>
![Page 42: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/42.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
<sig>
<pubKey>
![Page 43: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/43.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
<sig>
<pubKey>
![Page 44: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/44.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
<sig>
<pubKey>
<pubKey>
![Page 45: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/45.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
<sig>
<pubKey>
<pubKey>
![Page 46: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/46.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
<sig>
<pubKey>
<pubKeyHash>
![Page 47: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/47.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
<sig>
<pubKey>
<pubKeyHash>
![Page 48: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/48.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
<sig>
<pubKey>
<pubKeyHash?>
<pubKeyHash>
![Page 49: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/49.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
<sig>
<pubKey>
<pubKeyHash?>
<pubKeyHash>
![Page 50: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/50.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
<sig>
<pubKey>
![Page 51: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/51.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
<sig>
<pubKey>
![Page 52: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/52.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
true
![Page 53: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/53.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
true
![Page 54: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/54.jpg)
Bitcoin script execution example
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash?> OP_EQUALVERIFY OP_CHECKSIG
✓true
![Page 55: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/55.jpg)
Bitcoin script instructions
256 opcodes total (15 disabled, 75 reserved) ● Arithmetic ● If/then ● Logic/data handling ● Crypto!
○ Hashes ○ Signature verification ○ Multi-signature verification
![Page 56: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/56.jpg)
OP_CHECKMULTISIG
● Built-in support for joint signatures ● Specify n public keys ● Specify t ● Verification requires t signatures
![Page 57: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/57.jpg)
OP_CHECKMULTISIG
● Built-in support for joint signatures ● Specify n public keys ● Specify t ● Verification requires t signatures
BUG ALERT: Extra data value popped from the stack and ignored
![Page 58: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/58.jpg)
Bitcoin scripts in practice (as of 2014)
● Most nodes whitelist known scripts ● 99.9% are simple signature checks ● ~0.01% are MULTISIG ● ~0.01% are Pay-to-Script-Hash ● Remainder are errors, proof-of-burn
![Page 59: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/59.jpg)
Bitcoin scripts in practice (as of 2014)
● Most nodes whitelist known scripts ● 99.9% are simple signature checks ● ~0.01% are MULTISIG ● ~0.01% are Pay-to-Script-Hash ● Remainder are errors, proof-of-burn
![Page 60: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/60.jpg)
Proof-of-burn
OP_RETURN <arbitrary data>
![Page 61: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/61.jpg)
Proof-of-burn
OP_RETURN <arbitrary data>
nothing’s going to redeem that ☹
![Page 62: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/62.jpg)
Proof-of-burn: Applications
● Can be used to publish arbitrary data on the blockchain (e.g., timestamping a document)
● Altcoins: Require people to burn bitcoin in order to get new altcoins
![Page 63: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/63.jpg)
Should senders specify scripts?
Big Box
![Page 64: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/64.jpg)
Should senders specify scripts?
Big BoxI’m ready to pay for my purchases!
![Page 65: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/65.jpg)
Should senders specify scripts?
Big BoxI’m ready to pay for my purchases!
Cool! Well we’re using MULTISIG now, so include a script requiring 2 of our 3 account managers to approve. Don’t get any of those details wrong. Thanks for shopping at Big Box!
![Page 66: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/66.jpg)
Should senders specify scripts?
Big BoxI’m ready to pay for my purchases!
Cool! Well we’re using MULTISIG now, so include a script requiring 2 of our 3 account managers to approve. Don’t get any of those details wrong. Thanks for shopping at Big Box!
?
![Page 67: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/67.jpg)
Idea: use the hash of redemption script
OP_HASH160 <hash of redemption script> OP_EQUAL
![Page 68: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/68.jpg)
Idea: use the hash of redemption script
OP_HASH160 <hash of redemption script> OP_EQUAL
<signature> <<pubkey> OP_CHECKSIG>
![Page 69: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/69.jpg)
Idea: use the hash of redemption script
OP_HASH160 <hash of redemption script> OP_EQUAL
<signature> <<pubkey> OP_CHECKSIG><signature>
<pubkey> OP_CHECKSIG
![Page 70: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/70.jpg)
Idea: use the hash of redemption script
OP_HASH160 <hash of redemption script> OP_EQUAL
<signature> <<pubkey> OP_CHECKSIG>
“Pay to Script Hash”
<signature>
<pubkey> OP_CHECKSIG
![Page 71: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/71.jpg)
Pay to script hash
Big BoxI’m ready to pay for my purchases!
![Page 72: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/72.jpg)
Pay to script hash
Big BoxI’m ready to pay for my purchases!
Great! Here’s our address: 0x3454
![Page 73: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/73.jpg)
Applications of Bitcoin scripts
![Page 74: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/74.jpg)
Example 1: “Fair” transactions
● Problem: Alice wants to buy a product from an online vendor Bob
● Alice doesn’t want to pay until after Bob ships
● Bob doesn’t want to ship until after Alice pays
![Page 75: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/75.jpg)
Example 1: Fair transactions via Escrow
BobAlice
![Page 76: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/76.jpg)
Example 1: Fair transactions via Escrow
Pay x to 2-of-3 of Alice, Bob, Judy (MULTISIG)
SIGNED(ALICE)
BobAlice
![Page 77: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/77.jpg)
Example 1: Fair transactions via Escrow
Pay x to 2-of-3 of Alice, Bob, Judy (MULTISIG)
SIGNED(ALICE)
BobAlice
To: Alice From: Bob
![Page 78: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/78.jpg)
Example 1: Fair transactions via Escrow
Pay x to 2-of-3 of Alice, Bob, Judy (MULTISIG)
SIGNED(ALICE)
BobAlice
To: Alice From: Bob
Pay x to Bob
SIGNED(ALICE, BOB)
(normal case)
![Page 79: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/79.jpg)
Example 1: Fair transactions via Escrow
Pay x to 2-of-3 of Alice, Bob, Judy (MULTISIG)
SIGNED(ALICE)
BobAlice
To: Alice From: Bob
![Page 80: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/80.jpg)
Example 1: Fair transactions via Escrow
Pay x to 2-of-3 of Alice, Bob, Judy (MULTISIG)
SIGNED(ALICE)
BobAlice
To: Alice From: Bob
![Page 81: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/81.jpg)
Example 1: Fair transactions via Escrow
Pay x to 2-of-3 of Alice, Bob, Judy (MULTISIG)
SIGNED(ALICE)
BobAlice
To: Alice From: Bob
Pay x to Alice
SIGNED(ALICE, JUDY)
(disputed case)
Judy
![Page 82: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/82.jpg)
Example 2: Micro-payments
● Pay-as-you-go WIFI: Alice wants to pay WIFI provider (Bob) for each minute of WIFI service. But she doesn’t want to incur a transaction fee for every minute
● Similarly, pay-as-you-go online subscriptions
● Ad-free websites
![Page 83: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/83.jpg)
Example 2: Micro-payments with Bitcoin
![Page 84: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/84.jpg)
Example 2: Micro-payments with Bitcoin
● Main Idea: Instead of doing several transactions, do a single transaction for total payment (and thus incur only a single transaction fee)
● How to implement it?
![Page 85: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/85.jpg)
Example 2: Micro-payments with Bitcoin
AliceBob
![Page 86: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/86.jpg)
Example 2: Micro-payments with Bitcoin
AliceBob
Input: y; Pay 100 to Bob/Alice (MULTISIG) SIGNED(ALICE)
![Page 87: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/87.jpg)
Example 2: Micro-payments with Bitcoin
AliceBob
Input: x; Pay 01 to Bob, 99 to Alice SIGNED(ALICE)___________
Input: y; Pay 100 to Bob/Alice (MULTISIG) SIGNED(ALICE)
![Page 88: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/88.jpg)
Example 2: Micro-payments with Bitcoin
AliceBob
Input: x; Pay 01 to Bob, 99 to Alice SIGNED(ALICE)___________
Input: x; Pay 02 to Bob, 98 to Alice SIGNED(ALICE)___________
Input: y; Pay 100 to Bob/Alice (MULTISIG) SIGNED(ALICE)
![Page 89: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/89.jpg)
Example 2: Micro-payments with Bitcoin
AliceBob
Input: x; Pay 01 to Bob, 99 to Alice SIGNED(ALICE)___________
Input: x; Pay 02 to Bob, 98 to Alice SIGNED(ALICE)___________
Input: x; Pay 03 to Bob, 97 to Alice SIGNED(ALICE)___________
Input: x; Pay 04 to Bob, 96 to Alice SIGNED(ALICE)___________
Input: y; Pay 100 to Bob/Alice (MULTISIG) SIGNED(ALICE)
![Page 90: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/90.jpg)
Example 2: Micro-payments with Bitcoin
AliceBob
Input: x; Pay 01 to Bob, 99 to Alice SIGNED(ALICE)___________
Input: x; Pay 02 to Bob, 98 to Alice SIGNED(ALICE)___________
Input: x; Pay 03 to Bob, 97 to Alice SIGNED(ALICE)___________
Input: x; Pay 04 to Bob, 96 to Alice SIGNED(ALICE)___________
Input: x; Pay 42 to Bob, 58 to Alice SIGNED(ALICE)___________
...
I’m done!
Input: y; Pay 100 to Bob/Alice (MULTISIG) SIGNED(ALICE)
![Page 91: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/91.jpg)
Example 2: Micro-payments with Bitcoin
AliceBob
Input: x; Pay 01 to Bob, 99 to Alice SIGNED(ALICE)___________
Input: x; Pay 02 to Bob, 98 to Alice SIGNED(ALICE)___________
Input: x; Pay 03 to Bob, 97 to Alice SIGNED(ALICE)___________
Input: x; Pay 04 to Bob, 96 to Alice SIGNED(ALICE)___________
Input: x; Pay 42 to Bob, 58 to Alice SIGNED(ALICE)___________
...
I’m done! I’ll publish!
Input: y; Pay 100 to Bob/Alice (MULTISIG) SIGNED(ALICE)
Input: x; Pay 42 to Bob, 58 to Alice SIGNED(ALICE) SIGNED(BOB)
![Page 92: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/92.jpg)
Example 2: Micro-payments with Bitcoin
AliceBob
Input: x; Pay 01 to Bob, 99 to Alice SIGNED(ALICE)___________
Input: x; Pay 02 to Bob, 98 to Alice SIGNED(ALICE)___________
Input: x; Pay 03 to Bob, 97 to Alice SIGNED(ALICE)___________
Input: x; Pay 04 to Bob, 96 to Alice SIGNED(ALICE)___________
Input: x; Pay 42 to Bob, 58 to Alice SIGNED(ALICE)___________
...
I’m done! I’ll publish!
all of these could be double-spends!
Input: y; Pay 100 to Bob/Alice (MULTISIG) SIGNED(ALICE)
Input: x; Pay 42 to Bob, 58 to Alice SIGNED(ALICE) SIGNED(BOB)
![Page 93: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/93.jpg)
Example 2: Micro-payments with Bitcoin
AliceBob
Input: x; Pay 42 to Bob, 58 to Alice SIGNED(ALICE)___________
Input: y; Pay 100 to Bob/Alice (MULTISIG) SIGNED(ALICE)
![Page 94: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/94.jpg)
Example 2: Micro-payments with Bitcoin
AliceBob
Input: x; Pay 42 to Bob, 58 to Alice SIGNED(ALICE)___________
Input: y; Pay 100 to Bob/Alice (MULTISIG) SIGNED(ALICE)
What if Bob never signs??
![Page 95: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/95.jpg)
Example 2: Micro-payments with Bitcoin
AliceBob
Input: x; Pay 42 to Bob, 58 to Alice SIGNED(ALICE)___________
Input: y; Pay 100 to Bob/Alice (MULTISIG) SIGNED(ALICE)
What if Bob never signs??
Input: x; Pay 100 to Alice, LOCK until time t SIGNED(ALICE) SIGNED(BOB)
Alice demands a timed refund transaction before starting
![Page 96: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/96.jpg)
lock_time{ "hash":"5a42590...b8b6b", "ver":1, "vin_sz":2, "vout_sz":1, "lock_time":315415, "size":404, ... }
![Page 97: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/97.jpg)
lock_time{ "hash":"5a42590...b8b6b", "ver":1, "vin_sz":2, "vout_sz":1, "lock_time":315415, "size":404, ... }
Block index or real-world timestamp before which this transaction can’t be published
![Page 98: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/98.jpg)
Micro-payments from Cryptocurrencies
● Pass, shelat [CCS’16] ● Chiesa, Green, Liu, Miao, Miers, Mishra
[EUROCRYPT’17]
More recent constructions, that achieve better properties
![Page 99: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/99.jpg)
More advanced scripts● Fair multiplayer lotteries and fair multiparty
computation [Andrychowichz-Dziembowski-Malinowski-Mazurek, S&P’14; Bentov-Kumaresan, CRYPTO’14]
● Hash pre-image challenges
![Page 100: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/100.jpg)
More advanced scripts● Fair multiplayer lotteries and fair multiparty
computation [Andrychowichz-Dziembowski-Malinowski-Mazurek, S&P’14; Bentov-Kumaresan, CRYPTO’14]
● Hash pre-image challenges
“Smart contracts”
![Page 101: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/101.jpg)
More advanced scripts● Fair multiplayer lotteries and fair multiparty
computation [Andrychowichz-Dziembowski-Malinowski-Mazurek, S&P’14; Bentov-Kumaresan, CRYPTO’14]
● Hash pre-image challenges
“Smart contracts”Later: More powerful smart contracts with Ethereum (Turing-complete scripting language)
![Page 102: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/102.jpg)
Bitcoin blocks
![Page 103: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/103.jpg)
Bitcoin blocks
Why bundle transactions together? ● Single unit of work for miners ● Limit length of hash-chain of blocks
○ Faster to verify history
![Page 104: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/104.jpg)
trans: H( )prev: H( )
Bitcoin block structure
trans: H( )prev: H( )
trans: H( )prev: H( )
H( ) H( )
H( ) H( ) H( ) H( )
transaction transaction transaction transaction
![Page 105: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/105.jpg)
trans: H( )prev: H( )
Bitcoin block structure
trans: H( )prev: H( )
trans: H( )prev: H( )
H( ) H( )
H( ) H( ) H( ) H( )
transaction transaction transaction transaction
Hash chain of blocks
![Page 106: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/106.jpg)
trans: H( )prev: H( )
Bitcoin block structure
trans: H( )prev: H( )
trans: H( )prev: H( )
H( ) H( )
H( ) H( ) H( ) H( )
transaction transaction transaction transaction
Hash chain of blocks
Hash tree (Merkle tree) of transactions in each block
![Page 107: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/107.jpg)
The real deal: a Bitcoin block{
"hash":"00000000000000001aad2...",
"ver":2,
"prev_block":"00000000000000003043...",
"time":1391279636,
"bits":419558700,
"nonce":459459841,
"mrkl_root":"89776...",
"n_tx":354,
"size":181520,
"tx":[
...
],
"mrkl_tree":[
"6bd5eb25...",
...
"89776cdb..."
]
}
transaction data
block header
![Page 108: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/108.jpg)
The real deal: a Bitcoin block header{ "hash":"00000000000000001aad2...", "ver":2, "prev_block":"00000000000000003043...", "time":1391279636, "bits":419558700, "nonce":459459841, "mrkl_root":"89776...", ... }
![Page 109: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/109.jpg)
The real deal: a Bitcoin block header{ "hash":"00000000000000001aad2...", "ver":2, "prev_block":"00000000000000003043...", "time":1391279636, "bits":419558700, "nonce":459459841, "mrkl_root":"89776...", ... }
mining puzzle information
![Page 110: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/110.jpg)
The real deal: a Bitcoin block header{ "hash":"00000000000000001aad2...", "ver":2, "prev_block":"00000000000000003043...", "time":1391279636, "bits":419558700, "nonce":459459841, "mrkl_root":"89776...", ... }
mining puzzle information
hashed during mining
not hashed
![Page 111: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/111.jpg)
The real deal: coinbase transaction "in":[ { "prev_out":{ "hash":"000000.....0000000", "n":4294967295 },
"coinbase":"..." }, "out":[ { "value":"12.53371419", "scriptPubKey":"OPDUP OPHASH160 ... ”
}
![Page 112: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/112.jpg)
The real deal: coinbase transaction "in":[ { "prev_out":{ "hash":"000000.....0000000", "n":4294967295 },
"coinbase":"..." }, "out":[ { "value":"12.53371419", "scriptPubKey":"OPDUP OPHASH160 ... ”
}
arbitrary
redeeming nothing
![Page 113: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/113.jpg)
The real deal: coinbase transaction "in":[ { "prev_out":{ "hash":"000000.....0000000", "n":4294967295 },
"coinbase":"..." }, "out":[ { "value":"12.53371419", "scriptPubKey":"OPDUP OPHASH160 ... ”
}
arbitrary
redeeming nothing
block rewardtransaction fees
![Page 114: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/114.jpg)
The real deal: coinbase transaction "in":[ { "prev_out":{ "hash":"000000.....0000000", "n":4294967295 },
"coinbase":"..." }, "out":[ { "value":"12.53371419", "scriptPubKey":"OPDUP OPHASH160 ... ”
}
arbitrary
redeeming nothing
Null hash pointer
block rewardtransaction fees
![Page 115: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/115.jpg)
The real deal: coinbase transaction "in":[ { "prev_out":{ "hash":"000000.....0000000", "n":4294967295 },
"coinbase":"..." }, "out":[ { "value":"12.53371419", "scriptPubKey":"OPDUP OPHASH160 ... ”
}
arbitrary
redeeming nothing
Null hash pointer
First ever coinbase parameter: “The Times 03/Jan/2009 Chancellor on brink of second bailout for banks”block reward
transaction fees
![Page 116: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/116.jpg)
See for yourself!
blockchain.info (and many other sites)
![Page 117: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/117.jpg)
The Bitcoin network
![Page 118: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/118.jpg)
Bitcoin P2P network
● Ad-hoc protocol (runs on TCP port 8333) ● Ad-hoc network with random topology ● All nodes are equal ● New nodes can join at any time ● Forget non-responding nodes after 3 hr
![Page 119: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/119.jpg)
Joining the Bitcoin P2P network
1
6
4
7
3
5
2
![Page 120: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/120.jpg)
Joining the Bitcoin P2P network
1
6
4
7
3
5
2
8
Hello World! I’m ready to Bitcoin!
![Page 121: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/121.jpg)
Joining the Bitcoin P2P network
1
6
4
7
3
5
2
8getaddr()
![Page 122: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/122.jpg)
Joining the Bitcoin P2P network
1
6
4
7
3
5
2
8
1, 7
![Page 123: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/123.jpg)
Joining the Bitcoin P2P network
1
6
4
7
3
5
2
8getaddr()getaddr()
![Page 124: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/124.jpg)
Joining the Bitcoin P2P network
1
6
4
7
3
5
2
8
![Page 125: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/125.jpg)
Joining the Bitcoin P2P network
1
6
4
7
3
5
2
8
![Page 126: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/126.jpg)
Transaction propagation (flooding)
1
6
4
7
3
5
2
8
![Page 127: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/127.jpg)
Transaction propagation (flooding)
1
6
4
7
3
5
2
8
New tx! A→B
![Page 128: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/128.jpg)
Transaction propagation (flooding)
1
6
4
7
3
5
2
8
A→B
A→BA→B
![Page 129: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/129.jpg)
Transaction propagation (flooding)
1
6
4
7
3
5
2
8
A→B
A→B
A→B
![Page 130: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/130.jpg)
Transaction propagation (flooding)
1
6
4
7
3
5
2
8
A→B
A→B
A→B
A→B
A→B
![Page 131: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/131.jpg)
Transaction propagation (flooding)
1
6
4
7
3
5
2
8
A→B
A→B
A→BA→B
A→B
![Page 132: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/132.jpg)
Transaction propagation (flooding)
1
6
4
7
3
5
2
8
A→B
A→B
A→BA→B
A→B
A→B
![Page 133: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/133.jpg)
Transaction propagation (flooding)
1
6
4
7
3
5
2
8
A→B
A→B
A→BA→B
A→B
A→B
Already heard that!
![Page 134: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/134.jpg)
Should I relay a proposed transaction?
● Transaction valid with current block chain ● (default) script matches a whitelist
○ Avoid unusual scripts ● Haven’t seen before
○ Avoid infinite loops ● Doesn’t conflict with others I’ve relayed
○ Avoid double-spends
![Page 135: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/135.jpg)
Should I relay a proposed transaction?
● Transaction valid with current block chain ● (default) script matches a whitelist
○ Avoid unusual scripts ● Haven’t seen before
○ Avoid infinite loops ● Doesn’t conflict with others I’ve relayed
○ Avoid double-spends
Sanity checks only... Some nodes may ignore them!
![Page 136: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/136.jpg)
Nodes may differ on transaction pool
1
6
4
7
3
5
2
8
A→B
A→B
A→BA→B
A→B
![Page 137: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/137.jpg)
Nodes may differ on transaction pool
1
6
4
7
3
5
2
8
A→B
A→B
A→BA→B
A→B
New tx! A→C
![Page 138: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/138.jpg)
Nodes may differ on transaction pool
1
6
4
7
3
5
2
8
A→B
A→B
A→BA→B
A→B
A→B
A→C
A→C
A→BA→C
A→C
![Page 139: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/139.jpg)
Nodes may differ on transaction pool
1
6
4
7
3
5
2
8
A→B
A→B
A→BA→B
A→B
A→CA→C
A→B
![Page 140: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/140.jpg)
Race conditions
Transactions or blocks may conflict ● Default behavior: accept what you hear first ● Network position matters ● Miners may implement other logic!
![Page 141: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/141.jpg)
Block propagation nearly identical
Relay a new block when you hear it if: ● Block meets the hash target ● Block has all valid transactions
○ Run all scripts, even if you wouldn’t relay ● Block builds on current longest chain
○ Avoid forks
![Page 142: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/142.jpg)
Block propagation nearly identical
Relay a new block when you hear it if: ● Block meets the hash target ● Block has all valid transactions
○ Run all scripts, even if you wouldn’t relay ● Block builds on current longest chain
○ Avoid forksSanity check Also may be ignored...
![Page 143: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/143.jpg)
Source: Yonatan Sompolinsky and Aviv Zohar: “Accelerating Bitcoin’s Transaction Processing” 2014
![Page 144: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/144.jpg)
Source: Yonatan Sompolinsky and Aviv Zohar: “Accelerating Bitcoin’s Transaction Processing” 2014
NOT an efficient protocol (consequence of the design)
![Page 145: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/145.jpg)
How big is the network?
● Unclear how to measure exactly ● Estimates-up to 1M IP addresses/month ● Only about 5-10k “full nodes”
○ Permanently connected ○ Fully-validate
● This number may be dropping!
![Page 146: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/146.jpg)
Fully-validating nodes
● Permanently connected ● Store entire block chain ● Hear and forward every node/transaction
![Page 147: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/147.jpg)
Thin/SPV clients (not fully-validating)
Idea: don’t store everything ● Store block headers only ● Request transactions as needed
○ To verify incoming payment ● Trust fully-validating nodes
![Page 148: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/148.jpg)
Limitations & improvements
![Page 149: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/149.jpg)
Hard-coded limits in Bitcoin
● 10 min. average creation time per block ● 1 M bytes in a block ● 20,000 signature operations per block ● 23M total bitcoins maximum ● 50,25,12.5... bitcoin mining reward
![Page 150: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/150.jpg)
Hard-coded limits in Bitcoin
● 10 min. average creation time per block ● 1 M bytes in a block ● 20,000 signature operations per block ● 23M total bitcoins maximum ● 50,25,12.5... bitcoin mining reward
These affect economic balance of power too much to change now
![Page 151: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/151.jpg)
Throughput limits in Bitcoin
● 1 M bytes/block (10 min) ● >250 bytes/transaction ● 7 transactions/sec ☹
Compare to: ● VISA: 2,000-10,000 transactions/sec ● PayPal: 50-100 transaction/sec
![Page 152: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/152.jpg)
Throughput limits in Bitcoin
● 1 M bytes/block (10 min) ● >250 bytes/transaction ● 7 transactions/sec ☹
Compare to: ● VISA: 2,000-10,000 transactions/sec ● PayPal: 50-100 transaction/sec
Improving throughput: A strong motivation for Altcoins
![Page 153: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/153.jpg)
Cryptographic limits in Bitcoin
● Only 1 signature algorithm (ECDSA/P256) ● Hard-coded hash functions
Some of these crypto primitives used here might break by 2040 (e.g., collision-found in hash function, or powerful quantum computer breaks ECDSA)...
![Page 154: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/154.jpg)
Why not update Bitcoin software to overcome these limitations?
● Many of these changes require “hard forks”, which are currently considered unacceptable
![Page 155: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/155.jpg)
“Hard-forking” changes to Bitcoin
1
6
4
7
3
5
2
8
Block 23
Block 23
Block 23
Block 23
Block 23
Block 23
Block 23
Block 23
![Page 156: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/156.jpg)
“Hard-forking” changes to Bitcoin
1
6
4
7
3
5
2
8
I found a nifty new block!
Block 23
Block 23
Block 23
Block 23
Block 23
Block 23
Block 23
Block 23
![Page 157: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/157.jpg)
“Hard-forking” changes to Bitcoin
1
6
4
7
3
5
2
8
Block 24
Block 23
Block 23
Block 23
Block 23
Block 23
Block 23
Block 23
2424
![Page 158: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/158.jpg)
“Hard-forking” changes to Bitcoin
1
6
4
7
3
5
2
8
Block 24
Block 24
Block 23
Block 23
Block 23
Block 23
Block 23
Block 23
2424
That’s crazy talk!!
![Page 159: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/159.jpg)
“Hard-forking” changes to Bitcoin
1
6
4
7
3
5
2
8
Block 24
Block 24
Block 23
Block 23
Block 23
Block 23
Block 23
Block 23
24
24
That’s crazy talk!!
![Page 160: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/160.jpg)
“Hard-forking” changes to Bitcoin
1
6
4
7
3
5
2
8
Block 24
Block 24
Block 24
Block 24
Block 24
Block 23
Block 23
Block 23
![Page 161: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/161.jpg)
“Hard-forking” changes to Bitcoin
1
6
4
7
3
5
2
8
Block 24
Block 24
Block 24
Block 24
Block 24
Block 23
Block 23
Block 23
PROBLEM: Old nodes will never catch up
![Page 162: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/162.jpg)
Soft forks
Observation: we can add new features which only limit the set of valid transactions
Need majority of nodes to enforce new rules
Old nodes will approve
![Page 163: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/163.jpg)
Soft forks
Observation: we can add new features which only limit the set of valid transactions
Need majority of nodes to enforce new rules
Old nodes will approve
RISK: Old nodes might mine now-invalid blocks
![Page 164: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/164.jpg)
Soft fork example: pay to script hash
OP_HASH160 <hash of redemption script> OP_EQUAL
<signature> <<pubkey> OP_CHECKSIG>
Old nodes will just approve the hash, not run the embedded script
![Page 165: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/165.jpg)
Soft fork possibilities
● New signature schemes ● Extra per-block metadata
○ Shove in the coinbase parameter ○ Commit to unspent transaction tree in each block
![Page 166: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/166.jpg)
Hard forks
● New op codes ● Changes to size limits ● Changes to mining rate ● Many small bug fixes
![Page 167: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/167.jpg)
Hard forks
● New op codes ● Changes to size limits ● Changes to mining rate ● Many small bug fixes
Currently seem unlikely to happen
![Page 168: Lecture 6 - cs.jhu.eduabhishek/classes/CS601-641-441-Spring2018/Lectur… · Lecture 6 Mechanics of Bitcoin. Bitcoin transactions. An account-based ledger (not Bitcoin) ... 2 3 4](https://reader034.vdocument.in/reader034/viewer/2022051803/5b38b60e7f8b9a4b0a8bff4d/html5/thumbnails/168.jpg)
Hard forks
● New op codes ● Changes to size limits ● Changes to mining rate ● Many small bug fixes
Currently seem unlikely to happen
Many of these issues addressed by Altcoins