More Than You Need To Know AboutBitcoin Technology
Kenji Saito
Senior Visiting Researcher, Keio Research Institute at SFC
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.1/46
And you are. . .?
Kenji Saito, Ph.D. (Media and Governance)Senior Visiting Researcher of Keio Research Institute at SFCRepresentative Director of Academy Camphttp://twitter.com/ks91020 http://www.facebook.com/ks91media
Doing research on the Internet and SocietyFocus :Human digital currencies and applications
Organizing camps for children in Fukushima
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.2/46
And you are. . .?
Kenji Saito, Ph.D. (Media and Governance)Senior Visiting Researcher of Keio Research Institute at SFCRepresentative Director of Academy Camphttp://twitter.com/ks91020 http://www.facebook.com/ks91media
Doing research on the Internet and SocietyFocus :Human digital currencies and applications
Organizing camps for children in Fukushima
→ Well-connected in my mind
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.2/46
Bibliography (1)
“NEO in Wonderland”(2009)
Genre:“Sci-Fi Monetary Fantasy”
Digital currency thatchanges money
Which creates a drama
Free English translation
http://grsj.jp/neo.pdf(CC-BY-SA 3.0)
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.3/46
Bibliography (2)
“Now You Understand Bitcoin”(2014)
Genre:“Stealth Marketing”
Looks like a book onBitcoin. . .
A 180-degree differentconcept
A Trojan horse(that you can read)
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.4/46
Bibliography (3)
“The Internet Changes‘Money’ ” (2014)
Genre:“Short Story”
A fantasy on who SatoshiNakamoto is
And how the Internetchanges everything
And how quick a Ubertaxi comes
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.5/46
What’s Bitcoin?
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.6/46
What’s Bitcoin Anyway?
“What is needed is an electronic payment systembased on cryptographic proof instead of trust”
Satoshi Nakamoto, “Bitcoin: A Peer-to-Peer Electronic
Cash System”, 2008
As if putting the first button in the wrong hole
P2P digital currency developed based on the belief
http://bitcoin.org/
Hostility against inflation
Traded as a commodity
Made a fuss late 2013 when 1 BTC > 1,100 USD
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.7/46
Market Price (USD)
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.8/46
User Software (Wallet)
Easy transfer using QR code
Screenshots from “Bit Osaifu” by Mr. HoshinoMore Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.9/46
What’s Bitcoin System?
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.10/46
Beaker Model (1)
21 million cm3 useless fluid
in a tank
Can use any number ofbeakers that can measuredown to 1
100,000,000cm
3
Every 10 minutes on average,a selected party can scoop25cm
3 (as of today) to theirbeaker
Selected by a speciallottery
Winning tickets are ineveryone’s box
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.11/46
Beaker Model (2)
Can move fluids amongbeakers with simple rules
The ‘selected party’ mustaudit the moves and addrecords in the ledger
Can have leftovers too
Sometimes, someone breakstheir beaker
Implemented above digitallyto call it a currency
→ Bitcoin
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.12/46
Technology Basics
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.13/46
Basics - Cryptographic Hash Functions
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.14/46
Basics - Digital Signature
Assures the authenticity of the originator and the content
ECDSA (Elliptic Curve DSA) is used in Bitcoin
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.15/46
Overview
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.16/46
Overview of Bitcoin System
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.17/46
Realizing Digital Coins (1)
A referred output (=coin) is spent, and cannot be double-spent
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.18/46
Realizing Digital Coins (2)
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.19/46
What A Wallet Does
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.20/46
Maintaining the Blockchain
1. Miners collect correct transactions and each make a datablock, and participate in a lottery
2. Who won the lottery broadcasts the block as the new tail
3. Other miners, if they approve, go back to 1 to append a newblock to the blockchain
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.21/46
Transaction Chain
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.22/46
Quantitative Limit
Rewards (besides fees) are halved at every 210 thousand blocks(about 4 years)
The limit is therefore 21 million BTC
Rewards (besides fees) will become none around year 2140,because the smallest unit is 1
100,000,000BTC
20,999,999.9769 BTC in total to be exact
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.23/46
Mining (Lottery)
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.24/46
Miners’ BehaviourEfficiency is pursued
Dedicated hardware rose
Mining costsIf the benefit is (expected to be) greater than thecost, more miners join and more invest on thehardwareIf the benefit is (feared to be) less than the cost,miners leave
Mining becomes collective, and mining becomes aservice
Easier for individuals to join and leave
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.25/46
Retargeting
A target is usually copied from the previous block
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.26/46
Proof Of Work
Nonce and the digest in a block prove a work has been done
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.27/46
State Machine of a Coin
Paler the arrows are, less probable they are actually taken
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.28/46
Overlapped State Machines
Major state transfers only
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.29/46
Technological DetailYes, those were just overview
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.30/46
Transaction Data Structure
Field Description Size (bytes)
Version Currently 1 4# of inputs Positive var-int 1∼9List of inputs Variable# of outputs Positive var-int 1∼9List of outputs VariableLock time 4
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.31/46
Output Data Structure
Field Description Size (bytes)
Amount Value in 10−8BTC 8
Script length Positive var-int 1∼9Script Variable
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.32/46
Input Data Structure
Field Description Size (bytes)
Referred TX Double SHA-256 value 32Referred output Index of the output 4Script length Positive var-int 1∼9Script VariableSequence # 4
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.33/46
Major Script Operators
Operator Code Description
OP_0 0 Push 0 byte
N/A 1∼0x4b Push # bytes
OP_PUSHDATA1 0x4c Push length specified by 1-byte suffix
OP_PUSHDATA2 0x4d Push length specified by 2-byte suffix
OP_PUSHDATA4 0x4e Push length specified by 4-byte suffix
OP_NOP 0x61 Do nothing
OP_VERIFY 0x69 TX invalid if not true
OP_DUP 0x76 Copy 1 item
OP_EQUAL 0x87 If 2 items match
OP_EQUALVERIFY 0x88 OP_EQUAL → OP_VERIFY
OP_HASH160 0xa9 Apply SHA-256→RIPEMD-160
OP_CHECKSIG 0xac If signature for TX verified
OP_CHECKMULTISIG 0xae If multiple signatures for TX verified
Script is a stack-oriented language with postfix notation
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.34/46
Script (General)
Output:
OP_DUP OP_HASH160
OP_PUSHDATA* <Public-key digest>
OP_EQUALVERIFY OP_CHECKSIG
Input:
OP_PUSHDATA* <Signature>
OP_PUSHDATA* <Public key>
TX output addressed to a public-key digest and referring
input
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.35/46
Script Processing
Concatinates scripts: input → output
Stack-based processing
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.36/46
Script (Generation)
Output:OP_PUSHDATA* <Public key> OP_CHECKSIG
Input:OP_PUSHDATA* <Signature>
Gen. TX otuput and referring input
No need to specify public key by its digest
Can avoid compromising security down to 160bit
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.37/46
Block Data Structure
Field Description Size (bytes)
Block header 6 items 80
# of TXs Positive var-int 1∼9
List of TXs Variable
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.38/46
Block Header Data Structure
Field Description Size (bytes)
Version 4
Digest Double SHA-256 value 32
Merkle root Double SHA-256 value 32
Time Seconds (since 1970-01-01T00:00 UTC) 4
Target Compressed format 4
Nonce Appropriate value 4
Merkle root is the digest of all TXs
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.39/46
Merkle Tree
Digest = double SHA-256 value
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.40/46
Networking
No structure
All TCP, default port number: 8333
IPv6 supported since v0.7 of referenceimplementation (v0.9.3 as of Dec. 2014)
Can use IPv4, IPv6 or Tor
In reference implementationMax # of outbound connections : 8
Max # of all connections : 125 (by default)
Only one outbound connection to an address groupHigh 16bit in IPv4High 32bit in IPv6
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.41/46
Major Messages
Category Name Function
Connection version Sends version and block #
verack Acknowledges version
addr (address) Sends list of IP address/port #
getaddr Requests addr
Data inv (inventory) Sends (new) blocks and/or txs
transfer getblocks Requests inv for all blocks within range
getdata Requests block/tx by the digest
block Sends block replying to getdata
tx (transaction) Sends tx replying to getdata
Header getheaders Requests headers for all blocks within range
transfer headers Sends block headers up to 2,000
Others alert Broadcasts alert
ping Confirms connection
pong Acknowledges ping
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.42/46
Message Structure
Field Description Size (bytes)
Magic number 0xd9b4bef9 4
Command Message name (ASCII string) 12
Payload length Size of payload in bytes 4
Checksum Double SHA-256 value of payload First 4
Payload Message data Variable
All integers are encoded in Little Endian except IP address
and port #
We’ve just seen the payloads for block and tx messages
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.43/46
DNS Seed
seed.bitcoin.sipa.be
dnsseed.bluematt.me
dnsseed.bitcoin.dashjr.org
seed.bitcoinstats.com
seed.bitnodes.io
bitseed.xf2.org
Maintained by volunteers
None of these uses DNSSEC
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.44/46
Transfer Protocol
block message is handled in the same mannerMore Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.45/46
Discussion
More Than You Need To Know About Bitcoin Technology — 2014-12-13 – p.46/46