FinTech Lecture 7 : Basics of Cryptography and Blockchain
Slides I used for FinTech - Financial Innovation and the Internet 2022 Fall at Graduate School of Business and Finance, Waseda University on November 18, 2022.
Innovation and the Internet 2022 Fall Lecture 7 : Basics of Cryptography and Blockchain Kenji Saito, Graduate School of Business and Finance, Waseda University Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.1/37
be online only. When online, Camera ON is recommended, but not required You do need to speak often anyway (we are going to have a lot of dialogue) We will use breakout rooms a lot, but those won’t be recorded unless you do it yourselves (need to be allowed) Keep your Zoom client updated! We might use latest features The recordings could be used for research on (online) learning Transcribed for use and anonymized Will let you know when the necessity arises Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.2/37
and chat text will be posted at Moodle and Discord Trial automatic transcriptions will be posted at Discord Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.3/37
Web API (REST) in particular Demonstrations using stack calculators Discussion : Imagine API Basics of Cryptography Just the beginning Assignment Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.5/37
cryptography and digital signature Zero-knowledge proof Assignment Review Understanding Blockchain Bitcoin’s “question” and “answer” Beaker/Newspaper Model (physical model of Bitcoin) Validity/Existence/Uniqueness layers Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.6/37
we will not go through detail of encryption/decryption techniques Cryptographic hash function Public key cryptography and digital signature Zero-knowledge proof Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.7/37
*OQVUUIBUHJWFTUIFTBNFEJHFTU $BO` UEFEVDF 'JYFEMFOHUIEFpOFECZ UIFGVODUJPO FYCJU *OQVU )BTIWBMVF EJHFTU *GJOQVUTBSFKVTU CJUEJ⒎FSFOU 5PUBMMZEJ⒎FSFOU PVUQVU $SZQUPHSBQIJDIBTIGVODUJPO 4)" 3*1&.% FUD $BO` UEFEVDF $BO`UEFEVDF *U` TJOGFBTJCMFUPDBMDVMBUFBO JOQVUUIBUQSPEVDFTBTQFDJpD EJHFTU When a file (e.g., an open-source app) needs to be authenticated, the provider may publish a fingerprint value (called a hash value or digest) of the file (typically in hexadecimal) The downloader can calculate the digest in the same way, and if it is the same value as the publicly available one, they have a real file It is considered extremely difficult to disguise a fake file so that it gives the same digest The digest is calculated using a cryptographic hash function There are various functions, such as the SHA (Secure Hash Algorithm) series A cryptographic hash function is a function that outputs a completely different value if the original data (preimage) is different by even 1 bit Unidirectional, and cannot get preimage from the digest So it is sometimes used to hide the original data Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.8/37
by NSA) Deprecated SHA-2 (designed by NSA) SHA-256 produces 256-bit digests “FinTech - Financial Innovation and the Internet 2022 Fall” → 051a807b12513f8b402b23e337806a06ea221696611724be4d510329aa0076d6 SHA-3 (selected through a public call for proposals) SHA3-256 produces 256-bit digests “FinTech - Financial Innovation and the Internet 2022 Fall” → 794cbcb155f2b152c72c2cb4a37909129319cf9dd6576d0b7005f6491a5d8d8e Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.9/37
Online Tools https://emn178.github.io/online-tools/sha256.html For a cryptographic hash function H and data m, We cannot compute m′ where m′ = m such that H(m) = H(m′) in a realistic time, and therefore We cannot compute m or m′ in a realistic time when H(m) is given H is not encryption because there is no hint (key) and it cannot be decrypted We call it a collision if we find m′ such that H(m) = H(m′) and m′ = m Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.10/37
by Google and the National Research Institute for Mathematics and Computer Science (CWI), Netherlands As an alert Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.11/37
5IF*OUFSOFU %JTUSJCVUFQVCMJDLFZTJOBEWBODF -PDLJOHBOEVOMPDLJOHLFZTBSFTFQBSBUF BTZNNFUSJDDSZQUPTZTUFN 4FOEFS LFZQBJS 3FDFJWFS QMBJOUFYU QVCMJDLFZ QSJWBUFLFZ &ODSZQUX QVCMJDLFZ %FDSZQUX QSJWBUFLFZ 4FOEFODSZQUFEUFYU It is extremely difficult to deduce the private key from a public key Why don’t we use the same key for locking and unlocking? (Actually, we usually do, but we need ↑ to do so) Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.12/37
BTJGJU`TBEFDSZQUFEEBUB 4FOEQMBJOUFYUX TJHOBUVSF %PFTUIFFODSZQUFETJHOBUVSF NBUDIUIFEJHFTU DPNQVUFEGSPNUIFQMBJOUFYU %FDSZQUXQSJWBUFLFZ BTJGJU`TBOFODSZQUFEEBUB 3FDFJWFS 4FOEFS QMBJOUFYU QMBJOUFYU TJHOBUVSF TJHOBUVSF %JTUSJCVUFQVCMJDLFZTJOBEWBODF LFZQBJS EJHFTU QVCMJDLFZ QSJWBUFLFZ EJHFTU Can prove that it was sent by the very person and has not been altered This illustration shows how it works with RSA (RSA : Rivest, Shamir, Adleman) ECDSA is used in Bitcoin, etc., instead (Elliptic Curve Digital Signature Algorithm), in which we don’t encrypt/decrypt Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.13/37
text, private key> Output : signature Verifying Input : <plain text, signature, public key> Output : OK (no change in plain text, and private key was used) or NG (otherwise) Whether the signature meets certain mathematical properties that can be tested using plain text and public key Private key cannot be inferred in the verification process Cryptographic hash functions and digital signatures are the two cryptographic techniques used in blockchain (no cipher ) Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.14/37
no knowledge other than what prover wants to prove Example: “I know a secret spell to open the door” ↑ Prove this without revealing the spell itself For example, repeat “coming out from the way she is told” for 20 times Completeness Verifier accepts with high probability if the proposition is true Soundness Verifier has little chance of accepting if the proposition is false Zero-knowledge Can imitate dialogue without having to be a prover (without knowledge) Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.16/37
zero-knowledge proof Example: proving “my test score is the same as yours” Only one person can enter the room at a time Room has numbered and locked voting boxes for every possible score (for example, 101 boxes for 0∼100 points) You have a key bundle, but leave only the key of your score box, and throw away the rest I enter the room and vote for my score box and × for the rest You go into the room and unlock your score box to see if it’s voted Digital signature (can prove that the private key is there without revealing it) is an example of non-interactive zero-knowledge proof Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.17/37
financial services (2) If a user is an “end (edge)”, what is the “center” operated by people or an organization in the example? (3) How will the service change if that center is automated, without an organization? Deadline and how to submit November 15, 2022 at 17:59 JST From Moodle (mandatory) Optionally, you can also post to #assignments channel at Discord So that your classmates can read your report, refer to it, and comment on it Just plain text, and be concise, please (and please remember Kent Beck on How to Get a Paper Accepted) Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.19/37
Measures . . . how to improve the class 22 out of 28 students submitted (pretty good, and always better late than never) To be automated : lending / payment or transfer / exchange / insurance / properties / credit card / IPO / ALM / investment / brokerage / tax processing / consultation Very interesting! There are some aspects of blockchain or smart contracts that you are only dreaming about Hopefully, we will gain a high-resolution understanding of blockchain technology later Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.20/37
step is to give it a good title (probably 3 below is your title), then Abstract in 4 simple sentences, by Kent Beck: Sentence 1 : State the problem Sentence 2 : Why the problem is a problem Sentence 3 : A “startling” sentence Sentence 4 : Implications of the startling sentence Example: The rejection rate for OOPSLA papers is near 90% 1 Most papers are rejected not because of a lack of good ideas, but because they are poorly structured 2 Following four simple steps in writing a paper will dramatically increase your chances of acceptance 3 If everyone followed these steps, the amount of communication in the object community would increase, improving the rate of progress 4 cf. https://plg.uwaterloo.ca/∼migod/research/beckOOPSLA.html Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.21/37
Global Automatic Teller Machine Eliminates Banks (1) Cross-border fund transfer (2) Local and correspondent banks (3) (Kent Beck’s Abstract Style) Cross-border fund transfer is expensive and slow It is that way because the transfer needs to go through local and correspondent banks, each collecting a fee Global automatic teller machine with user-definable accounts will eliminate the needs for these banks People can transfer funds by simply depositing money and telling the other party the account through an encrypted channel (More detail if you want) Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.22/37
by eliminating the need, at least for smaller transactions, for a central institution that holds the currencies to clear the market Buy/sell orders for various currencies could be matched to people, at that moment, needing to sell/buy the counter currency via smart routing These people could be merely people needing the currency you are selling or they could be traders seeking to profit from price movements There would still need to be an organization to refill foreign currency ATMs or, in some cases, to physically staff foreign exchange counters, but this organization would not have to be a clearinghouse for foreign currency trading themselves ⇒ In other words, the staff can be hired by the automated system Just like the original definition of DAO (Decentralized Autonomous Organization) Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.23/37
can connect a borrower and a lender, using the concept of “smart contracts”, which are programs stored on blockchains that get automatically executed if their conditions match ⇒ No, they do not Smart contracts do not get automatically executed if their conditions match They have to be explicitly called by some external entity off the blockchain At least, that is how it works with Ethereum blockchain Such an external entity can be automated, but we need to trust it Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.24/37
FTX collapse may be the most relevant event for this discussion FTX recently filed for chapter 11 bankruptcy following a liquidity crisis and major fraud allegations against the “center”, in this case FTX (and Alameda Research) and more specifically against founder and CEO Sam Bankman-Fried Through automation, cutting out the center (i.e., intermediary or middlemen), and through proper implementation one may be able to prevent such events However, cutting out the center also comes with regulatory uncertainties especially with respect to oversight (See e.g., Financial Times article: https://www.ft.com/content/f05fe9f8-ca0a-48d5-8ef2-7a4d813af558) ⇒ Thank you, yes, it sounds very relevant Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.25/37
door key is needed to prove the Ownership Transfer; only the Housing Office (Real Estate Exchange Management Center) can issue a new property deed to confirm contract validity and transfer legality Here, the housing office is the “center” of the financial activity If there is no more housing office, or say, the ownership transaction process is automated, once the buyer has the door key, everyone will know that he/she is the new master of the house ⇒ Would we not still need more than the door key? Maybe it’s just a matter of how to say it We will probably see a demonstration at a later class Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.26/37
Nakamoto) Satoshi him or her or themselves called it “distributed time-stamp server” Not a good word for representing a concept (catchy, but manipulating the impression) Something implemented by Chain of ← actually, backward list of Blocks ← actually, sets of data For example, we don’t call TV “picture tube” today (or do we?) If you name a concept based on how it is implemented, it will quickly become outdated Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.27/37
money whenever we want, and never let anyone stop us”? Distrust of (central) bank money / Sending money → a state transition in a state machine Straightforward requirements (BP : Blockchain Properties) BP-1: A self-authorized user solely can cause a state transition that is allowed in the state machine (self-sovereignty) BP-2: Such a state transition always occurs if the authorized user wants it to happen (censorship resistance and fault tolerance) BP-3: Once a state transition occurs, it is virtually irreversible, and can never be denied (tamper resistance) Denying = rejection, deletion, alteration, fabrication ⇒ Censorship resistance in a broad sense (no control of the past either) Not really perfectly satisfied by blockchain Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.28/37
“we send money whenever we want, and never let anyone stop us”? Distrust of (central) bank money Bitcoin’s “Answer” Cannot depend on any particular service provider ⇒ Exchange digital coins over the Internet by P2P (peer-to-peer) What if they deny that they sent a coin? ⇒ Use digital signatures (collateral for verifiability and non-repudiability of contents) Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.29/37
by digital signatures alone Need to prevent double spending (want to ensure non-repudiation of existence) ⇒ Put the evidence of the transaction in newspaper What if refused for publishing or service is discontinued? ⇒ Place evidence of a transaction in “newspaper” (as collective evidences of events) issued by a crowd (everyone has the exact same local copy of the newspaper) And thereby records are like locked up in the air · Anyone can leave, and when they join again, the records are still there Theft of coins based on this idea always follow the story made typical by the Mt.GOX or CoinCheck incident “Don’t let anyone stop us from spending our own money whenever we want to” ⇒ Has to prove that the user is oneself by their own → Zero-knowledge proof of possession of the private key → Anyone with the private key is the user oneself ⇒ Transaction is verifiable by all but irrevocable → Stolen coins can be tracked but not recovered Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.30/37
of liquid of no value to mankind Contained in a tank Individuals can hold as many beakers as they like, measuring down to 1 100 , 000 , 000 cm3 (it has a locked lid) Only “editor” selected every 10 minutes on average can pump now 6.25cm3 into their beaker Chosen by a special lottery The winning lottery is held in everyone’s box, and each person draws the lottery with all their strength → non-stoppable procedure Coordinate the proportion of winning lots so that someone is chosen every 10 minutes on average Volume pumped is reduced by half every about 4 years (every 21 thousand pages of “newspaper” described later) Started from 50cm3 in January 2009 Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.31/37
of fluid between beakers Recorded as “a signed article” by the pourer Post the article in the “newspaper” made by everyone Selected “Editor” verifies the articles and publishes them in the last page of newspaper (of which everyone has a local copy) Page carries the evidence of winning the lottery Editor also gets “overflow” of trades on the page If people publish a page with the same page number. . . Longer sequence of pages wins People sometimes lose the key of their beakers Create this digitally, and pretend that it’s a currency → Bitcoin There is no money or currency that does not need pretension Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.32/37
a digital signature of the party to which the referenced output is addressed Referenced output (= coin) is consumed → never double-spent (UTXO : Unspent transaction (TX) Output) Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.33/37
number : n page number : n+1 page number : n+2 Cryptographic digest of the previous page (must be less than or equal to the target value) some extra number (Nonce : Number used Once) (random value to make the digest less than or equal to the target) Page digest (output by a cryptographic hash function) must be less than or equal to target We don’t know how to manipulate the original data to get the right digest This is the principle of the lottery, which requires the same amount of cost to fake the history Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.34/37
page number : n+1 page number : n+2 page number : n+3 page number : n+1 page number : n+2 page number : n+3 page number : n+4 This history is valid Sometimes page sequences are split when someone else wins the lottery at about the same time A history is the hardest to tamper with when the cumulative cost of lottery for the whole sequence is the highest Everyone agrees that such history is the official one (strict consensus is not achieved because it can be overturned) Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.35/37
n+1 block_no : n+2 block_no : n+3 block_no : n+1 block_no : n+2 block_no : n+3 block_no : n+4 Histroy with the largest cost to record or modify (history the most difficult to alter) is chosen Cryptographic digest of the previous block Transactions are digitally signed To create a block, its cryptographic digest needs to be below some certain number (Proof of Work) or one needs to win by voting weighted by the stakes in cryptocurrency (Proof of Stake) [both costly] Creator of a block can record the reward in cryptocurrency in the block, which is effective only when the block is included in the chosen history Means are provided to confirm existence of transactions validity existence uniqueness In case of Proof of Work, the cost of power is balanced against the market value of the native currency Everyone confirms that records are not tampered with by the mechanism protected by the price of the native currency Lecture 7 : Basics of Cryptography and Blockchain — FinTech — Financial Innovation and the Internet 2022 Fall — 2022-11-18 – p.36/37