SlideShare a Scribd company logo
BLOCKCHAIN
區塊鏈
CRYPTOGRAPHY
HASH
ENCRYPTION
DECENTRALIZATION
ITCOIN
1. Decentralized
2. Anonymous
3. Completely Transparent
4. Less Fees
5. Easy to use
• Block Structure
• Key, Address and Wallet
• Transaction
• Mining and Consensus
• Network
BLOCK
Chain of Blocks Inside a block
Merkle Tree
Chain of Blocks
Genesis
Block
prev #8FA
That is all you need!
Inside a block:
Merkle Tree
What’s a Merkle Tree?
Binary Hash Tree
Data
How to locate transaction
Assume P transactions in the Merkle tree,
We need O(logN) hashes to construct a path
to verify if a transaction exist here
authentication path :
HL , HIJ , HMNOP , HABCDEFGH
How to locate transaction
Assume P transactions in the Merkle tree,
We need O(logN) hashes to construct a path
to verify if a transaction exist here
authentication path :
HL , HIJ , HMNOP , HABCDEFGH
Block Header?
• Block Structure
• Key, Address and Wallet
• Transaction
• Mining and Consensus
• Network
KEY,ADDRESS
AND WALLET
Password
Account
e-Wallet
KEY
Private Key Public Key
≒ Address
PRIVATE KEY
• SINGLE SHA256
BlockChainForTheWIN
5KjTnMMnFKd2rWZKejXXkWWkd1LJwhnHrKpBxXujRvr8nTjZwp6
PUBLIC
KEY
ECDSA
• Curve : y2 mod p = x3+7 mod p
• G : base point
• p : prime number
ADDRESS
• HASH 160
• BASE58 ENCODING
04f29a7f486c90281f9396945e99ab35e
2ed732c008ada71e8e745da38dc63ac9
7b723fe731555dfba9dd60c0cc8fbc8f26
c35739f10c068125e6394839a47eb1e
7c4c8fc7afbf33660bef88460b8ef86bcc9d1134
1CLEWPDWRkTV2wEKZsDGPUWR1yXZwxsPQ
k
KEY
Private Key
Public Key
Address
ECDSA
HASH160 + Base58Check
KEY(PUBLIC)
• COMPRESSED • UNCOMPRESSED
(x, y)
k = 04xyk = 02x, if y is even
k = 03x, if y is odd
• 66 hex digits • 130 hex digits
04f29a7f486c90281f9396945e99ab35e2ed732c008a
da71e8e745da38dc63ac97b723fe731555dfba9dd60c
0cc8fbc8f26c35739f10c068125e6394839a47eb1e
02f29a7f486c90281f9396945e99ab35e2
ed732c008ada71e8e745da38dc63ac97
WALLET
WALLET
Non-deterministic Wallet : random generated
Deterministic Wallet(Seeded Wallet)
Mnemonic Code Word
1. Create a random sequence (entropy) of 128 to 256 bits
2. Create a checksum of the random sequence by taking the
first few bits of its SHA256 hash
3. Add the checksum to the end of the random sequence
4. Divide the sequence into sections of 11 bits, using those to
index a dictionary of 2048 pre-defined words
5. Produce 12-24 words representing the mnemonic code
Mnemonic Code Word
1. Create a random sequence (entropy) of 128 to 256 bits
2. Create a checksum of the random sequence by taking the
first few bits of its SHA256 hash
3. Add the checksum to the end of the random sequence
4. Divide the sequence into sections of 11 bits, using those to
index a dictionary of 2048 pre-defined words
5. Produce 12-24 words representing the mnemonic code
Hierarchical Deterministic Wallets
Each parent key can have 4 billion children keys
Hierarchical Deterministic Wallets
• tree structure can be used to express additional organizational
meaning
• users can create a sequence of public keys without having
access to the corresponding private keys
• insecure server or in a receive-only capacity
Hierarchical Deterministic Wallets
Hierarchical Deterministic Wallets
• parent private key and public key (256bit)
• seed called a chain code (256bit)
• index number (32bit)
Extended Keys : key + chain code
Hierarchical Deterministic Wallets
• Potential problems
Hierarchical Deterministic Wallets
• Solution : Hardened Child Key Derivation
• use parent private key to derive child chain code
• best practice, the level-1 children of the master keys are
always derived through the hardened derivation, to prevent
compromise of the master keys
Hierarchical Deterministic Wallets
• Index numbers for normal and hardened derivation
• Normal : 0 ~ 2^31 -1 , first one displayed as 0
• Hardened : 2^31 ~ 2^32 -1 , first one displayed as 0’
• HD wallet key identifier (path)
FORMAT
Key Format
• Private Key
• Wallet Import Format(WIF) : a way of encoding a private
key so as to make it easier to copy
• Public Key
Other Format
• Encrypted Private Key
• private key(usually in WIF) + passphrase
• => Base58Check encoded encrypted private key
with the prefix 6P
• need passphrase to decrypt
• Block Structure
• Key, Address and Wallet
• Transaction
• Mining and Consensus
• Network
TRANSACTION
TRANSACTION
Life Cycle
• Most important thing in Bitcoin network
• All designs in Bitcoin are created for transaction’s creation,
broadcast and verification
• Life cycle :
CREAT
ED
SIGNE
D
BROADCAS
TED
VERIFIED
AND
COLLECT
ED
Every node will
send validated
transaction to its
3~4 neighbors.
UTXO
• Unspent Transaction Output
• locked to specific owner
• no balance of a bitcoin address account; only scattered UTXO
• balance is the sum of UTXO of that address
Account-based ledger
Alice transfer $10 to me
Bob transfer $5 to me
transfer $13 to David
transfer $10 to Alice
Transaction-based ledger
Input from a1,$10, to me
Input from b1,$5, to me
Input from c1,c2,$13, to David
Input from c3,$5, to Alice
only need to verify output from specific transaction
UTXO
• Unspent Transaction Output
• locked to specific owner
• no balance of a bitcoin address account; only scattered UTXO
• balance is the sum of UTXO of that address
Account-based ledger
Alice transfer $10 to me
Bob transfer $5 to me
transfer $13 to David
transfer $10 to Alice
Transaction-based ledger
Input from a1,$10, to me
Input from b1,$5, to me
Input from c1,c2,$13, to David
Input from c3,$5, to Alice
only need to verify output from specific transaction
• efficient verification
• consolidating funds : merge my own
coins together to one address
• joint payments : combine payments
from multiple person
• change address : the change are
changed to another address
UTXO
• Unspent Transaction Output
• locked to specific owner
• no balance of a bitcoin address account; only scattered UTXO
• balance is the sum of UTXO of that address
Account-based ledger
Alice transfer $10 to me
Bob transfer $5 to me
transfer $13 to David
transfer $10 to Alice
Transaction-based ledger
Input from a1,$10, to me
Input from b1,$5, to me
Input from c1,c2,$13, to David
Input from c3,$5, to Alice
only need to verify output from specific transaction
• efficient verification
• consolidating funds : merge my own
coins together to one address
• joint payments : combine payments
from multiple person
• change address : the change are
changed to another address
Structure
• Metadata
• Locktime
• the earliest time that a transaction is valid and can be
relayed on the network or added to the blockchain
• = 0 : no locktime limit
• < 500 million : block height
• > 500 million : Unix Epoch timestamp
Structure
• Input : UTXO
Structure
• Output
Script
• Output
• How to unlock?
• concatenate input with output
• Input
Script
• Output
• How to unlock?
• concatenate input with output
• Input
• 5 standard transaction
• Pay-to-public-key-hash (P2PKH) Majority
• Public-key
• Multi-Signature
• Pay-to-Script-Hash(P2SH)
• Data Output(OP_RETURN)
Script
Script
Script
• Pay-to-public-key-hash (P2PKH)
• Majority
• Public-key
• Public key is store in the locking script
rather than Public key hash
• generated by older mining software that
has not been updated to use P2PKH
Script
• Multi-Signature
• Locking script
• M <Public Key 1> <Public Key 2> ... <Public
Key N> N OP_CHECKMULTISIG
• Unlocking script
• OP_0 <Signature B> <Signature C>
• Data Output(OP_RETURN)
• allows developers to add 40 bytes of non-payment
data to a transaction output
• un-spendable output
Script
• Pay-to-Script-Hash(P2SH)
• pay to a script matching this hash, a script which
will be presented later when this output is spent
• P2SH addresses are Base58Check encodings of
the 20 byte hash of a script
• use version prefix 5, which results in Base58Check
encoded addresses starting with 3
• the redeem script can be invalid , which will result
in un-spendable bitcoin
Script
• Pay-to-Script-Hash(P2SH)
• pay to a script matching this hash, a script which
will be presented later when this output is spent
• P2SH addresses are Base58Check encodings of
the 20 byte hash of a script
• use version prefix 5, which results in Base58Check
encoded addresses starting with 3
• the redeem script can be invalid , which will result
in un-spendable bitcoin
Script
• Pay-to-Script-Hash(P2SH)
• pay to a script matching this hash, a script which
will be presented later when this output is spent
• P2SH addresses are Base58Check encodings of
the 20 byte hash of a script
• use version prefix 5, which results in Base58Check
encoded addresses starting with 3
• the redeem script can be invalid , which will result
in un-spendable bitcoin
Script
• Pay-to-Script-Hash(P2SH)
• pay to a script matching this hash, a script which
will be presented later when this output is spent
• P2SH addresses are Base58Check encodings of
the 20 byte hash of a script
• use version prefix 5, which results in Base58Check
encoded addresses starting with 3
• the redeem script can be invalid , which will result
in un-spendable bitcoin
advantage:
nodes keep less record
Transaction Fee
• = sum of output - sum of input
• independent of the transaction’s bitcoin value,
but generally determined by size of a
transaction
• others are more willing to put a transaction into
a block if it’s fee is high
• is used to stop spam transactions and DDoS
• Block Structure
• Key, Address and Wallet
• Transaction
• Mining and Consensus
• Network
NING AND CONSENS
NING AND CONSENS
NING AND CONSENS
MINER
Task of Bitcoin Miners
• maintaining block chain and listen for new
blocks
• listen for transactions : listen and validate
• assemble a new block
• compute the answer(nonce) and broadcast the
block
Proof of Work
• spam email check
• difficult to produce but easy to verify
• a base string + nonce -> hash
• nonce : number used only once
• base string : Hello, world!
• target : hash begins with certain zeros
Proof of Work
• spam email check
• difficult to produce but easy to verify
• a base string + nonce -> hash
• nonce : number used only once
• base string : Hello, world!
• target : hash begins with certain zeros
Difficulty
• averagely 10 mins per block generation
• determine the difficulty
• adjust every 2 weeks
• next_difficulty = previous_difficulty * (2
weeks) / (time to mine last 2016 blocks)
Coinbase Transaction
• a null hash pointer
• a parameter contain arbitrary data , usually used
to signal support by miners for different new
features (vote)
• BIP , Bitcoin Improvement Proposal
• value contains block reward and all the
transaction fees of the block
Coinbase Transaction only transaction fees left
Broadcast
• previous block hash value + nonce
• put the nonce into block header
• broadcast to network
• easy verify by other miners
THREAT
Problem & Attack
• steal bitcoin?
• protected by digital signature
• steal private keys
• fork
• P2P network latency
• miner will go with the main(longest) chain
• lose if not on the main chain
• double-spend attack?
• a block is generated about every 10 minutes
• should wait at least 6 blocks(confirmation)
Problem & Attack
• Sybil attacks
• refuse to relay blocks and transactions,
disconnecting you from the network
• open to double-spending attacks
• 51% attack
• could change the main chain
Problem & Attack
• Sybil attacks
• refuse to relay blocks and transactions,
disconnecting you from the network
• open to double-spending attacks
• 51% attack
• could change the main chain
APPLICATION
Application of Bitcoin
• Escrow Application
• MULTISIG and a third party
• green address
• bank-controlled address
• bank guarantee it will not double-spend (real
world guarantee) , so recipient won’t have to
worry about confirmations of the transaction
which would take an hour
• trackable
Application of Bitcoin
• micro-payment
• bond : broadcast by recipient in the beginning
• refund : MULTISIG , requires both sender and
receiver to sign ; spend the money of bond ,
transfer them to both sender and recipient
• lock time : set the time t when recipient fail to
broadcast the payment by t , sender can get
the whole money back instead of money being
hold hostage by recipient
Application of Bitcoin B A BBond refund
100
Ecosystem - a cyclic nature
ValueSecurity
Mining
Digital Signature
Tamper-resistent
Market Price
Massive Users
Mining History
• CPU Mining
• while Loop
• too slow
• GPU Mining
• parallelism , overclocking
• floating point units, power consuming, cooling
Mining History
Source: LeonardH, cryptocurrenciestalk.com
Mining History
• FPGA Mining
• Field Programmable Gate Array, Verilog
• allowing the owner of the card to customize it
or reconfigure it
• better performance, cooling
• malfunction and errors, difficult to optimize the
32bit addition step, less accessible
Mining History
Mining History
• ASIC Mining
• Application Specific Integrated Circuits
• chips designed, built, and optimized for the
sole purpose of mining Bitcoins
• rapidly increasing network hash rate, shipping
speed is crucial
• short lifetime
Mining History
Mining History
• Today
• professional mining, not friendly to individual
Mining History
• Where to set up?
• climate: cool
• cost of electricity: cheap
• network position
• ideal place
• Republic of Georgia
• Iceland
Mining History
Mining Pool
• Miner
• only one mission: computing
• Pool Manager
• listen to transactions and verify
• build blocks
• update software
Mining Pool
• Rewards
• based on work done
share
Mining Pool
• Rewards
• based on work done
share
Mining Pool
• pay-per-share
• flat fee on every share, even no valid block
found
• manager absorb the risk
• took advantage by competitors
• proportional
Mining Pool
• started around 2010
• 51% mining pools
2014/62014/8
2015/42016/3
Mining Pool
• good for small miners, fast update
• centralization, few fully-validating nodes
• Block Structure
• Key, Address and Wallet
• Transaction
• Mining and Consensus
• Network
Bitcoin Network
• bitcoin P2P protocol
• extended bitcoin network
• bitcoin P2P protocol
• mining pool protocol
• Stratum protocol
Bitcoin Network
• Node Functions
Bitcoin Network
• Node Types
Bitcoin Network
• Node Types
SPV client
• Simplified Payment Verification nodes
• retrieve only block headers, 1000 times smaller
than full blockchain
• request for specific transaction from peers
• Sybil attack
• double spending attack
• privacy revealed
• Bloom Filter
Bloom Filter
• probabilistic search filter, a way to describe a
desired pattern without specifying it exactly
• a variable-size array of N binary digits
• a variable number of M hash functions, output
between 1 and N
• varying the level of accuracy and therefore
privacy by picking different N & M
Bloom Filter
• To add a pattern to the bloom filter, the pattern is
hashed by each hash function in turn
• corresponding bit of hash output is set to 1
Bloom Filter
collision
probabilistic :
more collision, less accuracy
Bloom Filter Maybe YES, Definitely NO
Bitcoin Network
• Block Structure
• Key, Address and Wallet
• Transaction
• Mining and Consensus
• Network

More Related Content

What's hot

Understanding blockchain
Understanding blockchainUnderstanding blockchain
Understanding blockchain
Priyab Satoshi
 
Blockchain overview, use cases, implementations and challenges
Blockchain overview, use cases, implementations and challengesBlockchain overview, use cases, implementations and challenges
Blockchain overview, use cases, implementations and challenges
Sébastien Tandel
 
Build your own block chain
Build your own block chainBuild your own block chain
Build your own block chain
Bohdan Szymanik
 
Bitcoin, Blockchain and the Crypto Contracts - Part 2
Bitcoin, Blockchain and the Crypto Contracts - Part 2Bitcoin, Blockchain and the Crypto Contracts - Part 2
Bitcoin, Blockchain and the Crypto Contracts - Part 2
Prithwis Mukerjee
 
Intro into blockchain
Intro into blockchainIntro into blockchain
Intro into blockchain
Roderik van der Veer
 
Blockchain
BlockchainBlockchain
Blockchain
Soichiro Takagi
 
Intro to Blockchain - And, by the way, what the heck is proof-of-work?
Intro to Blockchain - And, by the way, what the heck is proof-of-work?Intro to Blockchain - And, by the way, what the heck is proof-of-work?
Intro to Blockchain - And, by the way, what the heck is proof-of-work?
Jim Flynn
 
Blockchain and bitcoin fundamentals (usages and applications)
Blockchain and bitcoin fundamentals (usages and applications)Blockchain and bitcoin fundamentals (usages and applications)
Blockchain and bitcoin fundamentals (usages and applications)
Amir Rafati
 
Web3 Full Stack Development
Web3 Full Stack DevelopmentWeb3 Full Stack Development
Web3 Full Stack Development
Gene Leybzon
 
BitCoin Protocol
BitCoin ProtocolBitCoin Protocol
BitCoin Protocol
Consulthinkspa
 
Blockchains 101
Blockchains 101Blockchains 101
Blockchains 101
Nikhil Krishna Nair
 
gething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang clientgething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang client
Sathish VJ
 
Litecoin Crypto Currency Bootcamp
Litecoin Crypto Currency BootcampLitecoin Crypto Currency Bootcamp
Litecoin Crypto Currency Bootcamp
Joseph Holbrook, Chief Learning Officer (CLO)
 
Ethereum Blockchain with Smart contract and ERC20
Ethereum Blockchain with Smart contract and ERC20Ethereum Blockchain with Smart contract and ERC20
Ethereum Blockchain with Smart contract and ERC20
Truong Nguyen
 
Metadata in the Blockchain: The OP_RETURN Explosion
Metadata in the Blockchain: The OP_RETURN ExplosionMetadata in the Blockchain: The OP_RETURN Explosion
Metadata in the Blockchain: The OP_RETURN Explosion
Coin Sciences Ltd
 
The curious case of Blockchain Technology
The curious case of Blockchain TechnologyThe curious case of Blockchain Technology
The curious case of Blockchain Technology
Ritesh Mehrotra
 
Ethereum Blockchain explained
Ethereum Blockchain explainedEthereum Blockchain explained
Ethereum Blockchain explained
EthWorks
 
create your own cryptocurrency
create your own cryptocurrencycreate your own cryptocurrency
create your own cryptocurrency
Bellaj Badr
 
Ethereum Intro
Ethereum IntroEthereum Intro
Ethereum Intro
Dejan Radic
 

What's hot (20)

Understanding blockchain
Understanding blockchainUnderstanding blockchain
Understanding blockchain
 
Blockchain overview, use cases, implementations and challenges
Blockchain overview, use cases, implementations and challengesBlockchain overview, use cases, implementations and challenges
Blockchain overview, use cases, implementations and challenges
 
Build your own block chain
Build your own block chainBuild your own block chain
Build your own block chain
 
Bitcoin, Blockchain and the Crypto Contracts - Part 2
Bitcoin, Blockchain and the Crypto Contracts - Part 2Bitcoin, Blockchain and the Crypto Contracts - Part 2
Bitcoin, Blockchain and the Crypto Contracts - Part 2
 
Intro into blockchain
Intro into blockchainIntro into blockchain
Intro into blockchain
 
Blockchain
BlockchainBlockchain
Blockchain
 
Intro to Blockchain - And, by the way, what the heck is proof-of-work?
Intro to Blockchain - And, by the way, what the heck is proof-of-work?Intro to Blockchain - And, by the way, what the heck is proof-of-work?
Intro to Blockchain - And, by the way, what the heck is proof-of-work?
 
Blockchain and bitcoin fundamentals (usages and applications)
Blockchain and bitcoin fundamentals (usages and applications)Blockchain and bitcoin fundamentals (usages and applications)
Blockchain and bitcoin fundamentals (usages and applications)
 
bitcoin_presentation
bitcoin_presentationbitcoin_presentation
bitcoin_presentation
 
Web3 Full Stack Development
Web3 Full Stack DevelopmentWeb3 Full Stack Development
Web3 Full Stack Development
 
BitCoin Protocol
BitCoin ProtocolBitCoin Protocol
BitCoin Protocol
 
Blockchains 101
Blockchains 101Blockchains 101
Blockchains 101
 
gething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang clientgething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang client
 
Litecoin Crypto Currency Bootcamp
Litecoin Crypto Currency BootcampLitecoin Crypto Currency Bootcamp
Litecoin Crypto Currency Bootcamp
 
Ethereum Blockchain with Smart contract and ERC20
Ethereum Blockchain with Smart contract and ERC20Ethereum Blockchain with Smart contract and ERC20
Ethereum Blockchain with Smart contract and ERC20
 
Metadata in the Blockchain: The OP_RETURN Explosion
Metadata in the Blockchain: The OP_RETURN ExplosionMetadata in the Blockchain: The OP_RETURN Explosion
Metadata in the Blockchain: The OP_RETURN Explosion
 
The curious case of Blockchain Technology
The curious case of Blockchain TechnologyThe curious case of Blockchain Technology
The curious case of Blockchain Technology
 
Ethereum Blockchain explained
Ethereum Blockchain explainedEthereum Blockchain explained
Ethereum Blockchain explained
 
create your own cryptocurrency
create your own cryptocurrencycreate your own cryptocurrency
create your own cryptocurrency
 
Ethereum Intro
Ethereum IntroEthereum Intro
Ethereum Intro
 

Similar to 以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)

chapter4.pptxwgdyjshcbnbhvegwydvquhcjdvqigufwk
chapter4.pptxwgdyjshcbnbhvegwydvquhcjdvqigufwkchapter4.pptxwgdyjshcbnbhvegwydvquhcjdvqigufwk
chapter4.pptxwgdyjshcbnbhvegwydvquhcjdvqigufwk
NiveditaSingh839848
 
Blockchain Demystified
Blockchain DemystifiedBlockchain Demystified
Blockchain Demystified
Mahesh M Reddy
 
Introduction to blockchain and cryptocurrency technologies
Introduction to blockchain and cryptocurrency technologiesIntroduction to blockchain and cryptocurrency technologies
Introduction to blockchain and cryptocurrency technologies
Paweł Wacławczyk
 
J.burke HackMiami6
J.burke HackMiami6J.burke HackMiami6
J.burke HackMiami6
Jesse Burke
 
CBGTBT - Part 6 - Transactions 102
CBGTBT - Part 6 - Transactions 102CBGTBT - Part 6 - Transactions 102
CBGTBT - Part 6 - Transactions 102
Blockstrap.com
 
Bitcoin 101 - Certified Bitcoin Professional Training Session
Bitcoin 101 - Certified Bitcoin Professional Training SessionBitcoin 101 - Certified Bitcoin Professional Training Session
Bitcoin 101 - Certified Bitcoin Professional Training Session
Lisa Cheng
 
Cryptocurrencies for Everyone (Dmytro Pershyn Technology Stream)
Cryptocurrencies for Everyone (Dmytro Pershyn Technology Stream)Cryptocurrencies for Everyone (Dmytro Pershyn Technology Stream)
Cryptocurrencies for Everyone (Dmytro Pershyn Technology Stream)
IT Arena
 
Bitcoin Transactions Examples
Bitcoin Transactions ExamplesBitcoin Transactions Examples
Bitcoin Transactions Examples
Jeff Flowers
 
Bitcoin I.pptx
Bitcoin I.pptxBitcoin I.pptx
Bitcoin I.pptx
AseemBhube1
 
Idea To IPO Blockchain Slides
Idea To IPO Blockchain SlidesIdea To IPO Blockchain Slides
Idea To IPO Blockchain Slides
Roger Royse
 
Node.js Blockchain Implementation
Node.js Blockchain ImplementationNode.js Blockchain Implementation
Node.js Blockchain Implementation
GlobalLogic Ukraine
 
Bitcoin
BitcoinBitcoin
Bitcoin
mahdi ataeyan
 
Bitcoin Blockchain - Under the Hood
Bitcoin Blockchain - Under the HoodBitcoin Blockchain - Under the Hood
Bitcoin Blockchain - Under the Hood
Galin Dinkov
 
Bitcoin (Cryptocurrency)
Bitcoin (Cryptocurrency)Bitcoin (Cryptocurrency)
Bitcoin (Cryptocurrency)
Tsasaa Tsas
 
Bitcoin and the future of cryptocurrency
Bitcoin and the future of cryptocurrencyBitcoin and the future of cryptocurrency
Bitcoin and the future of cryptocurrency
Ben Hall
 
BlockChain Techonology - Unit 1.pptx
BlockChain Techonology   -   Unit 1.pptxBlockChain Techonology   -   Unit 1.pptx
BlockChain Techonology - Unit 1.pptx
os3558995
 
Chapter 2.pptx
Chapter 2.pptxChapter 2.pptx
Chapter 2.pptx
AvinashChoure2
 
Advanced Blockchain Technologies on Privacy & Scalability (All Things Open)
Advanced Blockchain Technologies on Privacy & Scalability (All Things Open) Advanced Blockchain Technologies on Privacy & Scalability (All Things Open)
Advanced Blockchain Technologies on Privacy & Scalability (All Things Open)
Kaleido
 
Blockchain - Presentacion Betabeers Galicia 10/12/2014
Blockchain - Presentacion Betabeers Galicia 10/12/2014Blockchain - Presentacion Betabeers Galicia 10/12/2014
Blockchain - Presentacion Betabeers Galicia 10/12/2014
WeKCo Coworking
 

Similar to 以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example) (20)

chapter4.pptxwgdyjshcbnbhvegwydvquhcjdvqigufwk
chapter4.pptxwgdyjshcbnbhvegwydvquhcjdvqigufwkchapter4.pptxwgdyjshcbnbhvegwydvquhcjdvqigufwk
chapter4.pptxwgdyjshcbnbhvegwydvquhcjdvqigufwk
 
Blockchain Demystified
Blockchain DemystifiedBlockchain Demystified
Blockchain Demystified
 
Introduction to blockchain and cryptocurrency technologies
Introduction to blockchain and cryptocurrency technologiesIntroduction to blockchain and cryptocurrency technologies
Introduction to blockchain and cryptocurrency technologies
 
J.burke HackMiami6
J.burke HackMiami6J.burke HackMiami6
J.burke HackMiami6
 
CBGTBT - Part 6 - Transactions 102
CBGTBT - Part 6 - Transactions 102CBGTBT - Part 6 - Transactions 102
CBGTBT - Part 6 - Transactions 102
 
Bitcoin 101 - Certified Bitcoin Professional Training Session
Bitcoin 101 - Certified Bitcoin Professional Training SessionBitcoin 101 - Certified Bitcoin Professional Training Session
Bitcoin 101 - Certified Bitcoin Professional Training Session
 
Cryptocurrencies for Everyone (Dmytro Pershyn Technology Stream)
Cryptocurrencies for Everyone (Dmytro Pershyn Technology Stream)Cryptocurrencies for Everyone (Dmytro Pershyn Technology Stream)
Cryptocurrencies for Everyone (Dmytro Pershyn Technology Stream)
 
Bitcoin Transactions Examples
Bitcoin Transactions ExamplesBitcoin Transactions Examples
Bitcoin Transactions Examples
 
Bitcoin I.pptx
Bitcoin I.pptxBitcoin I.pptx
Bitcoin I.pptx
 
Idea To IPO Blockchain Slides
Idea To IPO Blockchain SlidesIdea To IPO Blockchain Slides
Idea To IPO Blockchain Slides
 
Node.js Blockchain Implementation
Node.js Blockchain ImplementationNode.js Blockchain Implementation
Node.js Blockchain Implementation
 
Bitcoin
BitcoinBitcoin
Bitcoin
 
Bitcoin Blockchain - Under the Hood
Bitcoin Blockchain - Under the HoodBitcoin Blockchain - Under the Hood
Bitcoin Blockchain - Under the Hood
 
Bitcoin (Cryptocurrency)
Bitcoin (Cryptocurrency)Bitcoin (Cryptocurrency)
Bitcoin (Cryptocurrency)
 
Bitcoin and the future of cryptocurrency
Bitcoin and the future of cryptocurrencyBitcoin and the future of cryptocurrency
Bitcoin and the future of cryptocurrency
 
BlockChain Techonology - Unit 1.pptx
BlockChain Techonology   -   Unit 1.pptxBlockChain Techonology   -   Unit 1.pptx
BlockChain Techonology - Unit 1.pptx
 
Chapter 2.pptx
Chapter 2.pptxChapter 2.pptx
Chapter 2.pptx
 
Bitcoin
BitcoinBitcoin
Bitcoin
 
Advanced Blockchain Technologies on Privacy & Scalability (All Things Open)
Advanced Blockchain Technologies on Privacy & Scalability (All Things Open) Advanced Blockchain Technologies on Privacy & Scalability (All Things Open)
Advanced Blockchain Technologies on Privacy & Scalability (All Things Open)
 
Blockchain - Presentacion Betabeers Galicia 10/12/2014
Blockchain - Presentacion Betabeers Galicia 10/12/2014Blockchain - Presentacion Betabeers Galicia 10/12/2014
Blockchain - Presentacion Betabeers Galicia 10/12/2014
 

More from Nicholas Lin

區塊鏈智能合約應用於點數平台之架構
區塊鏈智能合約應用於點數平台之架構區塊鏈智能合約應用於點數平台之架構
區塊鏈智能合約應用於點數平台之架構
Nicholas Lin
 
部署並執行以太坊智能合約
部署並執行以太坊智能合約部署並執行以太坊智能合約
部署並執行以太坊智能合約
Nicholas Lin
 
以太坊智能合約撰寫簡單教學
以太坊智能合約撰寫簡單教學以太坊智能合約撰寫簡單教學
以太坊智能合約撰寫簡單教學
Nicholas Lin
 
智能合約結合區塊鏈簡介
智能合約結合區塊鏈簡介智能合約結合區塊鏈簡介
智能合約結合區塊鏈簡介
Nicholas Lin
 
Solidity Simple Tutorial EN
Solidity Simple Tutorial ENSolidity Simple Tutorial EN
Solidity Simple Tutorial EN
Nicholas Lin
 
CopyRightContractDemo
CopyRightContractDemoCopyRightContractDemo
CopyRightContractDemo
Nicholas Lin
 

More from Nicholas Lin (6)

區塊鏈智能合約應用於點數平台之架構
區塊鏈智能合約應用於點數平台之架構區塊鏈智能合約應用於點數平台之架構
區塊鏈智能合約應用於點數平台之架構
 
部署並執行以太坊智能合約
部署並執行以太坊智能合約部署並執行以太坊智能合約
部署並執行以太坊智能合約
 
以太坊智能合約撰寫簡單教學
以太坊智能合約撰寫簡單教學以太坊智能合約撰寫簡單教學
以太坊智能合約撰寫簡單教學
 
智能合約結合區塊鏈簡介
智能合約結合區塊鏈簡介智能合約結合區塊鏈簡介
智能合約結合區塊鏈簡介
 
Solidity Simple Tutorial EN
Solidity Simple Tutorial ENSolidity Simple Tutorial EN
Solidity Simple Tutorial EN
 
CopyRightContractDemo
CopyRightContractDemoCopyRightContractDemo
CopyRightContractDemo
 

Recently uploaded

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 

Recently uploaded (20)

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 

以比特幣為例的區塊鏈技術介紹 ( Intro to Blockchain using Bitcoin as an example)

  • 5. 1. Decentralized 2. Anonymous 3. Completely Transparent 4. Less Fees 5. Easy to use
  • 6. • Block Structure • Key, Address and Wallet • Transaction • Mining and Consensus • Network
  • 7. BLOCK Chain of Blocks Inside a block Merkle Tree
  • 8. Chain of Blocks Genesis Block prev #8FA That is all you need!
  • 9. Inside a block: Merkle Tree What’s a Merkle Tree? Binary Hash Tree Data
  • 10. How to locate transaction Assume P transactions in the Merkle tree, We need O(logN) hashes to construct a path to verify if a transaction exist here authentication path : HL , HIJ , HMNOP , HABCDEFGH
  • 11. How to locate transaction Assume P transactions in the Merkle tree, We need O(logN) hashes to construct a path to verify if a transaction exist here authentication path : HL , HIJ , HMNOP , HABCDEFGH
  • 13. • Block Structure • Key, Address and Wallet • Transaction • Mining and Consensus • Network
  • 15. KEY Private Key Public Key ≒ Address
  • 16. PRIVATE KEY • SINGLE SHA256 BlockChainForTheWIN 5KjTnMMnFKd2rWZKejXXkWWkd1LJwhnHrKpBxXujRvr8nTjZwp6
  • 17. PUBLIC KEY ECDSA • Curve : y2 mod p = x3+7 mod p • G : base point • p : prime number
  • 18. ADDRESS • HASH 160 • BASE58 ENCODING 04f29a7f486c90281f9396945e99ab35e 2ed732c008ada71e8e745da38dc63ac9 7b723fe731555dfba9dd60c0cc8fbc8f26 c35739f10c068125e6394839a47eb1e 7c4c8fc7afbf33660bef88460b8ef86bcc9d1134 1CLEWPDWRkTV2wEKZsDGPUWR1yXZwxsPQ k
  • 20. KEY(PUBLIC) • COMPRESSED • UNCOMPRESSED (x, y) k = 04xyk = 02x, if y is even k = 03x, if y is odd • 66 hex digits • 130 hex digits 04f29a7f486c90281f9396945e99ab35e2ed732c008a da71e8e745da38dc63ac97b723fe731555dfba9dd60c 0cc8fbc8f26c35739f10c068125e6394839a47eb1e 02f29a7f486c90281f9396945e99ab35e2 ed732c008ada71e8e745da38dc63ac97
  • 22. WALLET Non-deterministic Wallet : random generated Deterministic Wallet(Seeded Wallet)
  • 23. Mnemonic Code Word 1. Create a random sequence (entropy) of 128 to 256 bits 2. Create a checksum of the random sequence by taking the first few bits of its SHA256 hash 3. Add the checksum to the end of the random sequence 4. Divide the sequence into sections of 11 bits, using those to index a dictionary of 2048 pre-defined words 5. Produce 12-24 words representing the mnemonic code
  • 24. Mnemonic Code Word 1. Create a random sequence (entropy) of 128 to 256 bits 2. Create a checksum of the random sequence by taking the first few bits of its SHA256 hash 3. Add the checksum to the end of the random sequence 4. Divide the sequence into sections of 11 bits, using those to index a dictionary of 2048 pre-defined words 5. Produce 12-24 words representing the mnemonic code
  • 25. Hierarchical Deterministic Wallets Each parent key can have 4 billion children keys
  • 26. Hierarchical Deterministic Wallets • tree structure can be used to express additional organizational meaning • users can create a sequence of public keys without having access to the corresponding private keys • insecure server or in a receive-only capacity
  • 28. Hierarchical Deterministic Wallets • parent private key and public key (256bit) • seed called a chain code (256bit) • index number (32bit) Extended Keys : key + chain code
  • 30. Hierarchical Deterministic Wallets • Solution : Hardened Child Key Derivation • use parent private key to derive child chain code • best practice, the level-1 children of the master keys are always derived through the hardened derivation, to prevent compromise of the master keys
  • 31. Hierarchical Deterministic Wallets • Index numbers for normal and hardened derivation • Normal : 0 ~ 2^31 -1 , first one displayed as 0 • Hardened : 2^31 ~ 2^32 -1 , first one displayed as 0’ • HD wallet key identifier (path)
  • 33. Key Format • Private Key • Wallet Import Format(WIF) : a way of encoding a private key so as to make it easier to copy • Public Key
  • 34. Other Format • Encrypted Private Key • private key(usually in WIF) + passphrase • => Base58Check encoded encrypted private key with the prefix 6P • need passphrase to decrypt
  • 35. • Block Structure • Key, Address and Wallet • Transaction • Mining and Consensus • Network
  • 38. Life Cycle • Most important thing in Bitcoin network • All designs in Bitcoin are created for transaction’s creation, broadcast and verification • Life cycle : CREAT ED SIGNE D BROADCAS TED VERIFIED AND COLLECT ED Every node will send validated transaction to its 3~4 neighbors.
  • 39. UTXO • Unspent Transaction Output • locked to specific owner • no balance of a bitcoin address account; only scattered UTXO • balance is the sum of UTXO of that address Account-based ledger Alice transfer $10 to me Bob transfer $5 to me transfer $13 to David transfer $10 to Alice Transaction-based ledger Input from a1,$10, to me Input from b1,$5, to me Input from c1,c2,$13, to David Input from c3,$5, to Alice only need to verify output from specific transaction
  • 40. UTXO • Unspent Transaction Output • locked to specific owner • no balance of a bitcoin address account; only scattered UTXO • balance is the sum of UTXO of that address Account-based ledger Alice transfer $10 to me Bob transfer $5 to me transfer $13 to David transfer $10 to Alice Transaction-based ledger Input from a1,$10, to me Input from b1,$5, to me Input from c1,c2,$13, to David Input from c3,$5, to Alice only need to verify output from specific transaction • efficient verification • consolidating funds : merge my own coins together to one address • joint payments : combine payments from multiple person • change address : the change are changed to another address
  • 41. UTXO • Unspent Transaction Output • locked to specific owner • no balance of a bitcoin address account; only scattered UTXO • balance is the sum of UTXO of that address Account-based ledger Alice transfer $10 to me Bob transfer $5 to me transfer $13 to David transfer $10 to Alice Transaction-based ledger Input from a1,$10, to me Input from b1,$5, to me Input from c1,c2,$13, to David Input from c3,$5, to Alice only need to verify output from specific transaction • efficient verification • consolidating funds : merge my own coins together to one address • joint payments : combine payments from multiple person • change address : the change are changed to another address
  • 42. Structure • Metadata • Locktime • the earliest time that a transaction is valid and can be relayed on the network or added to the blockchain • = 0 : no locktime limit • < 500 million : block height • > 500 million : Unix Epoch timestamp
  • 45. Script • Output • How to unlock? • concatenate input with output • Input
  • 46. Script • Output • How to unlock? • concatenate input with output • Input • 5 standard transaction • Pay-to-public-key-hash (P2PKH) Majority • Public-key • Multi-Signature • Pay-to-Script-Hash(P2SH) • Data Output(OP_RETURN)
  • 49. Script • Pay-to-public-key-hash (P2PKH) • Majority • Public-key • Public key is store in the locking script rather than Public key hash • generated by older mining software that has not been updated to use P2PKH
  • 50. Script • Multi-Signature • Locking script • M <Public Key 1> <Public Key 2> ... <Public Key N> N OP_CHECKMULTISIG • Unlocking script • OP_0 <Signature B> <Signature C> • Data Output(OP_RETURN) • allows developers to add 40 bytes of non-payment data to a transaction output • un-spendable output
  • 51. Script • Pay-to-Script-Hash(P2SH) • pay to a script matching this hash, a script which will be presented later when this output is spent • P2SH addresses are Base58Check encodings of the 20 byte hash of a script • use version prefix 5, which results in Base58Check encoded addresses starting with 3 • the redeem script can be invalid , which will result in un-spendable bitcoin
  • 52. Script • Pay-to-Script-Hash(P2SH) • pay to a script matching this hash, a script which will be presented later when this output is spent • P2SH addresses are Base58Check encodings of the 20 byte hash of a script • use version prefix 5, which results in Base58Check encoded addresses starting with 3 • the redeem script can be invalid , which will result in un-spendable bitcoin
  • 53. Script • Pay-to-Script-Hash(P2SH) • pay to a script matching this hash, a script which will be presented later when this output is spent • P2SH addresses are Base58Check encodings of the 20 byte hash of a script • use version prefix 5, which results in Base58Check encoded addresses starting with 3 • the redeem script can be invalid , which will result in un-spendable bitcoin
  • 54. Script • Pay-to-Script-Hash(P2SH) • pay to a script matching this hash, a script which will be presented later when this output is spent • P2SH addresses are Base58Check encodings of the 20 byte hash of a script • use version prefix 5, which results in Base58Check encoded addresses starting with 3 • the redeem script can be invalid , which will result in un-spendable bitcoin advantage: nodes keep less record
  • 55. Transaction Fee • = sum of output - sum of input • independent of the transaction’s bitcoin value, but generally determined by size of a transaction • others are more willing to put a transaction into a block if it’s fee is high • is used to stop spam transactions and DDoS
  • 56. • Block Structure • Key, Address and Wallet • Transaction • Mining and Consensus • Network
  • 60. MINER
  • 61. Task of Bitcoin Miners • maintaining block chain and listen for new blocks • listen for transactions : listen and validate • assemble a new block • compute the answer(nonce) and broadcast the block
  • 62. Proof of Work • spam email check • difficult to produce but easy to verify • a base string + nonce -> hash • nonce : number used only once • base string : Hello, world! • target : hash begins with certain zeros
  • 63. Proof of Work • spam email check • difficult to produce but easy to verify • a base string + nonce -> hash • nonce : number used only once • base string : Hello, world! • target : hash begins with certain zeros
  • 64. Difficulty • averagely 10 mins per block generation • determine the difficulty • adjust every 2 weeks • next_difficulty = previous_difficulty * (2 weeks) / (time to mine last 2016 blocks)
  • 65. Coinbase Transaction • a null hash pointer • a parameter contain arbitrary data , usually used to signal support by miners for different new features (vote) • BIP , Bitcoin Improvement Proposal • value contains block reward and all the transaction fees of the block
  • 66. Coinbase Transaction only transaction fees left
  • 67. Broadcast • previous block hash value + nonce • put the nonce into block header • broadcast to network • easy verify by other miners
  • 69. Problem & Attack • steal bitcoin? • protected by digital signature • steal private keys • fork • P2P network latency • miner will go with the main(longest) chain • lose if not on the main chain • double-spend attack? • a block is generated about every 10 minutes • should wait at least 6 blocks(confirmation)
  • 70. Problem & Attack • Sybil attacks • refuse to relay blocks and transactions, disconnecting you from the network • open to double-spending attacks • 51% attack • could change the main chain
  • 71. Problem & Attack • Sybil attacks • refuse to relay blocks and transactions, disconnecting you from the network • open to double-spending attacks • 51% attack • could change the main chain
  • 73. Application of Bitcoin • Escrow Application • MULTISIG and a third party • green address • bank-controlled address • bank guarantee it will not double-spend (real world guarantee) , so recipient won’t have to worry about confirmations of the transaction which would take an hour • trackable
  • 74. Application of Bitcoin • micro-payment • bond : broadcast by recipient in the beginning • refund : MULTISIG , requires both sender and receiver to sign ; spend the money of bond , transfer them to both sender and recipient • lock time : set the time t when recipient fail to broadcast the payment by t , sender can get the whole money back instead of money being hold hostage by recipient
  • 75. Application of Bitcoin B A BBond refund 100
  • 76. Ecosystem - a cyclic nature ValueSecurity Mining Digital Signature Tamper-resistent Market Price Massive Users
  • 77. Mining History • CPU Mining • while Loop • too slow • GPU Mining • parallelism , overclocking • floating point units, power consuming, cooling
  • 78. Mining History Source: LeonardH, cryptocurrenciestalk.com
  • 79. Mining History • FPGA Mining • Field Programmable Gate Array, Verilog • allowing the owner of the card to customize it or reconfigure it • better performance, cooling • malfunction and errors, difficult to optimize the 32bit addition step, less accessible
  • 81. Mining History • ASIC Mining • Application Specific Integrated Circuits • chips designed, built, and optimized for the sole purpose of mining Bitcoins • rapidly increasing network hash rate, shipping speed is crucial • short lifetime
  • 83. Mining History • Today • professional mining, not friendly to individual
  • 84. Mining History • Where to set up? • climate: cool • cost of electricity: cheap • network position • ideal place • Republic of Georgia • Iceland
  • 86. Mining Pool • Miner • only one mission: computing • Pool Manager • listen to transactions and verify • build blocks • update software
  • 87. Mining Pool • Rewards • based on work done share
  • 88. Mining Pool • Rewards • based on work done share
  • 89. Mining Pool • pay-per-share • flat fee on every share, even no valid block found • manager absorb the risk • took advantage by competitors • proportional
  • 90. Mining Pool • started around 2010 • 51% mining pools 2014/62014/8 2015/42016/3
  • 91. Mining Pool • good for small miners, fast update • centralization, few fully-validating nodes
  • 92. • Block Structure • Key, Address and Wallet • Transaction • Mining and Consensus • Network
  • 93. Bitcoin Network • bitcoin P2P protocol • extended bitcoin network • bitcoin P2P protocol • mining pool protocol • Stratum protocol
  • 97. SPV client • Simplified Payment Verification nodes • retrieve only block headers, 1000 times smaller than full blockchain • request for specific transaction from peers • Sybil attack • double spending attack • privacy revealed • Bloom Filter
  • 98. Bloom Filter • probabilistic search filter, a way to describe a desired pattern without specifying it exactly • a variable-size array of N binary digits • a variable number of M hash functions, output between 1 and N • varying the level of accuracy and therefore privacy by picking different N & M
  • 99. Bloom Filter • To add a pattern to the bloom filter, the pattern is hashed by each hash function in turn • corresponding bit of hash output is set to 1
  • 100. Bloom Filter collision probabilistic : more collision, less accuracy
  • 101. Bloom Filter Maybe YES, Definitely NO
  • 103. • Block Structure • Key, Address and Wallet • Transaction • Mining and Consensus • Network