Bitcoin - Cryptocurrency
Bitcoin - Cryptocurrency
Bitcoin - Cryptocurrency
Dr John T. H.Yuen
CYC 306, thyuen@cs.hku.hk 1
2
3
OVERVIEW
Bitcoin Fundamentals.
Technology to build Bitcoin.
Blockchain and
Cryptocurrency Cryptoeconomy.
The ecosystem developed from Bitcoin
5
2008 GLOBAL FINANCIAL CRISIS
After the bursting of dot-com bubble in 2001, the global financial
crisis in 2008 is the worst financial crisis
The subprime mortgage crisis in the US caused the collapse of
the investment bank Lehman Brothers on September 15, 2008
Quantitative easing (QE) undertaken has mitigated some of the
economic problems since the crisis
6
WHAT IS BITCOIN?
Bitcoin is the first decentralized digital currency (cryptocurrency)
The system is peer-to-peer, and transactions take place between users directly, without an intermediary
Transactions are verified by network nodes and recorded in a public distributed ledger called a
blockchain
Total 21 million bitcoins to be mined until 2140
monetary policy based on artificial scarcity
response of BTC
Source: https://coinmarketcap.com/currencies/bitcoin/
BITCOIN: WHY IS IT IMPORTANT? (LAYMAN)
for the first time, a way for one Internet user to transfer a unique
piece of digital property to another Internet user, such that the transfer is guaranteed to
be safe and secure, everyone knows that the transfer has taken place, and nobody can
New York Times, January 2014.
9
BITCOIN: WHY IS IT IMPORTANT? (CYPHERPUNK)
Cypherpunk
A libertarian fight for privacy and self-governance using cryptography
Rooted from anonymous e-cash paper and pseudonymous reputation
systems paper "Security without Identification: Transaction Systems to Make Big
is necessary for an open society in the electronic age When I purchase a magazine at a
store and hand cash to the clerk, there is no need to know who I am Therefore, privacy in an open
society requires anonymous transaction systems. Until now, cash has been the primary such system.
An anonymous transaction system is not a secret transaction system. An anonymous system 10
empowers individuals to reveal their identity when desired and only when desired; this is the essence
of privacy. Cypherpunk manifesto (1993).
EARLY ATTEMPTS OF CRYPTOCURRENCY
B-Money (1998) by Dai Wai: deposit money in order to maintain the transaction data
(similar to the Proof of Stake)
11
BITCOIN FUNDAMENTALS
TECHNOLOGY TO BUILD BITCOIN
12
CURRENCY SYSTEM
Ledger
Bank
Problem:
Non-transferable
BITCOIN OVERVIEW: GLOBAL LEDGER
Current Bank Account Bitcoin
Satoshi Bitcoin based on blockchain (2008)
Bank
Global Ledger
2/7 Bob Alice $10
3/7 Carol Alice $50
4/7 Dennis Bob $20
6/7 Alice Carol $20
copy
16
Preimage resistance 17
Collision resistant
Demo: https://andersbrownworth.com/blockchain/hash
SHA-256
BLOCKCHAIN DATA STRUCTURE (1)
Block n-1 Block n Block n+1
Previous Hash Previous Hash Previous Hash
TX Data:
Transaction 1: Alice Bob
TX Data TX Data
Transaction 2: Carol David
Security guarantee 1:
integrity
18
Merkle
Demo: https://andersbrownworth.com/blockchain/tokens
CURRENCY SYSTEM
Demo: https://andersbrownworth.com/blockchain/public-private-keys/keys
QUESTIONS ON BITCOIN ADDRESS?
21
BITCOIN ADDRESS
22
CURRENCY SYSTEM
Validate your signature and account balance Validate transaction using digital
when you transfer/withdraw money Service signature and UTXO model
23
Digital signature
A valid digital signature gives a recipient reason to believe
that the message was created by a known sender
(authentication), that the sender cannot deny having sent
the message (non-repudiation), and that the message was
not altered in transit (integrity). 24
Demo: https://andersbrownworth.com/blockchain/public-private-keys/signatures
BLOCKCHAIN DATA STRUCTURE (2)
Block n-1 Block n Block n+1
Previous Hash Previous Hash Previous Hash
TX Data:
Transaction 1: Alice Bob
TX Data TX Data
Transaction 2: Carol David
Security guarantee 2:
blockchain) integrity
non-repudiation
Demo: https://andersbrownworth.com/blockchain/public-private-keys/transaction
ACCOUNT BALANCE MODEL VS. UTXO MODEL
26
UTXO MODEL
2 BTC
from Tx#12
5 BTC 7 BTC 3 BTC 12 BTC
from Tx#12 from Tx#17 from Tx#15 from Tx#16
Each person has his/her own secret key for the Bitcoin
27
UTXO MODEL
1 BTC
from Tx#20
2 BTC
from Tx#12
5 BTC 7 BTC 3 BTC 4 BTC 12 BTC
from Tx#12 from Tx#17 from Tx#15 from Tx#20 from Tx#16
1 BTC
from Tx#20
2 BTC
from Tx#12 7 BTC
from Tx#23
7 BTC 3 BTC 4 BTC 12 BTC
from Tx#17 from Tx#15 from Tx#20 from Tx#16
29
CHECKING FOR DOUBLE SPENDING
1 BTC
from Tx#20
2 BTC
from Tx#12 7 BTC
from Tx#23
5 BTC 7 BTC 3 BTC 4 BTC 12 BTC
from Tx#12 from Tx#17 from Tx#15 from Tx#20 from Tx#16
31
CURRENCY SYSTEM
Validate your signature and account balance Validate transaction using digital
when you transfer/withdraw money Service signature and UTXO model
32
Transfer $20
to John
Withdraw $10M
33
BITCOIN CONSENSUS
block of transactions)
Everyone should be able to check if the winner misbehaves (and how to handle it if it happens)
Everyone maintains the same copy of ledger (in the long run) no matter what happens Consensus
34
Puzzle to solve: Proof of Work:
Previous Hash In order to propose a new block, must
? include Proof-of-Work or the solution to
hash < 0000..0000xxxxxxxxxxxxx a hash puzzle:
TX Data
Number of zeros 75 now find a random number to put in the block,
such that the hash of the new block starts
with many zeros
Try to mine
Hash puzzle can only be solved using
one by one
brute-force computation, which spends
Hash(Prev hash || 0000 || Tx Fail resources
Hash(Prev hash || 0001 || Tx Fail
Hash(Prev hash || 0010 || Tx Fail
Hash(Prev hash || 0011 || Tx Fail hash function
TX Data:
Transaction 1: Alice Bob Tx fee
Transaction 2: Carol David TX Data TX Data
reward
miners
Block n+1
Previous Hash
Answer to puzzle
Block n TX Data:
Alice Bob $10
Previous Hash
Carol David $3
Answer to puzzle
immediately
TX Data:
Carol David $3 38
Eve Fred $1
FORKING
Eventually, one chain will be longer than the other
Block n+1 Block n+2
Previous Hash Previous Hash No one will follow the shorter chain and this branch
Answer to puzzle Answer to puzzle is dead
Block n
All transactions there are not completed
Previous Hash TX Data TX Data
Answer to puzzle No mining reward earned
TX Data
Previous Hash Previous Hash Previous Hash Previous Hash Previous Hash
Answer to puzzle Answer to puzzle Answer to puzzle Answer to puzzle Answer to puzzle
Since it takes 10 minutes to mine a block in Bitcoin, a transaction is complete after 1hour.
SECURITY BASED ON HONEST MAJORITY
40
COMBINING EVERYTHING
Demo:
https://andersbrownworth.com/blockchain/public-private-keys/blockchain
41
QUESTIONS
What if
Can I fork on a very old block and create a sub-chain from there?
What happens after the 21 million Bitcoin are mined after 2140?
If it takes 1 hour to complete a transaction, how can I buy something (e.g.,
coffee) from a shop using Bitcoin?
42
CRYPTOECONOMY
THE ECOSYSTEM DEVELOPED FROM BITCOIN
43
Bitcoin provides an open platform (without trusted third party) for monetary
transaction, participated by the following parties:
User
buy Fiat Money
User
Other cryptocurrencies
User
Miners
Exchange
regulate
Developer
Government
Nakamoto
2008, whose real identity is unknown Bitcoin system cannot be
Maintained by development regulated or be shut down 44
community Miners Regulate exchange
Miner
BITCOIN USERS
Blockchain
Important concepts:
Not every client is a miner
2. Address
BITCOIN WALLET 3. VTXO
$
Write on
paper or store in USB (Disconnected to internet a safer) less countenance
BUYING BITCOIN
There are some Bitcoin exchanges with local Hong Kong bank
accounts. can
buy bitcoin directly there
E.g., Tidebit, Liquid, Bitstamp, Gemini, Maicoin
HK proposed to restrict crypto exchanges to professional investors
(>$8M) in 2021-2022 any professional can buy the exchange l $8M)
in >
Brokerages, also called OTC (Over the counter), are places where
you can buy Bitcoin for cash or a wire transfer for a fixed rate,
similar to the forex shops foreign estrange shops lhiqher transaction feel
-
Once you get some Bitcoin, there are many website that allows
you to trade Bitcoin with cryptocurrencies. 47
Source: https://99bitcoins.com/who-accepts-bitcoins-payment-companies-stores-take-bitcoins/
MERCHANT ACCEPTANCE
AT&T becomes first big mobile carrier to accept Bitcoin payments in May 2019
cryptocurrency for payments for tax and various services in 2019.
Amazon: Cryptocurrency for payments through
49
MINING INDUSTRY
Voluntarily set by the sender, but if you set a higher transaction fee, it will be handled by miners
more quickly # For normal the software will deduce transaction fee
users
,
automatically .
wallet .
50
MINING INDUSTRY
Fixed_cost: Variable_cost: Energy consumed in mining
Electricity, to power your hardware
Cooling, to maintain your hardware
From 2010 ,
Gpus
miner
buys .
(to lower
E.g. Iceland; Dalian, China electricity
GPUs not enough ,
# China banned
mining .
ASICs dedicated
in
calculating
Hash functions
ASIC: 14 trillion hash per second now! 51
ALTCOINS
FROM BITCOIN TO OTHER CRYPTOCURRENCIES earhhasits advantages ↳ woatypesof cryptocurrencies )
-
52
(platform using smart contract)
53
ALTCOINS Alternative coins ( eaeh has its setting point)
Usually, each altcoins has their own selling point, by improving a bit from Bitcoin
One popular direction is to replace Proof-of-Work for the consensus: ( reduce electricity consumption )
Use memory-hard puzzle: it requires large amount of memory instead of computational power deter ASICS. Used in
Litecoin, Dogecoin
Developing
Two main steps:
toprevent
waste
1. Fill buffer w/ interdependent data
of energy em .
?? * address of parties
# amount
oftransfer
Sender Confidential Recipient
anonymity transaction anonymity except the
sender &
recipient
rate
IEUSD
most- µ
more suitable
more
popular tomy
than BTC
Maltings
57
SHORTCOMING, SCANDALS & HACKS
THE PROBLEM OF BITCOIN
58
BITCOIN STRUGGLES TO SCALE
Technical consideration:
Bitcoin blocks are created every 10 minutes and can only hold 1 MB of transactions
2015: blocks begin to run out of space, transactions go unconfirmed
Block size debate raises questions about decentralized governance
59
In February 2022, the Russian government announced it would
support, legalize, and regulate cryptocurrencies
US:
U.S. Treasury classified bitcoin as a convertible
decentralized virtual currency in 2013.
China:
Commodity Futures Trading Commission classified bitcoin
as a commodity in 2015. Cryptocurrency exchanges or trading platforms were
effectively banned by regulation in September 2017
For Internal Revenue Service, bitcoin is taxed as a property. with 173 platforms closed down by July 2018 60
Bitcoin was mentioned in a U.S. Supreme Court opinion A complete ban on cryptocurrency trading and
regarding the changing definition of money in 2018. mining was put into effect on 24 September 2021.
LEGAL STATUS OF CRYPTOCURRENCY
1. -to- Nakamoto.
2. https://medium.com/@VitalikButerin
3. Why Bitcoin Matters. New York Times. https://dealbook.nytimes.com/2014/01/21/why-bitcoin-matters/
4. The trust machine. Economist. https://www.economist.com/leaders/2015/10/31/the-trust-machine
5. PwC 6th ICO / STO Report, Spring 2020.
https://www.pwc.ch/en/publications/2020/Strategy&_ICO_STO_Study_Version_Spring_2020.pdf
65