1Copyright © 2017 All rights reserved. AIR at en-japan inc.
The Bitcoin Blockchain
2Copyright © 2017 All rights reserved. AIR at en-japan inc.
- We are gonna go in depth in how the bitcoin blockchain works.
- For now all you have to know is that the btc blockchain is a p2p distributed
read only write only once ledger.
Introduction
3Copyright © 2017 All rights reserved. AIR at en-japan inc.
- A public key is generated with ECDSA (Elliptic Curve Digital Signature
Algorithm) from a random private key
Bitcoin address?
You can just flip a coin 256 times to get a private key or use a computer :)
Note: Total number of possible btc addresses 2^160, it’s bigger than (the number of grains of
sand on earth) ^ 2
4Copyright © 2017 All rights reserved. AIR at en-japan inc.
Elliptic Curve
y^2 = x^3 + ax + b
secp256k1
a = 0
b = 7
Max
(keysize)
More secure than RSA
A lot less space used
Pk = Sk * G
5Copyright © 2017 All rights reserved. AIR at en-japan inc.
- When you make a transaction you sign it with your private key.
- A btc address is derived from a public key generated from your private key
and encoded in Base58Check
Bitcoin address?
k K A
Private key </= Public key </= Btc address
ECC Hashing
6Copyright © 2017 All rights reserved. AIR at en-japan inc.
Bitcoin address Generation Steps
Public key
SHA256
RIPEMD160
1KbYHh7LjcUxpcrKWsxmrhEsrF9BjBS3km
RIPEMD = RACE Integrity Primitives
Evaluation Message Digest
Version Payload
SHA256
SHA256
First 4 bytes
Version Payload Checksum
Base58
Base58Check
Encode
7Copyright © 2017 All rights reserved. AIR at en-japan inc.
- With a private key we can now sign transactions.
- Each transaction contains inputs transactions and outputs transactions. When
you create a transaction the inputs are your bitcoins, the outputs contains the
btc addresses you want to send these btc to.
- It's possible to sign a transaction that will only be valid in the future. You can
set a variable called nLockTime to either a timestamp or a block height. Then
the transaction will only be included in the blockchain after the block height or
timestamp you specified.
Transactions
8Copyright © 2017 All rights reserved. AIR at en-japan inc.
Transactions
4 bytes Version Specifies which rules this
transaction follows
1-9 bytes (VarInt) Input Counter How many inputs are
included
Variable Inputs One or more transaction
inputs
1-9 bytes (VarInt) Output counter How many outputs do we
have
Variable Outputs One or more outputs
4 bytes nLockTime A unix timestamp or block
number
9Copyright © 2017 All rights reserved. AIR at en-japan inc.
Transactions
Alice needs to pay Bob 5 BTC.
She has 6 BTC left in a previous unspent transaction output (UTXO),
she decides to use that UTXO as input of a new 5 BTC transaction to
Bob.
That means she’ll have to create a transaction with 2 UTXO, one is for
Bob btc address for 5 BTC, and the second one is for an address she
owns, for 1 BTC minus fees.
Alice previous txid (contains 6BTC):
3f4fa19803dec4d6a84fae3821da7a
c7577080ef75
16au1M18Pcu9wzz79
hAznvdh8nt1opjEcz
(5BTC bob)
14h22VUd4393feMAU
Xb8hbyJo5wmrKtezu
(1BTC - fees Alice)
All UTXO balance should always match transaction input balance
minus fees.
10Copyright © 2017 All rights reserved. AIR at en-japan inc.
- The transaction Alice did is still not broadcasted to the network. So that’s
nothing more than a signed check for now.
Transactions
11Copyright © 2017 All rights reserved. AIR at en-japan inc.
- Contains an amount of bitcoins, a LockScript (ScriptPubKey), and an
UnlockScript (ScriptSig)
UTXO
{
"txid" :
"263c018582731ff54dc72c7d67e858c002ae298835501d
80200f05753de0edf0",
"address" :
"mvbnrCX3bg1cDRUu8pkecrvP6vQkSLDSou",
"scriptPubKey" :
"76a914cbc20a7664f2f69e5355aa427045bc15e7c6c7728
8ac",
"amount" : 10.00000000,
"confirmations" : 0,
}
76a914cbc20a7664f2f69e5355aa427045bc15e7c6c77288ac
Is the hex representation of:
OP_DUP OP_HASH160 cbc20a7664f2f69e5355a
a427045bc15e7c6c772 OP_EQUALVERIFY OP_CHECKSIG
12Copyright © 2017 All rights reserved. AIR at en-japan inc.
- Pay to Public Key Hash (P2PKH)
- Pay to Public Key
- Multi Signature (limit 15 keys)
- Pay to Script Hash (P2SH)
- Data Output (OP_RETURN)
Different transactions
13Copyright © 2017 All rights reserved. AIR at en-japan inc.
When Alice pays Bob she generates a LockScript:
OP_DUP OP_HASH160 <Bob Public Key Hash> OP_EQUAL OP_CHECKSIG
To be able to spend that money, Bob needs to generate the following
UnlockScript:
<Bob Signature> <Bob public key>
Concatenating UnlockScript + LockScript and executing it should return TRUE.
Pay to Public Key Hash (P2PKH)
14Copyright © 2017 All rights reserved. AIR at en-japan inc.
Same as before but without Hashes, it used to be the standard long time ago
when people didn’t have btc addresses but sent directly to pubkeys
<Bob Public Key> OP_CHECKSIG
To be able to spend that money, Bob needs to generate the following
UnlockScript:
<Bob Signature>
Concatenating UnlockScript + LockScript and executing it should return TRUE.
Pay to Public Key (P2PK)
15Copyright © 2017 All rights reserved. AIR at en-japan inc.
A very interesting feature. You can create a lockScript that can only be unlocked if
multiple keys are used (limit 15). Great way to do joint accounts or escrow
systems.
M <pubkey 1> <pubkey 2> … <pubkey N> N OP_CHECKMULTISIG
M is the threshold of required signatures to spend the output and N the total
number of pubkeys.
To be able to spend that money, Bob needs to generate the following
UnlockScript:
OP_0 <Signature 1> <Signature 2>...
MultiSignature
16Copyright © 2017 All rights reserved. AIR at en-japan inc.
This is a new way to do multi signatures transactions.
Pay to Script Hash (P2SH)
Without P2SH:
LockingScript: 2 Pubkey1 Pubkey2 OP_CHECKMULTISIG
UnlockingScript: Sig1 Sig2
With P2SH:
Redeem Script: 2 Pubkey1 Pubkey2 OP_CHECKMULTISIG
LockingScript: OP_HASH160 <20 bytes hash of redeem script> OP_EQUAL
UnlockingScript: Sig1 Sig2 redeem script
17Copyright © 2017 All rights reserved. AIR at en-japan inc.
It is possible to simply write data in the blockchain in a transaction script. It’s very
useful for uses beyond payments, like stock certificates, proof of existence etc..
OP_RETURN <data>
This UTXO can never be spent and you can store a maximum of 80 bytes.
Data Output OP_RETURN
18Copyright © 2017 All rights reserved. AIR at en-japan inc.
Miners:
- Check that transaction is signed with the key matching the inputs (i.e the
inputs belong to Alice and the message has not been tampered)
- Sum of inputs > Sum of outputs (Sum(inputs) - Sum(outputs) = fees)
- The inputs are unspent (would have to read the whole blockchain to check
that but nowadays there is an UTXO index for that purpose)
Miners and blocks
19Copyright © 2017 All rights reserved. AIR at en-japan inc.
- Miner generate a coinbase transaction (no UTXO as input)
- SHA256(the content of the block header + a random value) needs to be lower
than a specific difficulty value.
- One block is mined every 10 minutes. Difficulty adjusted every 2016 blocks.
- Each block contains a Merkle Tree root, it’s used to quickly check if a specific
transaction is included in a specific block. All transactions are hashed and
summarized into one node at the root of the tree.
Proof of work
20Copyright © 2017 All rights reserved. AIR at en-japan inc.
Genesis block
The first mined block has been mined by Satoshi Nakamoto on January 3rd 2009.
It’s called the Genesis block.
You can find this hidden message in it:
“ The Times 03/Jan/2009 Chancellor on brink of second bailout for banks.”
This message is here as a proof of the earliest date the block could have been mined
21Copyright © 2017 All rights reserved. AIR at en-japan inc.
Sometimes 2 miners find the
solution at the same time.
2 blocks found at the same time?
22Copyright © 2017 All rights reserved. AIR at en-japan inc.
Sometimes 2 miners find the
solution at the same time.
In that situation we have a fork.
2 blocks found at the same time?
23Copyright © 2017 All rights reserved. AIR at en-japan inc.
The next miner finding a block
will have to choose one as a
parent block.
2 blocks found at the same time?
24Copyright © 2017 All rights reserved. AIR at en-japan inc.
The bitcoin mining software
always choose the longest chain
by default for the next block.
So now we have an orphan
block!
All transactions in that block have
now 0 confirmations and are out
of the blockchain! These
transactions have to be included
in a block again. That’s why you
should always wait for 3
confirmations (blocks) at least.
2 blocks found at the same time?
25Copyright © 2017 All rights reserved. AIR at en-japan inc.
If a miner had 50% of the mining
network they can in theory find a
block 50% of the time. That
means they can abuse the
system and do a double spend.
BTC Guild few years ago mined 6
blocks in a row.
2 blocks found at the same time?
26Copyright © 2017 All rights reserved. AIR at en-japan inc.
Common double spend
Alice previous txid (contains 1BTC):
3f4fa19803dec4d6a84fae3821da7a
c7577080ef75
1HYGn4HvcM8eZaAFb
GYSGxG1xPTRYXWt3z
(1BTC to Alice)
Alice previous txid (contains 1BTC):
3f4fa19803dec4d6a84fae3821da7a
c7577080ef75
14h22VUd4393feMAU
Xb8hbyJo5wmrKtezu
(1BTC to Bob)
27Copyright © 2017 All rights reserved. AIR at en-japan inc.
All blocks contain in their header
the hash of the previous block.
If the red block gets modified, all
subsequent blocks will have to be
recalculated.
Why is the past so immutable?
28Copyright © 2017 All rights reserved. AIR at en-japan inc.
Pseudonymity
Bitcoin is not anonymous but pseudonymous.
Everyone can see all the transactions, who send money to whom, the values of transactions, etc
Your IP address is also inside each packet.
You also need to be careful of blockchain analysis. Many websites already do that and can find the
balance of big users (like exchanges etc).
Coinbase banned users buying drugs with their bitcoins, so they do blockchain analysis.
What people do usually to hide themselves is using Tumblers. (careful, prone to timing attacks and you
have to trust the tumbling service which could be and must be owned by the Feds)
29Copyright © 2017 All rights reserved. AIR at en-japan inc.
Alternatives Blockchains based on Bitcoin’s code
30Copyright © 2017 All rights reserved. AIR at en-japan inc.
Alternatives Blockchains based on Bitcoin’s code
31Copyright © 2017 All rights reserved. AIR at en-japan inc.
Alternatives Blockchains based on Bitcoin’s code
32Copyright © 2017 All rights reserved. AIR at en-japan inc.
Alternatives Blockchains based on Bitcoin’s code
33Copyright © 2017 All rights reserved. AIR at en-japan inc.
Alternatives Blockchains NOT based on Bitcoin’s code
34Copyright © 2017 All rights reserved. AIR at en-japan inc.
Cryptos based on a Tangle
35Copyright © 2017 All rights reserved. AIR at en-japan inc.
Blockchains can be used for
- Voting systems (See https://www.ethereum.org/dao)
- Patents
- Smart Contracts
- Any contract, like a marriage contract with multiple keys owned by multiple people.
- Proving that something happened in the past (e.g Bob worked for company X from 2001 to 2003)
- Developing Escrow systems like Paypal with zero infrastructure/employees.
- Storing data in P2P in a secure manner (can’t be tampered, only the owners can modify)
36Copyright © 2017 All rights reserved. AIR at en-japan inc.
Questions?

More Related Content

PDF
Through the looking glass (of the blockchain)
PDF
Reutov, yunusov, nagibin random numbers take ii
PDF
Bitcoin protocol for developers at techfest
PDF
Ethereum VM and DSLs for Smart Contracts (updated on May 12th 2015)
PDF
Introduction to Lightning Network
PPTX
“Technical Intro to Blockhain” by Yurijs Pimenovs from Paybis at CryptoCurren...
PDF
Intro. to Lightning Network (Bitcoin/Litecoin) - Blockchain Developers Malaysia
Through the looking glass (of the blockchain)
Reutov, yunusov, nagibin random numbers take ii
Bitcoin protocol for developers at techfest
Ethereum VM and DSLs for Smart Contracts (updated on May 12th 2015)
Introduction to Lightning Network
“Technical Intro to Blockhain” by Yurijs Pimenovs from Paybis at CryptoCurren...
Intro. to Lightning Network (Bitcoin/Litecoin) - Blockchain Developers Malaysia

What's hot (18)

PDF
Bitcoin protocol for developerBitcoin Protocol for Developers
PDF
Bitcoin and Blockchain
PPTX
The Burden of Proof
PPTX
Presentation_Topalidis_Giorgos
PDF
Protocol buffers and Microservices
ODP
Fredericksburg LUG Bitcoin slides
PPTX
Blockchain Cryptography for Developers (Nakov @ BGWebSummit 2018)
PDF
Cryptography For The Average Developer - Sunshine PHP
ODP
Real world blockchains
PDF
Introduction to JWT and How to integrate with Spring Security
PDF
Smart contracts using web3.js
PPTX
J.burke HackMiami6
PPTX
Technology of Lightning Network in Tel Aviv, Israel
PPTX
Cryptography for Absolute Beginners (May 2019)
PDF
Cryptography With PHP - ZendCon 2017 Workshop
PDF
Common Browser Hijacking Methods
PPTX
Monero Presentation by Justin Ehrenhofer - Oslo, Norway 2017
PDF
JSON Web Tokens Will Improve Your Life
Bitcoin protocol for developerBitcoin Protocol for Developers
Bitcoin and Blockchain
The Burden of Proof
Presentation_Topalidis_Giorgos
Protocol buffers and Microservices
Fredericksburg LUG Bitcoin slides
Blockchain Cryptography for Developers (Nakov @ BGWebSummit 2018)
Cryptography For The Average Developer - Sunshine PHP
Real world blockchains
Introduction to JWT and How to integrate with Spring Security
Smart contracts using web3.js
J.burke HackMiami6
Technology of Lightning Network in Tel Aviv, Israel
Cryptography for Absolute Beginners (May 2019)
Cryptography With PHP - ZendCon 2017 Workshop
Common Browser Hijacking Methods
Monero Presentation by Justin Ehrenhofer - Oslo, Norway 2017
JSON Web Tokens Will Improve Your Life
Ad

Similar to The bitcoin blockchain (20)

PPTX
以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)
PDF
Bitcoin for programmers - part 1 version 2
PDF
CRYPTO CURRENCY-2022OD205.pdf
PDF
Bitcoin - Beyond the basics
PPTX
Blockchain and Bitcoin.pptx
PPTX
15-Bitcoin.pptx
PPTX
bitcoin
PPTX
Webinar on BITCOIN FORENSICS : BRIGHTTALK
PDF
Bitcoin Blockchain - Under the Hood
PPTX
Fundamentals of Blockchain Technology
PPTX
Bitcoin and it's security related to transaction.pptx
PPTX
20190606 blockchain101
PPTX
Bitcoin developer guide
PPTX
Bitcoin
PDF
Introduction to Bitcoin for programmers
PPTX
Node.js Blockchain Implementation
PDF
Introduction to Blockchains
PPTX
Intro to blockchain
PDF
Connecting The Block Cointelligence Academy by Dr Vince Ming
PPTX
BlockchainConf.tech - Build a private blockchain workshop
以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)
Bitcoin for programmers - part 1 version 2
CRYPTO CURRENCY-2022OD205.pdf
Bitcoin - Beyond the basics
Blockchain and Bitcoin.pptx
15-Bitcoin.pptx
bitcoin
Webinar on BITCOIN FORENSICS : BRIGHTTALK
Bitcoin Blockchain - Under the Hood
Fundamentals of Blockchain Technology
Bitcoin and it's security related to transaction.pptx
20190606 blockchain101
Bitcoin developer guide
Bitcoin
Introduction to Bitcoin for programmers
Node.js Blockchain Implementation
Introduction to Blockchains
Intro to blockchain
Connecting The Block Cointelligence Academy by Dr Vince Ming
BlockchainConf.tech - Build a private blockchain workshop
Ad

Recently uploaded (20)

PDF
sustainability-14-14877-v2.pddhzftheheeeee
DOCX
search engine optimization ppt fir known well about this
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
PPTX
2018-HIPAA-Renewal-Training for executives
PDF
Comparative analysis of machine learning models for fake news detection in so...
PPTX
TEXTILE technology diploma scope and career opportunities
PDF
UiPath Agentic Automation session 1: RPA to Agents
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
Five Habits of High-Impact Board Members
PDF
A review of recent deep learning applications in wood surface defect identifi...
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
Zenith AI: Advanced Artificial Intelligence
PPTX
Microsoft Excel 365/2024 Beginner's training
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PPT
Geologic Time for studying geology for geologist
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
1 - Historical Antecedents, Social Consideration.pdf
sustainability-14-14877-v2.pddhzftheheeeee
search engine optimization ppt fir known well about this
Module 1.ppt Iot fundamentals and Architecture
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
2018-HIPAA-Renewal-Training for executives
Comparative analysis of machine learning models for fake news detection in so...
TEXTILE technology diploma scope and career opportunities
UiPath Agentic Automation session 1: RPA to Agents
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Five Habits of High-Impact Board Members
A review of recent deep learning applications in wood surface defect identifi...
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Zenith AI: Advanced Artificial Intelligence
Microsoft Excel 365/2024 Beginner's training
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
OpenACC and Open Hackathons Monthly Highlights July 2025
Geologic Time for studying geology for geologist
NewMind AI Weekly Chronicles – August ’25 Week III
1 - Historical Antecedents, Social Consideration.pdf

The bitcoin blockchain

  • 1. 1Copyright © 2017 All rights reserved. AIR at en-japan inc. The Bitcoin Blockchain
  • 2. 2Copyright © 2017 All rights reserved. AIR at en-japan inc. - We are gonna go in depth in how the bitcoin blockchain works. - For now all you have to know is that the btc blockchain is a p2p distributed read only write only once ledger. Introduction
  • 3. 3Copyright © 2017 All rights reserved. AIR at en-japan inc. - A public key is generated with ECDSA (Elliptic Curve Digital Signature Algorithm) from a random private key Bitcoin address? You can just flip a coin 256 times to get a private key or use a computer :) Note: Total number of possible btc addresses 2^160, it’s bigger than (the number of grains of sand on earth) ^ 2
  • 4. 4Copyright © 2017 All rights reserved. AIR at en-japan inc. Elliptic Curve y^2 = x^3 + ax + b secp256k1 a = 0 b = 7 Max (keysize) More secure than RSA A lot less space used Pk = Sk * G
  • 5. 5Copyright © 2017 All rights reserved. AIR at en-japan inc. - When you make a transaction you sign it with your private key. - A btc address is derived from a public key generated from your private key and encoded in Base58Check Bitcoin address? k K A Private key </= Public key </= Btc address ECC Hashing
  • 6. 6Copyright © 2017 All rights reserved. AIR at en-japan inc. Bitcoin address Generation Steps Public key SHA256 RIPEMD160 1KbYHh7LjcUxpcrKWsxmrhEsrF9BjBS3km RIPEMD = RACE Integrity Primitives Evaluation Message Digest Version Payload SHA256 SHA256 First 4 bytes Version Payload Checksum Base58 Base58Check Encode
  • 7. 7Copyright © 2017 All rights reserved. AIR at en-japan inc. - With a private key we can now sign transactions. - Each transaction contains inputs transactions and outputs transactions. When you create a transaction the inputs are your bitcoins, the outputs contains the btc addresses you want to send these btc to. - It's possible to sign a transaction that will only be valid in the future. You can set a variable called nLockTime to either a timestamp or a block height. Then the transaction will only be included in the blockchain after the block height or timestamp you specified. Transactions
  • 8. 8Copyright © 2017 All rights reserved. AIR at en-japan inc. Transactions 4 bytes Version Specifies which rules this transaction follows 1-9 bytes (VarInt) Input Counter How many inputs are included Variable Inputs One or more transaction inputs 1-9 bytes (VarInt) Output counter How many outputs do we have Variable Outputs One or more outputs 4 bytes nLockTime A unix timestamp or block number
  • 9. 9Copyright © 2017 All rights reserved. AIR at en-japan inc. Transactions Alice needs to pay Bob 5 BTC. She has 6 BTC left in a previous unspent transaction output (UTXO), she decides to use that UTXO as input of a new 5 BTC transaction to Bob. That means she’ll have to create a transaction with 2 UTXO, one is for Bob btc address for 5 BTC, and the second one is for an address she owns, for 1 BTC minus fees. Alice previous txid (contains 6BTC): 3f4fa19803dec4d6a84fae3821da7a c7577080ef75 16au1M18Pcu9wzz79 hAznvdh8nt1opjEcz (5BTC bob) 14h22VUd4393feMAU Xb8hbyJo5wmrKtezu (1BTC - fees Alice) All UTXO balance should always match transaction input balance minus fees.
  • 10. 10Copyright © 2017 All rights reserved. AIR at en-japan inc. - The transaction Alice did is still not broadcasted to the network. So that’s nothing more than a signed check for now. Transactions
  • 11. 11Copyright © 2017 All rights reserved. AIR at en-japan inc. - Contains an amount of bitcoins, a LockScript (ScriptPubKey), and an UnlockScript (ScriptSig) UTXO { "txid" : "263c018582731ff54dc72c7d67e858c002ae298835501d 80200f05753de0edf0", "address" : "mvbnrCX3bg1cDRUu8pkecrvP6vQkSLDSou", "scriptPubKey" : "76a914cbc20a7664f2f69e5355aa427045bc15e7c6c7728 8ac", "amount" : 10.00000000, "confirmations" : 0, } 76a914cbc20a7664f2f69e5355aa427045bc15e7c6c77288ac Is the hex representation of: OP_DUP OP_HASH160 cbc20a7664f2f69e5355a a427045bc15e7c6c772 OP_EQUALVERIFY OP_CHECKSIG
  • 12. 12Copyright © 2017 All rights reserved. AIR at en-japan inc. - Pay to Public Key Hash (P2PKH) - Pay to Public Key - Multi Signature (limit 15 keys) - Pay to Script Hash (P2SH) - Data Output (OP_RETURN) Different transactions
  • 13. 13Copyright © 2017 All rights reserved. AIR at en-japan inc. When Alice pays Bob she generates a LockScript: OP_DUP OP_HASH160 <Bob Public Key Hash> OP_EQUAL OP_CHECKSIG To be able to spend that money, Bob needs to generate the following UnlockScript: <Bob Signature> <Bob public key> Concatenating UnlockScript + LockScript and executing it should return TRUE. Pay to Public Key Hash (P2PKH)
  • 14. 14Copyright © 2017 All rights reserved. AIR at en-japan inc. Same as before but without Hashes, it used to be the standard long time ago when people didn’t have btc addresses but sent directly to pubkeys <Bob Public Key> OP_CHECKSIG To be able to spend that money, Bob needs to generate the following UnlockScript: <Bob Signature> Concatenating UnlockScript + LockScript and executing it should return TRUE. Pay to Public Key (P2PK)
  • 15. 15Copyright © 2017 All rights reserved. AIR at en-japan inc. A very interesting feature. You can create a lockScript that can only be unlocked if multiple keys are used (limit 15). Great way to do joint accounts or escrow systems. M <pubkey 1> <pubkey 2> … <pubkey N> N OP_CHECKMULTISIG M is the threshold of required signatures to spend the output and N the total number of pubkeys. To be able to spend that money, Bob needs to generate the following UnlockScript: OP_0 <Signature 1> <Signature 2>... MultiSignature
  • 16. 16Copyright © 2017 All rights reserved. AIR at en-japan inc. This is a new way to do multi signatures transactions. Pay to Script Hash (P2SH) Without P2SH: LockingScript: 2 Pubkey1 Pubkey2 OP_CHECKMULTISIG UnlockingScript: Sig1 Sig2 With P2SH: Redeem Script: 2 Pubkey1 Pubkey2 OP_CHECKMULTISIG LockingScript: OP_HASH160 <20 bytes hash of redeem script> OP_EQUAL UnlockingScript: Sig1 Sig2 redeem script
  • 17. 17Copyright © 2017 All rights reserved. AIR at en-japan inc. It is possible to simply write data in the blockchain in a transaction script. It’s very useful for uses beyond payments, like stock certificates, proof of existence etc.. OP_RETURN <data> This UTXO can never be spent and you can store a maximum of 80 bytes. Data Output OP_RETURN
  • 18. 18Copyright © 2017 All rights reserved. AIR at en-japan inc. Miners: - Check that transaction is signed with the key matching the inputs (i.e the inputs belong to Alice and the message has not been tampered) - Sum of inputs > Sum of outputs (Sum(inputs) - Sum(outputs) = fees) - The inputs are unspent (would have to read the whole blockchain to check that but nowadays there is an UTXO index for that purpose) Miners and blocks
  • 19. 19Copyright © 2017 All rights reserved. AIR at en-japan inc. - Miner generate a coinbase transaction (no UTXO as input) - SHA256(the content of the block header + a random value) needs to be lower than a specific difficulty value. - One block is mined every 10 minutes. Difficulty adjusted every 2016 blocks. - Each block contains a Merkle Tree root, it’s used to quickly check if a specific transaction is included in a specific block. All transactions are hashed and summarized into one node at the root of the tree. Proof of work
  • 20. 20Copyright © 2017 All rights reserved. AIR at en-japan inc. Genesis block The first mined block has been mined by Satoshi Nakamoto on January 3rd 2009. It’s called the Genesis block. You can find this hidden message in it: “ The Times 03/Jan/2009 Chancellor on brink of second bailout for banks.” This message is here as a proof of the earliest date the block could have been mined
  • 21. 21Copyright © 2017 All rights reserved. AIR at en-japan inc. Sometimes 2 miners find the solution at the same time. 2 blocks found at the same time?
  • 22. 22Copyright © 2017 All rights reserved. AIR at en-japan inc. Sometimes 2 miners find the solution at the same time. In that situation we have a fork. 2 blocks found at the same time?
  • 23. 23Copyright © 2017 All rights reserved. AIR at en-japan inc. The next miner finding a block will have to choose one as a parent block. 2 blocks found at the same time?
  • 24. 24Copyright © 2017 All rights reserved. AIR at en-japan inc. The bitcoin mining software always choose the longest chain by default for the next block. So now we have an orphan block! All transactions in that block have now 0 confirmations and are out of the blockchain! These transactions have to be included in a block again. That’s why you should always wait for 3 confirmations (blocks) at least. 2 blocks found at the same time?
  • 25. 25Copyright © 2017 All rights reserved. AIR at en-japan inc. If a miner had 50% of the mining network they can in theory find a block 50% of the time. That means they can abuse the system and do a double spend. BTC Guild few years ago mined 6 blocks in a row. 2 blocks found at the same time?
  • 26. 26Copyright © 2017 All rights reserved. AIR at en-japan inc. Common double spend Alice previous txid (contains 1BTC): 3f4fa19803dec4d6a84fae3821da7a c7577080ef75 1HYGn4HvcM8eZaAFb GYSGxG1xPTRYXWt3z (1BTC to Alice) Alice previous txid (contains 1BTC): 3f4fa19803dec4d6a84fae3821da7a c7577080ef75 14h22VUd4393feMAU Xb8hbyJo5wmrKtezu (1BTC to Bob)
  • 27. 27Copyright © 2017 All rights reserved. AIR at en-japan inc. All blocks contain in their header the hash of the previous block. If the red block gets modified, all subsequent blocks will have to be recalculated. Why is the past so immutable?
  • 28. 28Copyright © 2017 All rights reserved. AIR at en-japan inc. Pseudonymity Bitcoin is not anonymous but pseudonymous. Everyone can see all the transactions, who send money to whom, the values of transactions, etc Your IP address is also inside each packet. You also need to be careful of blockchain analysis. Many websites already do that and can find the balance of big users (like exchanges etc). Coinbase banned users buying drugs with their bitcoins, so they do blockchain analysis. What people do usually to hide themselves is using Tumblers. (careful, prone to timing attacks and you have to trust the tumbling service which could be and must be owned by the Feds)
  • 29. 29Copyright © 2017 All rights reserved. AIR at en-japan inc. Alternatives Blockchains based on Bitcoin’s code
  • 30. 30Copyright © 2017 All rights reserved. AIR at en-japan inc. Alternatives Blockchains based on Bitcoin’s code
  • 31. 31Copyright © 2017 All rights reserved. AIR at en-japan inc. Alternatives Blockchains based on Bitcoin’s code
  • 32. 32Copyright © 2017 All rights reserved. AIR at en-japan inc. Alternatives Blockchains based on Bitcoin’s code
  • 33. 33Copyright © 2017 All rights reserved. AIR at en-japan inc. Alternatives Blockchains NOT based on Bitcoin’s code
  • 34. 34Copyright © 2017 All rights reserved. AIR at en-japan inc. Cryptos based on a Tangle
  • 35. 35Copyright © 2017 All rights reserved. AIR at en-japan inc. Blockchains can be used for - Voting systems (See https://www.ethereum.org/dao) - Patents - Smart Contracts - Any contract, like a marriage contract with multiple keys owned by multiple people. - Proving that something happened in the past (e.g Bob worked for company X from 2001 to 2003) - Developing Escrow systems like Paypal with zero infrastructure/employees. - Storing data in P2P in a secure manner (can’t be tampered, only the owners can modify)
  • 36. 36Copyright © 2017 All rights reserved. AIR at en-japan inc. Questions?

Editor's Notes

  • #12: As you can see there is a scripting language integrated into Bitcoin. It’s a very simple non turing complete stack based language. When Alice sent money to Bob she generated that exact LockScript in the transaction. Only Bob can provide the UnlockScript to actually spend the money he received. This is typical to most of bitcoin transactions and it’s called a P2PKH transaction (Pay2PublicKeyHash)
  • #17: As you can see, with P2SH Alice doesn’t need to generate a very long LockingScript containing all the Pubkeys. She can create it with a simple hash. Only Bob when he wants to spend that money will have to generate a long UnlockingScript. Less bloat on the blockchain, less fees for Alice. Bonus point, Bob can now generate a btc address containing that 20 bytes hash of the redeem script. These type of addresse start with 3. Alice can simply send money there.
  • #19: Miners do that job for each transaction and put these transactions into blocks. The blockchain is a chain of blocks, each block refers to the previous block by hash. Like each transaction refers to a previous transaction.
  • #20: They add the (Sum of inputs - Sum of outputs) which represents the total fees in the coinbase transaction + the block reward
  • #26: A faster blocktime would make transactions clear faster but lead to more frequent forks, whereas a slower block time would decrease the number of forks but make settlement slower.