%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Beamer Presentation
% LaTeX Template
% Version 1.0 (10/11/12)
%
% This template has been downloaded from:
% http://www.LaTeXTemplates.com
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%----------------------------------------------------------------------------------------
%	PACKAGES AND THEMES
%----------------------------------------------------------------------------------------

\documentclass[aspectratio=169]{beamer}



\DeclareMathOperator*{\argmin}{arg\,min}


%%%%%%%%%%%%%

\usepackage{hyperref}

\input{mydefs.tex}

\mode<presentation> {


\usetheme{Frankfurt}

% As well as themes, the Beamer class has a number of color themes
% for any slide theme. Uncomment each of these in turn to see how it
% changes the colors of your current slide theme.



}


%{%
%}

\setbeamercolor{section in head/foot}{bg=lightgray} %set the top navigation bar background color
\setbeamertemplate{footline}[frame number] % set frame page number only
\usepackage{appendixnumberbeamer} % total will not include appendix frame numbers 

\beamertemplatenavigationsymbolsempty



\usepackage{graphicx} % Allows including images
% graphicx also allows for resizebox
% graphicx also allows for \scalebox
\usepackage{caption}
\usepackage{subcaption} % packgage for subcaption in subfigures
% The subfig and subcaption packages can not be used in cooperation with each other. Instead, you can usecaption package with subfig to add some flavor to the captions and subcaptions
\usepackage{bm} % make bold math symbols
\usefonttheme{professionalfonts}
\usepackage{tabularx} % extra features for tabular environment
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{adjustbox} % allows adjustbox
\usepackage{amsmath}  
\usepackage{amsfonts}
\usepackage{hyperref} % package for hyper link

% the following hypersetup makes link blue
\hypersetup{
  colorlinks   = true, %Colours links instead of ugly boxes
  urlcolor     = blue, %Colour for external hyperlinks
  linkcolor    = blue, %Colour of internal links
  citecolor   = blue %Colour of citations
}


\usepackage{float} % make the table H effective
\restylefloat{table}
\usepackage{color, colortbl}
\usepackage{booktabs} % package for tex professional table
\usepackage{mathtools} % package for \coloneqq
\usepackage{multirow} % multirow for intuition page.

% make pdf dark mode

\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%



\usepackage{tikz} % graph in latex
\usetikzlibrary{positioning,arrows.meta} %tikz diagram
\usepackage{pgfplots}
\pgfplotsset{compat=newest} %this setting allow node to go to the correct place
\usepgfplotslibrary{fillbetween}

% use the tikz external library to cache tikz drawings
\usetikzlibrary{external}
\tikzexternalize[prefix=tikz/,optimize command away=\includepdf]



\usepackage{natbib} % package for citation


% The subfig and subcaption packages can not be used in cooperation with each other. Instead, you can usecaption package with subfig to add some flavor to the captions and subcaptions


% define a comment line that does nothing to hide content
\newcommand{\comment}[1]{}
\newcommand{\lnb}[1]{%
  \ln\left(#1\right)%
}
\renewcommand{\baselinestretch}{1.0} %  scales the default interline space to 1.0 its default value. 

% define a comment that can scale the equation 
\newcommand\scalemath[2]{\scalebox{#1}{\mbox{\ensuremath{\displaystyle #2}}}}

%----------------------------------------------------------------------------------------
%	TITLE PAGE
%----------------------------------------------------------------------------------------

\title[Introduction to Cryptocurrency]{\huge{Introduction to Cryptocurrency} \\
\vspace{6mm}
\small{Fall 2025}
} % The short title appears at the bottom of every slide, the full title is only on the title page




\author[Joseph Hall]{Joseph Hall} % Your name
\institute[GT]{Georgia Institute of Technology} % Your institution as it will appear on the bottom of every slide, may be shorthand to save space
 % Your institution for the title page
 % Your email address
 
\date{November 4, 2025} 
 % Date, can be changed to a custom date if without date



%---------------------------------------------------------------------------
\begin{document}

\newcolumntype{d}[1]{D{.}{.}{#1}}


\begin{frame}
\titlepage % Print the title page as the first slide
\end{frame}


%----------------------------------------------------------------------------------------

%	PRESENTATION SLIDES
%----------------------------------------------------------------------------------------

%-----------------------------------------------



%---------------------------------------------------------------------
%---------------------------------------------------------------------
%---------------------------------------------------------------------
%---------------------------------------------------------------------



\begin{frame}
\frametitle{Roadmap}
\tableofcontents
\end{frame}

%------------------------------------------------



%------------------------------------------------
% insert table of content before each section or subsection
%------------------------------------------------
\AtBeginSection[]
{
\begin{frame}
\frametitle{Roadmap}
\tableofcontents[currentsection,currentsubsection]
\end{frame}
}
%------------------------------------------------


%---------------------------------------------------------------------
%---------------------------------------------------------------------
\section{Cryptographic Building Blocks}
%---------------------------------------------------------------------
%---------------------------------------------------------------------

%------------------------------------------------
%------------------------------------------------
\subsection{Hash Functions}
%------------------------------------------------
%------------------------------------------------

\begin{frame}
\frametitle{Hash Functions} 

\bi
\m A \textbf{hash function} takes some input string, and ``chaotically'' spits out an output string. \href{https://emn178.github.io/online-tools/sha256.html}{Demo}
\m Servers (to which you log in) store hashes, not passwords! \pause 
\m ``Chaotic'' means deterministic but unpredictable: hash of a number never changes, but knowing hash of $N$ doesn't reveal anything about hash of $N+1$. 
\bi
\m \textbf{One-way:} Can calculate outcomes, but can't back out initial conditions
\m \textbf{Collision Resistance:} Lots of outcomes are possible, so two initial conditions rarely result in same outcome (a ``collision'') 
\ei 
\ei

\end{frame}

\begin{frame}\frametitle{Hash Functions}

A cryptographic hash function is a mapping H : M → D from a set M of possible messages of any length to a set D of digests, for example the set of strings of 0s and 1s of a fixed length, such as 256. See \href{https://www.youtube.com/watch?v=0WiTaBI82Mc}{Ramzan (2012)}. 
\vfill \pause 
For usefulness, a cryptographic hash function H should be easily computable and, among other properties, be: 
\begin{enumerate}
    \item \textbf{Collision resistant}, meaning that H is “nearly injective.” That is, it should be extremely \ul{rare} to have H(x) = H(y) unless x = y.\pause 
    \item \textbf{Difficult to invert}. That is, it should be extremely hard to guess x, or properties of x\footnote{digital signature schemes do preserve \ul{some} properties of x as we will see}, from H(x).\pause 
    \item \textbf{Extremely sensitive}. Even small changes in the message should usually produce large changes in the digest.  \pause 
\end{enumerate}
In \textbf{digital signature schemes} (as we will see), a ``digest'' is a \textbf{signed message}. 
\end{frame}


\begin{frame}{Collision Resistance and Invertability}

\textbf{Question}: Suppose a function H maps the integers {1, 2, 3, 4, 5, 6} to the integers {0, 1, 2, 3, 4, 5} by letting H(x) = x - 1. For example, H(5) = 4. Is H collision resistant? \pause 
\vfill 
\textbf{Answer}: Yes, it is. Observe that $H(x) - H(y) = x - y$ in this case, so if $x \ne y$, then $H(x) \ne H(y)$ \pause 
\vfill 
\textbf{Question}: is $H(.)$ difficult to invert? \pause 
\vfill 
\textbf{Answer}: No, it is easy to invert. In this case $H^{-1}(x) = x + 1$ \pause \vfill 
\textbf{Question}: is $H(.)$ a useful cryptographic \textbf{hash function}? \pause 
\vfill 
\textbf{Answer}: No, hash functions must be hard to invert. 
    
\end{frame}


\begin{frame}
\frametitle{Hash Functions}

Hash functions are the basis for \textbf{Proof of Work}
\bi
\m By publishing $y=H(x)$, anyone can check that they know the real $x$ \ul{without $x$ ever becoming public information} \pause 
\bi
\m Easy to compute $H(x)$ given $H(\cdot)$ and $x$ \pause 
\m If someone changes $x$ to $\tilde{x}$, even by one letter, $H(\tilde{x})$ will be very different!
\m Used in checksums for file downloading \pause 
\ei
\m Application: \textbf{Mining and proof-of-work}
\bi 
\m No way to discover $x$ given $H(x)$ beside \textbf{brute force}! \pause 
\m The Secure Hash Algorithm 1 (``\textbf{SHA1}'') takes between $2^{63}$ - $2^{80}$ evaluations to find a collision ($x,y$ such that $H(x)=H(y)$) (depending on how clever you are) \pause 
\m Bitcoins are mined by brute-forcing hashes to find $x$s that produce $H(x)$ with leading zeroes. 
\ei 
\ei

\end{frame}

\subsection{Digital Signatures}

\begin{frame}
\frametitle{Digital Signature Schemes}

Requirements:
\bi
\m JPH has a public key everyone knows
\m JPH has a private key only JPH knows
\bi 
\m \textbf{Non-invertability} means the public key doesn't reveal the private key \pause 
\ei 
\m JPH can ``sign'' messages: use the private key to alter the message in a way that \ul{proves} JPH created his public key 
\m Public key allows \textbf{verification}, but not \textbf{signature production} \pause 
\bi
\m Using public key, anyone can verify signature correctness: JPH used his private key to sign the message \pause 
\m But, using the public key, can't generate new valid signatures
\ei
\ei

\end{frame}


\begin{frame}{Digital Signatures, Formally}

A \textbf{Digital Signature Scheme} is a combination of \ul{Three Functions}: 

\bi 
\m A function to generate \textbf{Public Keys}: $PrK \Rightarrow PuK$ \pause 
\m A function to generate \textbf{Signed Messages}: $(PrK, M) \Rightarrow M'$ \pause 
\m A function to \textbf{Verify} signed messages: $(PuK, M, M') \Rightarrow \{0,1\}$ \pause 
\ei 

These functions ($\Rightarrow$) are \ul{one-way}, \ul{chaotic} functions! \pause \\
In Bitcoin, these ``messages'' encode a list of transfers of blocks from one owner to another! 

\end{frame}

\begin{frame}{Digital Signature Schemes, Visually}

\begin{center}
    \includegraphics[scale = 0.3]{pics/Financial Technology Timeline for Joseph slide 2.pdf}
\end{center}
    
\end{frame}

\begin{frame}{Ok, but how do these signatures actually \ul{work}?}

\href{https://ece.gatech.edu/courses/ece6280}{ECE 6208} teaches this. 

\vfill 
An easy scheme to implement from scratch  is called \href{https://www.geeksforgeeks.org/elgamal-encryption-algorithm/}{ElGamal.} \pause (``The Beauty'' in Arabic) 
    
\end{frame}

\subsection{Merkle Trees}

\begin{frame}{Uses of Merkle Trees}

A \hyperlink{https://decentralizedthoughts.github.io/2020-12-22-what-is-a-merkle-tree/}{Merkle Tree} is a way of \ul{efficiently} storing the required information to ensure that a set of documents or messages have not been tampered with or corrupted. \pause 
\vfill 
Merkle Trees are used in many applications to solve problems such as:

\bi 
\m Maintaining integrity of files stored on Dropbox.com, or \emph{file outsourcing}
\m Proving a transaction between Alice and Bob occurred, or \emph{set membership}
\m Transmitting files over unreliable channels, or \emph{anti-entropy}
\ei 
    
\end{frame}

\begin{frame}{Construciton of Merkle Trees}

Start with, say, 8 files $(f_1...f_8)$, and a hash function $H(.)$ \vfill \pause 

Start by hashing each file $H(f_i)$: 

\includegraphics[scale = 0.3]{Screenshot 2025-01-27 at 7.38.00 PM.png}
    
\end{frame}

\begin{frame}{Construction of Merkle Trees}

Then, create the second layer of the tree by hashing adjacent nodes \ul{together} (this can be as simple as concatenating them!) 

\includegraphics[scale = 0.3]{Screenshot 2025-01-27 at 7.40.09 PM.png}
    
\end{frame}

\begin{frame}{Construction of Merkle Trees}

Continue until you have created an entire ``tree'': 
\begin{center}
    \includegraphics[scale = 0.3]{Screenshot 2025-01-27 at 7.43.10 PM.png}
\end{center}

\end{frame}

\begin{frame}{Construction of Merkle Trees}

\textbf{Question}: Why is this tree upside-down? \pause 

\textbf{Answer}: Because Computer Scientists have never gone outside, a necessary prerequisite to see a real tree 
    
\end{frame}

\begin{frame}{Verification with Merkle Trees}

Upload your files $(f_1...f_8)$ \textbf{and} your Merkle Tree to Dropbox, storing \ul{only} the \textbf{Merkle Root} $h_{1,8}$ locally. \pause \vfill 
Later, ask for the file you want, say $f_3$, but make sure to also ask for the \textbf{Merkle Proof}: the hashes needed to compute $h_{1,8}$ from the desired \textbf{Merkle Leaf} ($f_3$)

\end{frame}

\begin{frame}{Verification with Merkle Trees}

The \textbf{Merkle Proof} lets you verify that you downloaded the real, original $f_3$: 

\begin{center}
        \includegraphics[scale = 0.3]{Screenshot 2025-01-28 at 1.46.09 PM.png}
\end{center}
    
\end{frame}

\begin{frame}{Advantages of Merkle Trees}

\textbf{Question}: Why not just store the hash of every file? Wouldn't that be simpler? \pause \\ 
\textbf{Answer}: That would require storing 1 hash per document, so your local storage would scale linearly with number of files. The Merkle Tree requires storing \textbf{only} the Merkle Root, a single hash, \textbf{for any number of files}! \pause 

\vfill 
\textbf{Question}: The server stores ($h_4$, $h_{1,2}$, and $h_{5,8}$) for you. Can't the server modify these to make the Merkle Proof appear true, even if $f_3$ is changed to $\tilde{f_3}$? \pause   \\ 
\textbf{Answer}: The cryptographic property of \textbf{Non-Invertability} ensures that it is prohibitively difficult to create a false Merkle proof. 
\vfill \pause 
For other (analogous) uses of Merkle Trees including Transaction Verification and Transmitting files robustly over error-prone communication channels, see \hyperlink{https://decentralizedthoughts.github.io/2020-12-22-what-is-a-merkle-tree/}{Tomescu (2020)}
    
\end{frame}


\section{Blockchains}

\subsection{A Centralized Blockchain}

\begin{frame}{What is a Blockchain?}

A \textbf{Blockchain} is a list of records that are linked together by hash functions

\begin{center}
    \includegraphics[scale = 0.25]{Screenshot 2025-01-27 at 7.03.18 PM.png}
\end{center}
    
\end{frame}

\begin{frame}{A Centralized Blockchain}

Say that I, JPH, own and operate a private server which records a Blockchain. I don't know the users' private keys, but I control everything that is written on the blockchain. Can I: \pause 
\begin{itemize}
    \item Create false messages? \pause 
    \bi 
    \m No: I don't have the private keys to create messages that can be verified as true. \pause 
    \ei 
    \item Cancel or revert messages? \pause
    \bi 
    \m Yes: I can refuse to include a new block or roll back the blockchain to a previous state. \pause 
    \ei 
    \item Selectively cancel three messages ago, but not the last two? \pause 
    \bi 
    \m No: the hashes of the last two messages would be wrong if the middle hash is missing. 
    \ei 
\end{itemize}
    
\end{frame}

\begin{frame}{A Centralized Blockchain}

Centralized Blockchains are in fact widely-used: 

\bi 
\m Binance Smart Chain 
\m Coinbase Base 
\m Ripple XRP 
\m ``Permissioned'' or ``Private'' Blockchains use \textbf{Proof of Authority}: the admin's public key \emph{per se} is hard-coded into the protocol. 
\ei \pause 
When are these better than just a spreadsheet? \pause \\ 
\bi 
\m Often they aren't: Chase, VISA, Zelle, and Federal Reserves are all just spreadsheets at the end of the day \pause 
\m Centralized Blockchains add one extra level of security: create a transaction history that can't be arbitrarily tampered with: only censored or rewound. \pause  
\m That's still a lot of power in the admin's hands! \pause 
\ei 

\textbf{Can we take away even more power from the admin? Can we make a set of rules to agree on a shared history of transactions without needing to trust \ul{anybody}?}

\end{frame}


\subsection{A Decentralized Blockchain}

\begin{frame}{A Decentralized Blockchain}

\begin{itemize}
    \item  A natural, “democratic” rule would be to have multiple admins taking turns adding transactions to the chain \pause 
    \item How do we prevent one admin from just pretending to be multiple admins? \pause 
    \item Needs to be some “cost”/“barrier” to becoming an admin \pause 
    \item Bitcoin solves this through \textbf{proof of work}
    \item Ethereum solves this through \textbf{proof of stake}
\end{itemize}
    
\end{frame}


\begin{frame}
\frametitle{Hash Puzzles}

\bi
\m The amount of computational power in the world is finite!
\m Let's try to \href{https://emn178.github.io/online-tools/sha256.html}{find a number whose SHA256 hash has a 0 at the beginning}\ldots \pause 
\m Why is this a nice puzzle? Like a PhD
\be
\m Hard to do
\m Proves that you did something hard to do \pause 
\ee
\m With puzzle solution in hand, you become the admin!
\m \textbf{Incentives:} solving the puzzle gives you some BTC as a \ul{block reward}
\m \textbf{Consensus:} \ul{everyone works on the longest chain} 
\ei

\end{frame}



\begin{frame}{How to Prevent Doublespending?}
    
\bi
\m I may want to spend some money to buy a coffee, then ``unspend'' it (but keep my coffee!)
\m Can't just selectively delete the transaction from history (why?)\pause 
\bi
\m Hashes verify integrity of history!
\ei
\m But\ldots could go back in time, then create a parallel universe (a fork in the chain) where I never spent the money 
\bi
\m This would be called a \ul{doublespend}
\ei
\ei

\end{frame}

\begin{frame}
\frametitle{Turning Back Time\ldots}

\bi
\m Anyone can try, since anyone can try to mine and become admin
\m When would I succeed? \pause
\bi
\m Because everyone uses the \textbf{longest chain}, I must be able to hash faster than \textbf{everyone else combined}
\m Control 51\% of the computing power in the Bitcoin ecosystem!
\ei
\m For more details, see \href{https://cs251.stanford.edu/lectures/lecture5.pdf}{Stanford CS251 slides}
\ei

\end{frame}


\section{Bitcoin}

\subsection{History}

\begin{frame}
\frametitle{Satoshi Nakamoto}

\bi
\m Started sending emails about Bitcoin August 2008
\m Oct 2008: Bitcoin \href{https://bitcoin.org/bitcoin.pdf}{white paper}, code released
\m January 9: first block mined!
\bi
\m ``The Times 03/Jan/2009 Chancellor on brink of second bailout for banks''
\ei
\m May 22, 2010: Laszlo Hanyecz bought two Papa John's pizzas for 10,000 BTC, now worth \$600mil USD!
\m Quickly became popular among black markets, \href{https://en.wikipedia.org/wiki/Silk_Road_(marketplace)}{Silk Road}\ldots
\m Founder Ross Ulbricht was recently pardoned by Trump 
\ei
	
\end{frame}

\begin{frame}
\frametitle{Prizes for a Starcraft Tournament in 2011}

\includegraphics[height = 0.8\textheight]{Screenshot 2025-01-28 at 3.03.46 PM.png}
    
\end{frame}

\begin{frame}
\frametitle{Bitcoin Prices}

\begin{center}
\includegraphics[width = .8\textwidth]{Screenshot 2025-01-28 at 3.02.23 PM.png}
\end{center}

\scriptsize
Source: \href{https://coinmarketcap.com/currencies/bitcoin/}{CoinMarketCap}

\end{frame}

\subsection{Structure}

\begin{frame}
\frametitle{Each BTC Block is a Merkle Tree of Transactions!}

\begin{center}
	\includegraphics[width = 0.65\textwidth]{pics/blockchain_book.png}
\end{center}

\bi
\m Valid block headers' hashes start with a big number of 0's (mining puzzle)
\ei

\vspace{2ex}

\scriptsize

Source: \href{https://d28rh4a8wq0iu5.cloudfront.net/bitcointech/readings/princeton_bitcoin_book.pdf?a=1}{NBFMG}, fig. 3.8

\end{frame}

\begin{frame}
\frametitle{Proof of Work Consensus}

\bi
\m Miners connected to each other in a network
\m If you find a valid block, tell all other miners about it
\bi
\m They'll then mine the next block, based on yours
\ei
\m If you solved the hash puzzle, why can't I just steal your solution? \pause
\bi
\m My address is hashed into the block header 
\ei\pause
\m Why wouldn't I try to re-mine your block? \pause
\bi
\m Consensus: if everyone else uses ``longest chain'', I do better by accepting your win, and trying to mine the next block
\ei
\ei

\end{frame}

\begin{frame}
\frametitle{Proof of Work Consensus}

\bi
\m Notice that all properties depend on everyone ``following the rules''\ldots
\bi
\m If your block:
\bi
\m Doesn't hash to enough 0's, or
\m Steals \$\$, or
\m Includes invalid tx's, etc.
\ei
\m Others won't build on it, so others won't build on others not building on it, 
\m So you won't get mining reward
\ei
\m Simple rules are easy for a decentralized system to follow 
\bi
\m By default, miners will pick the simplest possible path
\ei
\ei

\end{frame}

\begin{frame}
\frametitle{Proof of Work Concensus}

\bi
\m If I want to send, sign a tx, and tell all the miners about it \pause
\bi
\m Pile of valid signed, but not-yet in chain, tx's floating around waiting to be included by miners called the \textbf{mempool}
\ei \pause
\m Why can't miner steal my \$? \pause
\bi
\m Tx specifies signature and receiver; miner can only include tx
\ei
\m What if miner doesn't want to include me? \pause
\bi
\m Someone else will, and take the tx fee\ldots
\m \ldots And miner eventually has to accept my tx as valid, or ``fork'' whole network (since hash pointers break)
\ei \pause
\m What if I try to spend twice? \pause
\bi
\m One tx is ``invalid'': doesn't obey the rules, since old tx output already spent
\m Remember, though; everything is ultimately due to consensus among miners, that ``longest block of valid chains'' is the legitimate blockchain
\ei
\ei

\end{frame}


\subsection{Difficulty Adjustments}

\begin{frame}
\frametitle{The Money Pot Game}

\bi
\m Two options:
\be
\m Get \$1 for sure
\m Fight for a \$10 pot, which is equally divided between everyone who picks this option
\ee \pause
\m Which do you pick?
\ei

\end{frame}

\begin{frame}
\frametitle{The Money Pot Game}

\bi
\m What is going on?
\bi
\m Everyone wants the money pot
\m But the more people take the money pot, the less money there is for everyone
\m In ``Nash equilibrium'', the money pot becomes no better than the ``outside option''
\ei \pause
\m Similar settings: what's the equilibrium condition?
\bi
\m Firms competing for profits? \pause
\m Going to the beach on a sunny day? \pause
\m Getting a table for Brunch on Sunday at 12pm? \pause
\ei
\m ``Equilibrium'' behavior is easy to predict in such settings
\bi
\m In equilibrium, the ``good'' deal is so crowded that it becomes just as bad as the ``bad'' deal
\ei \pause
\m Game theory language: call these \ul{congestion games}, or \ul{wars of attrition}, or \ul{tragedy of the commons}
\ei

\end{frame}


\begin{frame}
\frametitle{BTC mining}

\bi
\m Suppose mining a block pays 0.001 BTC
\m Suppose mining block costs \$60 in electricity
\bi
\m If BTC price $>\$60k$, everyone mines; blocks produced quickly
\m If BTC price $<\$60k$, nobody mines; tx's aren't included and the blockchain stops working!
\ei
\m The fact that mining rate depends on BTC vs electricity price is not desirable\ldots
\m Solution: use \ul{difficulty adjustment} to maintain constant block production rate
\ei

\end{frame}

\begin{frame}
\frametitle{BTC Difficulty Adjustment}

\bi
\m Blocks should be produced every 10 minutes
\m Every 2016 blocks (approx 14 days), Bitcoin considers average block production rate, and\ldots
\bi
\m Increases/decreases hash problem difficulty, if block production is too fast/slow
\ei
\m What determines how fast blocks are produced, fixing hash rate? \pause
\bi
\m How many people (that is, how much electricity) is devoted to mining
\ei \pause
\m What determines how many people mine?
\bi
\m How profitable mining is, that is, how high BTC price is, vs electricity price
\ei
\ei

\end{frame}


\begin{frame}
\frametitle{BTC: Equilibrium Condition}
What happens to mining when BTC price goes up?
\bi \pause
\m More people try to mine
\m Difficulty goes up; so electricity to mine a BTC increases
\m $\implies$ profit per \$ of electricity spent doesn't change
\ei \pause
\textbf{Prediction:} difficulty should increase with BTC price

\end{frame}

\begin{frame}
\frametitle{Difficulty vs BTC price}

\begin{center}
\includegraphics[width = \textwidth]{pics/difficulty.png}
\end{center}


\scriptsize
Source: \href{https://www.blockchain.com/explorer/charts/difficulty}{Blockchain.com}

\end{frame}


\begin{frame}
\frametitle{Technological Improvement}

\begin{center}
\includegraphics[width = 0.65\textwidth]{pics/hashrate.png}
\end{center}

\bi
\m 842 Exahashes/s = 842 billion billion hashes a second!
\m Each living person in the world could shake each other living person's hand 10 times, every second!
\m $\sim1\%$ of global energy consumption\ldots
\ei

\scriptsize
Source: \href{https://data.hashrateindex.com/chart/bitcoin-network-hashrate}{Hashrate Index}

\end{frame}


\begin{frame}
\frametitle{BTC Halving}

\bi
\m Approximately every 4 years, issuance of BTC drops by half
\m Last halving: April 2024, now 3.125 BTC per block
\m Does this affect block production rate?
\bi
\m No! Difficulty adjustment always ensure a constant block production rate. 
\ei \pause
\m Also implies there will only ever be 21 million BTC in existence!
\bi 
\m By approximately 2140, the block reward will drop to less than the smallest unit of bitcoin ($1/10^8$) and become equal to zero. 
\m Difficulty adjustment ensures that block production rate is approximately constant 
\ei 
\ei

\end{frame}


\begin{frame}{Transaction Fees}

\bi 
\m Block rewards are not the only incentive to process transactions: miners also charge \ul{transaction fees} to include a transaction in their blocks. \pause 
\m Transaction fees are quoted in ``sat/vB'', or ``Satoshis per virtual Byte" 
\bi 
\m A \ul{Satoshi} is $1/10^8$ BTC, the smallest unit that can be transacted \pause 
\m The \ul{Size} of the transaction depends mostly on its format. \hyperlink{https://mempool.space/docs/faq#what-are-vb-wu}{The current most efficient format for submitting transactions was created in 2017.} \pause 
\ei
\m Miners prioritize including transactions that offer higher fee rates 
\m As of 2/4/25, the going rate to complete your transaction within 30 minutes is 3 sat/vB, or	$\$0.42$ for an average transaction \pause 
\m A \textbf{``mempool''} is a pool of transactions waiting to be added to the bitcoin blockchain 
\ei 

Explore mempools at \hyperlink{https://mempool.space/}{https://mempool.space/}
    
\end{frame}


\begin{frame}
	\frametitle{Transaction Fees as \% of Block Revenue}
	
	\begin{center}
		\includegraphics[width = 0.65\textwidth]{pics/txfeespct.png}
	\end{center}
	
	Source: \href{https://www.galaxy.com/insights/research/2023-mid-year-mining/}{Galaxy} \\
        In the long run, this will go to 100\%! Why? \pause Mining rewards will reach zero, and the only incentive to mine a block will be to collect transaction fees. 
	
\end{frame}

\begin{frame}
\frametitle{Incentives}

\bi
\m A centralized authority can ``censor'', i.e. not include tx's
\m Decentralization and competition ``ensure'' performance
\bi
\m If you don't include my tx, the next miner will
\m Even if the US bans US miners from including tx's, someone else will include them
\ei
\ei

\end{frame}


\begin{frame}
\frametitle{Further Reading on Mining Industry}

\bi
\m Galaxy digital \href{https://www.galaxy.com/insights/research/2023-mid-year-mining/}{2023} and \href{https://www.galaxy.com/insights/research/2024-mid-year-mining/}{2024}
\m Cool \href{https://zhiguohe.net/wp-content/uploads/2023/12/10914-hhaa040.pdf}{paper} on mining pools
\ei

\end{frame}


\section{Ethereum}

\subsection{Smart Contracts}

\begin{frame}{Smart Contracts}

    ``A smart contract is essentially an automated agent that lives on the Ethereum network, has an Ethereum address and balance, and can send and receive transactions. A contract is "activated" every time someone sends a transaction to it, at which point it runs its code, perhaps modifying its internal state or even sending some transactions, and then shuts down.'' \\
 
-Ethereum Whitepaper, Vitalik Buterin (2014)
    
\end{frame}


\begin{frame}
\frametitle{Smart Contracts}

\bi
\m A smart contract is:
\bi
\m A \ul{wallet}, which can hold \ul{Ether (ETH)},
\m Functions it can call when requested as determined by its \ul{code},
\m (optionally) a source of \ul{data} to which it can read and write \pause 
\ei
\m If you've heard of \ul{object oriented programming}: smart contracts are a bundle of functions (code), data, as well as ETH balances \pause
\m The most popular coding language which compiles Ethereum script code (a minimal Turing-complete language akin to assembly) is called \textbf{Solidity} \pause 
\ei
Deploying a smart contract or calling its functions requires a \textbf{gas fee}: ETH must be paid to the network to run the code. 

\end{frame}

\begin{frame}
\frametitle{Smart Contract Example: Tokens}

\bi
\m An ETH address, ``technically'', only ``holds'' Ether (``ETH'') natively -- no other tokens!
\m An ETH address can be assigned non-ETH tokens through \ul{smart contracts}
\m A \ul{smart contract} can define \ul{tokens} using the \textbf{ERC-20} standard 
\bi 
\m So-called because it was originally the 20th submission to ``Ethereum Requests for Comments'' 
\ei 
\ei

\end{frame}


\begin{frame}{Unlike BTC, ETH has native gas fees}

``In Bitcoin, there are no mandatory transaction fees. Transactions can optionally include fees which are paid to miners, and it is up to the miners to decide what fees they are willing to accept. In Bitcoin, such a mechanism is already imperfect\ldots In Ethereum, because of its Turing-completeness, a purely voluntary fee system would be catastrophic. Instead, Ethereum will have a system of mandatory fees, including a transaction fee and six fees for contract computations.'' \\

-Ethereum Whitepaper, Vitalik Buterin (2014)
    
\end{frame}


\begin{frame}{Ethereum Virtual Machine Native Gas Costs}

\vfill
\begin{center}
    \href{https://www.evm.codes/}{evm.codes}
\end{center}
\vfill
    
\end{frame}

\subsection{Proof of Stake}

\begin{frame}
\frametitle{Proof of Stake}

\bi
\m Originally, ETH mining proof-of-work, similar to BTC
\m On Sept 15 2022, ETH switched to \ul{proof of stake} -- called \textbf{``The Merge''}
\m Reduced energy consumption by \textbf{over 99\%}! 
\m Users deposit (``stake'') 32 ETH into a special smart contract
\m Stakers randomly selected (prop. to stake) to propose new blocks
\m If a staker is caught trying to do ``bad things'' (e.g. propose 2 inconsistent blocks), they are ``slashed'': staked ETH is removed by smart contract
\m Most newer blockchains (SOL, LUNA, AVAX) use proof-of-stake
\ei

\end{frame}

\begin{frame}
\frametitle{Capacity of Ethereum}

\bi
\m Ethereum currently processes around \href{https://www.coinbase.com/blog/scaling-ethereum-crypto-for-a-billion-users}{15 transactions per second}
\m This is pretty bad! Visa is \href{https://crypto.com/university/blockchain-scalability}{24,000 tps}!
\bi
\m Every ETH staker has to run every transaction, and keep a copy of all data!
\ei
\m Decentralization very expensive, in terms of computational efficiency!
\m Proof-of-stake doesn't help throughput
\bi 
\m \ul{Rollups} do, which we will cover 
\ei 
\ei

\end{frame}


\section{Rollups}

\begin{frame}
\frametitle{Rollups or ``L2's''}

ETH is getting expensive! One set of solutions is \ul{rollups} (also called \ul{L2's}). Idea:
\bi
\m Put our ETH, tokens, etc. in a ``smart contract pot'' (L2 bridge)
\m People do transactions (smart contract, etc.) using funds in the pot, without doing anything on ``main chain"
\m Transactions are periodically batch settled \pause
\m Need to guarantee whatever happens on ``rollup'' is exactly what would happen on ETH main chain! Two methods:
\bi
\m \textbf{Optimistic rollup} (Optimism, Arbitrum, Coinbase Base): Can ``challenge'' L2 transactions, will (essentially) run on L1 if challenged
\m \textbf{ZK-rollup} (zkSync, StarkWare, Polygon): Some math black magic proves validity of transactions
\ei \pause
\m Industry state: 
\bi
\m \$30B locked! ETH market cap is \$408B, stables \textasciitilde\$141B
\m Optimistic rollups somewhat bigger than ZKs
\ei
\ei

\end{frame}






%------------------------------------------------


\end{document}