Slide Chuỗi Khối
Slide Chuỗi Khối
aaaaaaaaaaaaaaaaaaaaaaaaaaa
1 Pre-requisites
2 Course outline
3 Key topics
4 Course materials
5 Grading (plan)
6 Instructor’s contact
7 Academic policy
8 How to study?
1 Pre-courses:
1 Programming fundamentals: skills related to structured programming
2 OOP: skills related to object-oriented programming
3 Data structures and algorithms: skills related to the implementation
and usage of basic data structures and algorithms (e.g., Lists, Trees,
Hash tables, sorting and searching, etc.)
4 Basic knowledge about cryptography is a plus
2 English:
not require an English certificate, but
good enough to read course materials.
Course website:
http://lms.buh.edu.vn
Tools:
Java Programming Environment
Duc Vinh VO (BUH) Lecture 0 - Course Introduction November 25, 2022 6 / 12
Grading (plan)
Maximum score: 10
Assessments:
Class attendance (C) (10%)
Progress tests/Group work (P) (20%)
Midterm tests (M) (20%)
Final exam (FE) (50%)
Total score = 0.1*C + 0.2*P + 0.2*M + 0.5*FE
Before classes:
Reading textbooks and related documents.
Read lecture slides.
Attend lectures
Listen, understand, then make your own notes
Give your explanation about some topics in lectures
Ask questions
Give some examples that are not existed in your books
Practice all the exercises to make your sense
After classes
Discuss your classmates directly or on forum
Analyze, design and implement workshops and assignments
Build your teams to support together in studying
Complete chapter assessments in time (programs and/or reports).
Plagiarism
Plagiarism is using the work of others without citing it; that is, holding
the work of others out as your own work.
Breach of copyright
If you photocopy a textbook without the copyright holder’s permission,
you violate copyright law.
Our job is to help you learn and enjoy the experience. We will do our
best but we need your engagement too.
B B B B B
B B
Q&A B B
B B B B B
B B B B B
BLOCKCHAIN
2
ĐẠI HỌC NGÂN HÀNG THÀNH PHỐ HỒ CHÍ MINH
Chapter 1
INTRODUCTION TO
CRYPTOGRAPHIC DIGITAL MONEY,
LEDGER, BITCOIN
2. Application
• Understand blockchain applications
• Learn to apply blockchain to areas of interest
• Think about new applications of blockchain
4
WHAT YOU WISH TO LEARN?
3. Impact
• Understand blockchain impacts on internet, business, and finance
• Implications in people’s lives
4. Regulation
• How will regulation and public policy change and need to change
• Learning about regulations
5. Market & Money
• Make money
• Investment
• Trends and top influencers in the market
5
SURVEY
6
Study Questions
7
NON-METAL MONEY
10
PAPER MONEY
Australia USA
Canada England 12
What is money?
13
What is the role of money?
Personal Ledger
Proto Cuneiform George Washington
Uruk, ca 3000 B.C 1747
§ Immutable, Consistency
§ Timestamped
§ Ownership
§ Accuracy
§ Description of Transaction
§ Comprehensive
17
What is a payment system?
18
EARLY CRYPTOGRAPHIC DIGITAL CURRENCIES
§ Merchant adoption
§ Centralization
§ Double spending
§ Consensus
20
DIGITAL & MOBILE PAYMENTS
§ P2P transactions
§ Without trusted central intermediary
Bitcoin: A Peer-to-Peer Electronic Cash System (2008)
Satoshi Nakamoto: “I've been working on a new electronic cash
system that's fully peer-to-peer, with no trusted third party”
22
DISTRIBUTED DATABASES vs DISTRIBUTED
LEDGER
Centralized relational databases:
§ (Multiple) clients talk to central server
§ Server manages competing requests, assigns priority, prevents conflicts
§ Examples: web server
Distributed databases:
§ Distribute storage of information across multiple locations
§ Distributed consensus algorithm is used to ensure consistency
§ Examples: 2PC, 3PC, Paxos
24
BITCOIN
25
DATA STORING
26
BLOCKCHAIN - A NEW LAYER?
Blockchain 2009
SSL/TLS 1996
HTTP 1990
TCP/IP 1974
Ethernet 1974
27
BLOCKCHAIN – WEB 3.0?
28
DISCUSSION
29
ĐẠI HỌC NGÂN HÀNG THÀNH PHỐ HỒ CHÍ MINH
Chapter 2
CRYPTOGRAPHY
AND
CRYPTOCURRENCY
§ Public blockchains:
§ open, decentralized networks of computers accessible to anyone who want
to request or validate a transaction (check for accuracy)
§ Those (miners) who validate transactions receive rewards.
§ Proof-of-work or proof-of-stake consensus mechanisms are used.
§ Examples: the Bitcoin and Ethereum (ETH) blockchains.
6
Blockchain - Types
§ Private blockchains:
§ NOT open, they have access restrictions
§ Require a permission from the system administrator to join
§ They are typically governed by one entity, meaning they’re centralized
§ Example: Hyperledger is a private, permissioned blockchain
7
Blockchain - Types
§ Hybrid blockchains (consortiums):
§ a combination of public and private blockchains
§ contain centralized and decentralized features.
§ Example: Dragonchain, Energy Web Foundation, and R3.
8
Blockchain - Types
§ Sidechains:
§ a blockchain running parallel to the main chain.
§ allows users to move digital assets between two different blockchains
§ improves scalability and efficiency.
§ Example: the Liquid Network.
9
Blockchain - How it works
Image by http://www.blockgeeks.com 10
Benefits of Blockchain Over Traditional Finance
§ Trustless
§ Unstoppable
§ Immutable
§ Decentralized
§ Lower Cost
§ Peer-to-Peer
§ Transparent
§ Universal Banking
11
Disadvantages of Blockchain
§ Environmental Impact
§ Personal Responsibility
§ Growing Pains
§ False Narratives
12
Applications of Blockchain
§ Cryptocurrencies: Bitcoin, Ethereum, etc.
§ Smart Contracts
§ Decentralized Banking
§ Video Games/Art
§ Peer-to-peer Energy Trading
§ Supply chain and logistics tracking
§ Healthcare process optimization
13
Applications of Blockchain
§ Real estate processing platform
§ NFT marketplaces: These are marketplaces that allow you to buy nonfungible
tokens (NFTs) è “FTX sập rồi”
§ Music royalties tracking
§ Personal identity security
§ Automated Advertising Campaigns
14
BITCOIN DESIGN FEATURES
Cryptography & Timestamped Logs
§ Cryptographic Hash Func1ons
§ Timestamped Append-only Logs (Blocks)
§ Block Headers & Merkle Trees
§ Asymmetric Cryptography & Digital Signatures
§ Addresses
Decentralized Network Consensus
§ Consensus through Proof of Work
§ Network of Nodes
§ Na1ve Currency
Transac>on Script & UTXO
§ Transac1on Inputs & Outputs
§ Unspent Transac1on Output (UTXO)
§ Scrip1ng language 15
CRYPTOGRAPHIC HASH FUNCTIONS
Hash = Digital Fingerprints for Data
General Properties
§ Maps Input x of any size to an Output of fixed size – called a ‘Hash’
§ Deterministic: Always the same Hash for the same x
§ Efficiently computed
Cryptographic Properties
§ Preimage resistant (One way): infeasible to determine x from Hash(x)
§ Collision resistant: infeasible to find and x and y where Hash(x) = Hash(y)
§ Avalanche effect: Change x slightly and Hash(x) changes significantly
§ Puzzle friendliness: knowing Hash(x) and part of x it is still very hard to find
rest of x 1
16
CRYPTOGRAPHIC HASH FUNCTIONS
Hash = Digital Fingerprints for Data
Use cases
§ Hash password before storing in database
§ Verify data integrity when receiving
§ Using as reference
§ Using in digital signature
18
TIME-STAMP DIGITAL DOCUMENT
WHY TIME-STAMP?
§ Bind a signed document to a parWcular date and Wme
§ Prove in the future that the signed document existed at this parWcular date
and Wme.
§ Ensure the accuracy of the date and the Wme it indicates and the integrity of
the data to which the date and Wme are bound
USE CASE
§ Digital signature for contract
19
TIME-STAMP DIGITAL DOCUMENT
WHY TIME-STAMP?
§ Bind a signed document to a particular date and time
§ Prove in the future that the signed document existed at this particular date
and time.
§ Ensure the accuracy of the date and the time it indicates and the integrity of
the data to which the date and time are bound
USE CASE
§ Digital signature for contract
20
TIMESTAMPED APPEND-ONLY - BLOCKCHAIN
GENESIS BLOCK
0000000…0000
21
BLOCK HEADER
§ Version
§ Previous Block hash
§ Merkle Root hash
§ Timestamp
§ Difficulty target
§ Nonce
22
MERKLE TREE
Binary Data Tree with Hashes
23
SYMMETRIC & ASYMMETRIC CRYPTOGRAPHY
SYMMETRIC ENCRYPTION
24
SYMMETRIC & ASYMMETRIC CRYPTOGRAPHY
ASYMMETRIC ENCRYPTION
25
ASYMMETRIC CRYPTOGRAPHY & DIGITAL
SIGNATURES
26
BITCOIN ADDRESSES
27
Bitcoin explorer
BITCOIN ADDRESSES
Sign transaction with private key Verify transaction with public key
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PUBLIC KEY-----
MIIBOgIBAAJBAKj34GkxFhD90vcNLYLInFEX6Ppy1tPf9Cnzj4p4WGeKLs1Pt8Qu MEgCQQCo9+BpMRYQ/dL3DS2CyJxRF+j6ctbT3/Qp84+KeFhnii7NT7fELilKUSnx
KUpRKfFLfRYC9AIKjbJTWit+CqvjWYzvQwECAwEAAQJAIJLixBy2qpFoS4DSmoEm S30WAvQCCo2yU1orfgqr41mM70MBAgMBAAE=
o3qGy0t6z09AIJtH+5OeRV1be+N4cDYJKffGzDa88vQENZiRm0GRq6a+HPGQMd2k -----END RSA PUBLIC KEY-----
TQIhAKMSvzIBnni7ot/OSie2TmJLY4SwTQAevXysE2RbFDYdAiEBCUEaRQnMnbp7
9mxDXDf6AU0cN/RPBjb9qSHDcWZHGzUCIG2Es59z8ugGrDY+pxLQnwfotadxd+Uy
v/Ow5T0q5gIJAiEAyS4RaI9YG8EWx/2w0T67ZUVAw8eOMB6BIUg0Xcu+3okCIBOs
HASH SHA 256
/5OiPgoTdSy7bcF9IGpSE8ZgGKzgYQVZeN97YE00
61087f7e8804c5361dd0291c2dd4083a6d28014a999b43c981a42435cf0fce00
-----END RSA PRIVATE KEY-----
Bitcoin address
base58
3xVUrcYNkxtrpgeD6Lez2QbfZGW7g3MDWTV34mZy 21799c282798d07dc5cf385d5fe2fcb7c5e91a5309bcbf6b
28
Bitcoin explorer
QUESTIONS
29
DISCUSSION
30
ĐẠI HỌC NGÂN HÀNG THÀNH PHỐ HỒ CHÍ MINH
Chapter 3
CONSENSUS PROTOCOL
AND
MINING
TP. HCM 2022
OVERVIEW
2
THE BYZANTINE GENERALS PROBLEM
4
SOLUTION I: ORAL MESSAGES
5
L. Lamport, R. Shostak, and M. Pease, “The Byzantine generals problem,” ACM TOPLAS, vol. 4, pp. 382–401, July 1982.
SOLUTION I: ORAL MESSAGES
COMMANDER
v v
v
v x
LEUTENANT 1 LEUTENANT 2 LEUTENANT 3
v v
traitor
x z
y
x z
LEUTENANT 1 LEUTENANT 2 LEUTENANT 3
y y
7
L. Lamport, R. Shostak, and M. Pease, “The Byzantine generals problem,” ACM TOPLAS, vol. 4, pp. 382–401, July 1982.
SOLUTION II: SIGNED MESSAGES
COMMANDER
COMMANDER
traitor
1{0} 1{0}
1{0} 0{0}
0{0,2}
traitor 0{0,2}
discard
9
SOLUTION II: SIGNED MESSAGES
SIGNATURE PATH
v{0}
1
4
0 v{0,1}
v{0,1,5,4}
v{0,1,5}
5
6
v{0,1,5,4,6}
2 v{0,1,5,4,6,3}
10
BLOCKHAIN CONSENSUS – PROOF OF WORK
difficulty
11
BLOCKHAIN CONSENSUS – PROOF OF WORK
difficulty
12
BLOCKHAIN CONSENSUS – PROOF OF WORK
Pros Cons
Better ability to be Slower transaction
decentralized speeds
Higher costs to
Better security
validate transactions
Higher energy
consumption
13
BLOCKHAIN CONSENSUS – PROOF OF STAKE
14
BLOCKHAIN CONSENSUS – PROOF OF STAKE
15
BLOCKHAIN CONSENSUS – PROOF OF STAKE
Pros Cons
Less energy Harder to truly
consumption decentralize the
network
Less security than
Financial opportunities
PoW
Faster transaction
speeds
16
BLOCKHAIN CONSENSUS
17
BLOCKHAIN CONSENSUS
18
BITCOIN PROOF OF WORK DIFFICULTY
19
https://www.blockchain.com/
BITCOIN PROOF OF WORK DIFFICULTY
20
https://btc.com/stats/diff
EVOLUTION OF BITCOIN MINING
GPU ASIC
2009 2010 2010 2013 2014
CPU Mining pools Mining farms
21
BITCOIN MINING
22
BITCOIN MINING
23
BITCOIN MINING REWARDS
§ Full Nodes – Store full Blockchain & able to Validate all Transactions
§ Pruning Nodes – Prune transactions after validation and aging
§ Lightweight Nodes - Simplified Payment Verification (SPV) nodes –
Store Blockchain Headers only
§ Miners – Performs Proof of Work & Create new Blocks - Do not need
to be a Full Node Mining Pool Operators
§ Wallets – Store, View, Send and Receive Transactions & Create Key
Pairs
§ Mempool – Pool of unconfirmed (yet validated) Transactions
25
READINGS
26
DISCUSSION
27
ĐẠI HỌC NGÂN HÀNG THÀNH PHỐ HỒ CHÍ MINH
Chapter 4
TRANSACTIONS
AND
TRANSACTION PROCESSING
TP. HCM 2022
OVERVIEW
2
TRANSACTION FORMAT
3
TRANSACTION FORMAT
4
TRANSACTIONS
5
COINBASE TRANSACTION
RECAP
GENESIS BLOCK
0000000…0000
6
COINBASE TRANSACTION
7
UNSPENT TRANSACTION OUTPUT (UTXO)
Bitcoin transaction outputs that have not been spent at a given time
8
UNSPENT TRANSACTION OUTPUT (UTXO)
9
UNSPENT TRANSACTION OUTPUT (UTXO)
10
UNSPENT TRANSACTION OUTPUT (UTXO)
11
BLOCKCHAIN DESIGN
12
ĐẠI HỌC NGÂN HÀNG THÀNH PHỐ HỒ CHÍ MINH
Chapter 5
CONTRACT
AND
SMART CONTRACT
TP. HCM 2022
OVERVIEW
§ Contract
§ Smart Contracts
§ Blockchain Design with Smart Contracts
§ Brieft explanation of Dapps, Token, NFT
§ Legal Issues
2
CONTRACT
promise or performance
given in exchange for
promise or performance
3
SMART CONTRACT
X Code is law
4
SMART CONTRACT
However…
§ Smart Contracts may not be “Smart”
§ Smart Contracts may not be “Contracts“
5
SMART CONTRACT
However…
§ Smart Contracts may not be “Smart”
§ Smart Contracts may not be “Contracts“
6
SMART CONTRACT
Pros Cons
Not suitable for all kinds of
Immutability characteristic
contracts
BUGS???
8
INTERACTING WITH A SMART CONTRACT
9
BLOCKCHAIN DESIGN WITH SMART CONTRACTS
10
BLOCKCHAIN DESIGN WITH SMART CONTRACTS
Smart contract
Smart contract
11
USE CASES
13
https://dappradar.com/
NFTs
§ NFTs (non-fungible tokens) are unique cryptographic
tokens that exist on a blockchain and cannot be
replicated.
§ NFTs can represent real-world items like artwork and real
estate.
§ "Tokenizing" these real-world tangible assets makes
buying, selling, and trading them more efficient while
reducing the probability of fraud.
§ NFTs can also function to represent individuals' identities,
property rights, and more.
14
INITIAL COIN OFFERING (ICO)
Advantage:
• Young enterprises do not have to wait for months before having the "go"
of an investment fund
Disadvantages:
• Difficult to verify the relevance and quality of a project that does not exist
yet
• Absence of control authority to regulate the market "anyone can issue a
digital title, so there are mechanically a lot of scams of all kinds"
• Volatility of cryptocurrency can quickly raise or lower the amount raised
depending on the technical developments of the platform and of other
exceptional events 16
LEGAL ISSUES
DISCUSSION
17
READINGS
Chapter 6
THE FUTURE OF
BLOCKCHAIN TECHNOLOGY
2
CHALLENGES WITH BLOCKCHAIN TECHNOLOGY
DECENTRALIZATION SECURITY
4
BLOCKCHAIN – TECHNICAL FEATURES
BITCOIN - PERMISSIONLESS PERMISSIONED
Cryptography & Timestamped Logs YES
§ Cryptographic Hash Functions § ü
§ Timestamped Append-only Logs (Blocks) § ü
§ Block Headers & Merkle Trees § ü
§ Asymmetric Cryptography & Digital Signatures § ü
§ Addresses § ü
Decentralized Network Consensus NO
§ Consensus through Proof of Work § PBFT, Notary Nodes, etc.
§ Network of Nodes § ü
§ Native Currency § ü
Transaction Script & UTXO YES
§ Transaction Inputs & Outputs § ü
§ Unspent Transaction Output (UTXO) § ü
§ Scripting language § ü
5
PERMISSIONED PRIVATE BLOCKCHAINS
Key Design Features
§ Membership Limited to Authorized Nodes
§ Transactions can also be Limited to Authorized Known Participants
§ Data & Ledgers can be Partitioned to Keep amongst Subgroups of Nodes
§ Consensus built on Permissioned, Private Protocols – Globally or Modular
between Transacting Parties.
§ Practical Byzantine Fault Tolerance
§ Delegated Notary Nodes
§ Diverse Protocols – from Protocols for Multi Party Consensus to Crash Fault Tolerant
for 1 Party
§ Uses Cryptography and Registration Authorities to Mask User Data
§ Facilitates Smart Contracts using Chaincode or other Programming Language
§ No Native Currency – Possible, though, with Smart Contracts
§ Code Generally Open Source
6
HYPERLEDGER FABRIC
7
HYPERLEDGER FABRIC
8
HYPERLEDGER FABRIC
§ Public Write Capability § Private Write Capability § Trusted Party host data
§ P2P transactions § Finality of Data in Append § Trusted Party can
§ No Central Intermediaries Only Log “CRUD”
§ Token economics § Public Verifiability § Client – Server
architecture
11
BLOCKCHAIN APPLICATIONS
12
FINANCIAL SECTOR POTENTIAL USE CASES
13
USE CASES: ASSESSING COSTS & BENEFITS
Strategic questions?
§ What is the value creation proposition?
§ What problem or ‘pain point’ is being solved?
§ What are competitors doing to address similar ‘pain points’?
§ Why is blockchain technology and native token the best solution?
14
USE CASES: ASSESSING COSTS & BENEFITS
15
METAVERSE
The metaverse is a concept of a persistent, online, 3D universe that combines
multiple different virtual and physical spaces. Metaverse is the future iteration
of the internet. The metaverse will allow users to work, meet, game, and
socialize together in these 3D spaces.
Experience Games, Social, Esports, Theater, Shopping
Discovery Ad Networks, Social CuraBon, RaBng, Store, Agents
Creator Economy Design Tools, Asset Markets, Workflow, Commerce
Spatial Computing
3D Engines, VR/AR/XR, GIS
Decentralization
Human
Edge Computing, AI Agents, Microservices, Blockchain
Interface
Mobile, Wearable, HapBc, Gestures, Voice
Infrastructure 5G, 6G, Wifi 6, Cloud, GPUs, Storage
METAVERSE 7 LỚP 16
Understanding the Seven Layers of the Metaverse
METAVERSE
ECONOMIC
SYSTEM
OPENESS UNLIMITED
METAVERSE
PERSONALIZED
IMMERSIVE
PERSISTENT INTEROPERABILITY 17
METAVERSE
Augmented Mix Virtual
Reality Reality Reality
Physical Digital
Reality Holographic Immersive Reality
Mobile phone / devices devices Mobile phone
Tablet (Hololens, Magic (Oculus, HTC (cardboard,
Leap…) Vive…) GearVR)
PHYSICAL WORLD
Proptech Concert
Improve industrial efficiency in the virtual way
Healthcare
Generate new industries to create real value
Education Movies
VIRTUAL WORLD
19
BLOCKCHAIN & METAVERSE
20
QUESTIONS
21
READINGS
3. Ten Years after the Crash, We are Living in a World it Brutally Remade
22
DISCUSSION
23