Lec2.Cryptography and Cryptocurrency
Lec2.Cryptography and Cryptocurrency
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