diff --git a/applied-hash/Makefile b/applied-hash/Makefile
new file mode 100644
index 0000000..f802a49
--- /dev/null
+++ b/applied-hash/Makefile
@@ -0,0 +1,4 @@
+SUBDIR+= fingerprinting
+
+INCLUDE_MAKEFILES?=../makefiles
+include ${INCLUDE_MAKEFILES}/subdir.mk
diff --git a/applied-hash/fingerprinting/.gitignore b/applied-hash/fingerprinting/.gitignore
new file mode 100644
index 0000000..31a3e79
--- /dev/null
+++ b/applied-hash/fingerprinting/.gitignore
@@ -0,0 +1,6 @@
+ltxobj/
+notes.pdf
+slides.pdf
+bibsp.sty
+crypto.bib
+
diff --git a/applied-hash/fingerprinting/Makefile b/applied-hash/fingerprinting/Makefile
new file mode 100644
index 0000000..c7f39a2
--- /dev/null
+++ b/applied-hash/fingerprinting/Makefile
@@ -0,0 +1,43 @@
+.PHONY: all
+all: notes.pdf slides.pdf
+
+LATEXFLAGS+= -shell-escape
+
+SRC+= preamble.tex
+SRC+= abstract.tex contents.tex
+
+DEPENDS+= bibsp.sty
+DEPENDS+= crypto.bib
+
+FIGS+= centralized.pdf
+FIGS+= p2p.pdf
+FIGS+= file-parts.pdf
+FIGS+= torrent-hashes.pdf
+FIGS+= git-objects.pdf
+FIGS+= git-commit.pdf
+FIGS+= git-challenge-1.pdf git-challenge-2.pdf
+
+notes.pdf: notes.tex
+notes.pdf: ${SRC} ${DEPENDS} $(addprefix fig/,${FIGS})
+
+slides.pdf: slides.tex
+slides.pdf: ${SRC} ${DEPENDS} $(addprefix fig/,${FIGS})
+
+
+$(addprefix fig/, ${FIGS}):
+ ${MAKE} -C $(dir $@) $(notdir $@)
+
+
+.PHONY: clean
+clean:
+ ${RM} notes.pdf slides.pdf
+
+.PHONY: distclean
+distclean:
+ ${MAKE} -C fig clean distclean
+
+
+INCLUDE_MAKEFILES=../../makefiles
+include ${INCLUDE_MAKEFILES}/tex.mk
+INCLUDE_BIBSP=../../bibsp
+include ${INCLUDE_BIBSP}/bibsp.mk
diff --git a/applied-hash/fingerprinting/abstract.tex b/applied-hash/fingerprinting/abstract.tex
new file mode 100644
index 0000000..4012d9d
--- /dev/null
+++ b/applied-hash/fingerprinting/abstract.tex
@@ -0,0 +1,22 @@
+% What's the problem?
+% Why is it a problem? Research gap left by other approaches?
+% Why is it important? Why care?
+% What's the approach? How to solve the problem?
+% What's the findings? How was it evaluated, what are the results, limitations,
+% what remains to be done?
+
+% XXX Summary
+\emph{Summary:}
+\dots
+
+% XXX Motivation and intended learning outcomes
+\emph{Intended learning outcomes:}
+\dots
+
+% XXX Prerequisites
+\emph{Prerequisites:}
+\dots
+
+% XXX Reading material
+\emph{Reading:}
+\dots
diff --git a/applied-hash/fingerprinting/contents.tex b/applied-hash/fingerprinting/contents.tex
new file mode 100644
index 0000000..bf4c934
--- /dev/null
+++ b/applied-hash/fingerprinting/contents.tex
@@ -0,0 +1,268 @@
+\mode*
+
+\input{../hash-review.tex}
+
+
+\section{Fingerprinting}
+
+\begin{frame}
+ \begin{definition}[Compressing]
+ \begin{itemize}
+ \item Function~\(f\colon \{0, 1\}^{l}\to \{0, 1\}^{l'}\)
+ \item We can have \(l > l'\).
+ \end{itemize}
+ \end{definition}
+
+ \pause
+
+ \begin{remark}
+ \begin{itemize}
+ \item Most hash functions are compressing.
+ \end{itemize}
+ \end{remark}
+\end{frame}
+
+\begin{frame}[fragile]
+ \begin{example}[Compressing]
+ \begin{itemize}
+ \begin{minted}{text}
+(1|11:27)dbosk@X1:WinDev2007Eval
+$ du WinDev2007Eval-disk001.vdi
+43G WinDev2007Eval-disk001.vdi
+(0|11:28)dbosk@X1:WinDev2007Eval
+$ sha256sum WinDev2007Eval-disk001.vdi
+5260fe9713a5b6341aca8d7e61c9cdb9bb50ee9f5f0bc15e5427a07397df9d95 WinDev2007Eval-disk001.vdi
+(0|11:32)dbosk@X1:WinDev2007Eval
+$
+ \end{minted}
+ \end{itemize}
+ \end{example}
+\end{frame}
+
+\begin{frame}
+ \begin{block}{Requirements}
+ \begin{description}
+ \item[Compressing property] to make the fingerprint small.
+ \item[Collision resistance] to reduce likelihood of collisions.
+ \end{description}
+ \end{block}
+\end{frame}
+
+\subsection{BitTorrent}
+
+\begin{frame}
+ \begin{figure}
+ \begin{subfigure}{0.45\columnwidth}
+ \centering
+ \includegraphics[width=\columnwidth]{fig/centralized.pdf}
+ \caption{Centralized}
+ \end{subfigure}
+ \hfill
+ \begin{subfigure}{0.45\columnwidth}
+ \centering
+ \includegraphics[width=\columnwidth]{fig/p2p.pdf}
+ \caption{Peer-to-peer (P2P)}
+ \end{subfigure}
+ \end{figure}
+\end{frame}
+
+\begin{frame}
+ \begin{figure}
+ \begin{subfigure}{0.45\columnwidth}
+ \centering
+ \includegraphics[height=0.4\textheight]{fig/centralized.pdf}
+ \caption{Centralized}
+ \end{subfigure}
+ \hfill
+ \begin{subfigure}{0.45\columnwidth}
+ \centering
+ \includegraphics[height=0.4\textheight]{fig/p2p.pdf}
+ \caption{Peer-to-peer (P2P)}
+ \end{subfigure}
+ \end{figure}
+
+ \begin{question}
+ \begin{itemize}
+ \item How to get most out of the P2P case?
+ \end{itemize}
+ \end{question}
+\end{frame}
+
+\begin{frame}
+ \begin{figure}
+ \begin{subfigure}{0.45\columnwidth}
+ \centering
+ \includegraphics[height=0.5\textheight]{fig/p2p.pdf}
+ \caption{Peer-to-peer (P2P)}
+ \end{subfigure}
+ \hfill
+ \begin{subfigure}{0.45\columnwidth}
+ \only<1>{%
+ \centering
+ \includegraphics[width=\columnwidth]{fig/file-parts.pdf}
+ \caption{File divided into parts}
+ }
+ \only<2>{%
+ \centering
+ \includegraphics[width=\columnwidth]{fig/torrent-hashes.pdf}
+ \caption{Hash values of file and parts}
+ }
+ \end{subfigure}
+ \end{figure}
+
+ \begin{solution}
+ \begin{itemize}
+ \item Must keep track of different parts of a file.
+ \end{itemize}
+ \end{solution}
+\end{frame}
+
+\begin{frame}
+ \begin{remark}
+ \begin{itemize}
+ \item We want a cryptographic hash function if we want authenticity
+ properties.
+ \item Will a malicious actor inject fake parts of files?
+ \item Authenticated torrent file gives authenticated file.
+ \end{itemize}
+ \end{remark}
+\end{frame}
+
+
+\subsection{Git}
+
+\begin{frame}
+ \begin{remark}
+ \begin{itemize}
+ \item Git is a content-addressable file system.
+ \end{itemize}
+ \end{remark}
+
+ \pause
+
+ \begin{definition}[Git blob {[binary large object]}]
+ \begin{itemize}
+ \item Name is hash value of content and a header.
+ \item Content is just the content.
+ \end{itemize}
+ \end{definition}
+\end{frame}
+
+\begin{frame}
+ \begin{figure}
+ \centering
+ \includegraphics[height=0.8\textheight]{fig/git-objects.pdf}
+ \caption{Git objects with hashes \texttt{deadbeef}, \texttt{deadcode},
+ \texttt{oobab1oc}, \texttt{000ff1ce}.}
+ \end{figure}
+\end{frame}
+
+\begin{frame}
+ \begin{remark}
+ \begin{itemize}
+ \item Blobs don't store file names etc., just content.
+ \item Tree objects solve the problem of storing the filename.
+ \item Also allow you to store a group of files together.
+ \end{itemize}
+ \end{remark}
+
+ \pause
+
+ \begin{definition}[Tree object]
+ \begin{itemize}
+ \item Blob with structured content:
+ \item file mode
+ \item type (blob, tree \etc)
+ \item human readable name
+ \end{itemize}
+ \end{definition}
+\end{frame}
+
+\begin{frame}
+ \begin{figure}
+ \centering
+ \includegraphics[height=0.8\textheight]{fig/git-objects.pdf}
+ \caption{Tree objects with hashes \texttt{oobab1oc}, \texttt{000ff1ce}.}
+ \end{figure}
+\end{frame}
+
+\begin{frame}
+ \begin{remark}
+ \begin{itemize}
+ \item A tree doesn't keep track of versions.
+ \end{itemize}
+ \end{remark}
+
+ \begin{definition}[Commit]
+ \begin{itemize}
+ \item Tree (current state)
+ \item Parent commits
+ \item Author
+ \item Commit log
+ \end{itemize}
+ \end{definition}
+\end{frame}
+
+\begin{frame}
+ \begin{figure}
+ \includegraphics[height=0.8\textheight]{fig/git-commit.pdf}
+ \caption{A commit \texttt{feedc0de}.}
+ \end{figure}
+\end{frame}
+
+\begin{frame}
+ \begin{exercise}
+ \begin{columns}
+ \begin{column}{0.40\columnwidth}
+ \begin{figure}
+ \includegraphics[height=0.6\textheight]{fig/git-challenge-2.pdf}
+ \caption{Some Git objects.}
+ \end{figure}
+ \end{column}
+ \begin{column}{0.45\columnwidth}
+ \begin{itemize}
+ \item What happened if the initial commit is \texttt{00bab10c}?
+ \end{itemize}
+ \end{column}
+ \end{columns}
+ \end{exercise}
+\end{frame}
+
+%\begin{frame}
+% \begin{exercise}
+% \begin{columns}
+% \begin{column}{0.40\columnwidth}
+% \begin{figure}
+% \includegraphics[height=0.6\textheight]{fig/git-challenge-1.pdf}
+% \caption{Some Git objects.}
+% \end{figure}
+% \end{column}
+% \begin{column}{0.45\columnwidth}
+% \begin{itemize}
+% \item What happened if the initial commit is \texttt{c00010ff}?
+% \end{itemize}
+% \end{column}
+% \end{columns}
+% \end{exercise}
+%\end{frame}
+
+\begin{frame}
+ \begin{exercise}
+ \begin{itemize}
+ \item What properties do we want from the hash function?
+ \end{itemize}
+ \end{exercise}
+\end{frame}
+
+\begin{frame}
+ \begin{solution}
+ \begin{itemize}
+ \item Compression (short identifiers)
+ \item Collision resistance:
+ \begin{itemize}
+ \item Cryptographic: in case we want authentication.
+ \item Otherwise, just to avoid two different objects colliding.
+ \end{itemize}
+ \end{itemize}
+ \end{solution}
+\end{frame}
diff --git a/applied-hash/fingerprinting/fig/.gitignore b/applied-hash/fingerprinting/fig/.gitignore
new file mode 100644
index 0000000..1034c98
--- /dev/null
+++ b/applied-hash/fingerprinting/fig/.gitignore
@@ -0,0 +1,16 @@
+centralized.pdf
+centralized.pdf_tex
+file-parts.pdf
+file-parts.pdf_tex
+git-challenge-1.pdf
+git-challenge-1.pdf_tex
+git-challenge-2.pdf
+git-challenge-2.pdf_tex
+git-commit.pdf
+git-commit.pdf_tex
+git-objects.pdf
+git-objects.pdf_tex
+p2p.pdf
+p2p.pdf_tex
+torrent-hashes.pdf
+torrent-hashes.pdf_tex
diff --git a/applied-hash/fingerprinting/fig/Makefile b/applied-hash/fingerprinting/fig/Makefile
new file mode 100644
index 0000000..5627300
--- /dev/null
+++ b/applied-hash/fingerprinting/fig/Makefile
@@ -0,0 +1,25 @@
+.PHONY: all
+all: centralized.pdf p2p.pdf
+all: file-parts.pdf torrent-hashes.pdf
+all: merkle-tree.pdf
+all: git-commit.pdf
+all: git-objects.pdf
+all: git-challenge-1.pdf
+all: git-challenge-2.pdf
+
+
+.PHONY: clean
+clean:
+ ${RM} centralized.pdf p2p.pdf
+ ${RM} centralized.pdf_tex p2p.pdf_tex
+ ${RM} file-parts.pdf torrent-hashes.pdf
+ ${RM} file-parts.pdf_tex torrent-hashes.pdf_tex
+ ${RM} merkle-tree.pdf merkle-tree.pdf_tex
+ ${RM} git-commit.pdf git-commit.pdf_tex
+ ${RM} git-objects.pdf git-objects.pdf_tex
+ ${RM} git-challenge-1.pdf git-challenge-1.pdf_tex
+ ${RM} git-challenge-2.pdf git-challenge-2.pdf_tex
+
+
+INCLUDE_MAKEFILES=../../../makefiles
+include ${INCLUDE_MAKEFILES}/doc.mk
diff --git a/applied-hash/fingerprinting/fig/centralized.svg b/applied-hash/fingerprinting/fig/centralized.svg
new file mode 100644
index 0000000..8df136d
--- /dev/null
+++ b/applied-hash/fingerprinting/fig/centralized.svg
@@ -0,0 +1,109 @@
+
+
diff --git a/applied-hash/fingerprinting/fig/file-parts.svg b/applied-hash/fingerprinting/fig/file-parts.svg
new file mode 100644
index 0000000..a3b8524
--- /dev/null
+++ b/applied-hash/fingerprinting/fig/file-parts.svg
@@ -0,0 +1,663 @@
+
+
diff --git a/applied-hash/fingerprinting/fig/git-challenge-1.svg b/applied-hash/fingerprinting/fig/git-challenge-1.svg
new file mode 100644
index 0000000..c0c1b76
--- /dev/null
+++ b/applied-hash/fingerprinting/fig/git-challenge-1.svg
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/applied-hash/fingerprinting/fig/git-challenge-2.svg b/applied-hash/fingerprinting/fig/git-challenge-2.svg
new file mode 100644
index 0000000..0b80aa8
--- /dev/null
+++ b/applied-hash/fingerprinting/fig/git-challenge-2.svg
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/applied-hash/fingerprinting/fig/git-commit.svg b/applied-hash/fingerprinting/fig/git-commit.svg
new file mode 100644
index 0000000..c5eae8b
--- /dev/null
+++ b/applied-hash/fingerprinting/fig/git-commit.svg
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/applied-hash/fingerprinting/fig/git-objects.svg b/applied-hash/fingerprinting/fig/git-objects.svg
new file mode 100644
index 0000000..28906d7
--- /dev/null
+++ b/applied-hash/fingerprinting/fig/git-objects.svg
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/applied-hash/fingerprinting/fig/merkle-tree.png b/applied-hash/fingerprinting/fig/merkle-tree.png
new file mode 100644
index 0000000..4572da1
Binary files /dev/null and b/applied-hash/fingerprinting/fig/merkle-tree.png differ
diff --git a/applied-hash/fingerprinting/fig/p2p.svg b/applied-hash/fingerprinting/fig/p2p.svg
new file mode 100644
index 0000000..70da774
--- /dev/null
+++ b/applied-hash/fingerprinting/fig/p2p.svg
@@ -0,0 +1,234 @@
+
+
diff --git a/applied-hash/fingerprinting/fig/torrent-hashes.svg b/applied-hash/fingerprinting/fig/torrent-hashes.svg
new file mode 100644
index 0000000..4942cc7
--- /dev/null
+++ b/applied-hash/fingerprinting/fig/torrent-hashes.svg
@@ -0,0 +1,608 @@
+
+
diff --git a/applied-hash/fingerprinting/notes.tex b/applied-hash/fingerprinting/notes.tex
new file mode 100644
index 0000000..f6e9ab4
--- /dev/null
+++ b/applied-hash/fingerprinting/notes.tex
@@ -0,0 +1,45 @@
+\documentclass{article}
+
+\usepackage[hyphens]{url}
+\usepackage[hidelinks]{hyperref}
+
+\input{preamble.tex}
+
+\usepackage[noamsthm,notheorems]{beamerarticle}
+\setjobnamebeamerversion{slides}
+
+%\usepackage{authblk}
+%\let\institute\affil
+
+\declaretheorem[numbered=unless unique,style=theorem]{theorem}
+\declaretheorem[numbered=unless unique,style=definition]{definition}
+\declaretheorem[numbered=unless unique,style=definition]{assumption}
+\declaretheorem[numbered=unless unique,style=definition]{protocol}
+\declaretheorem[numbered=unless unique,style=example]{example}
+%\declaretheorem[style=definition,numbered=unless unique,
+% name=Example,refname={example,examples}]{example}
+\declaretheorem[numbered=unless unique,style=remark]{remark}
+\declaretheorem[numbered=unless unique,style=remark]{idea}
+\declaretheorem[numbered=unless unique,style=exercise]{exercise}
+\declaretheorem[numbered=unless unique,style=exercise]{question}
+\declaretheorem[numbered=unless unique,style=solution]{solution}
+
+\begin{document}
+\title{%
+ Applied Hash Functions: Fingerprinting
+}
+\author{Daniel Bosk}
+\institute{%
+ KTH EECS
+}
+
+\maketitle
+
+\begin{abstract}
+ \input{abstract.tex}
+\end{abstract}
+
+\input{contents.tex}
+
+\printbibliography
+\end{document}
diff --git a/applied-hash/fingerprinting/preamble.tex b/applied-hash/fingerprinting/preamble.tex
new file mode 100644
index 0000000..ec61d2a
--- /dev/null
+++ b/applied-hash/fingerprinting/preamble.tex
@@ -0,0 +1,39 @@
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage[british]{babel}
+\usepackage{booktabs}
+
+\usepackage[all]{foreign}
+\renewcommand{\foreignfullfont}{}
+\renewcommand{\foreignabbrfont}{}
+
+\usepackage{newclude}
+\usepackage{import}
+
+\usepackage[strict]{csquotes}
+\usepackage[single]{acro}
+
+\usepackage[natbib,style=alphabetic,maxbibnames=99]{biblatex}
+\addbibresource{crypto.bib}
+
+\usepackage{subcaption}
+
+\usepackage[noend]{algpseudocode}
+\usepackage{xparse}
+
+\let\email\texttt
+
+\usepackage[outputdir=ltxobj]{minted}
+\setminted{autogobble,fontsize=\footnotesize}
+
+\usepackage{amsmath}
+\usepackage{amssymb}
+\usepackage{mathtools}
+\usepackage{amsthm}
+\usepackage{thmtools}
+\usepackage[unq]{unique}
+\DeclareMathOperator{\powerset}{\mathcal{P}}
+
+\usepackage[binary-units]{siunitx}
+
+\usepackage{bibsp}
diff --git a/applied-hash/fingerprinting/slides.tex b/applied-hash/fingerprinting/slides.tex
new file mode 100644
index 0000000..359c1d8
--- /dev/null
+++ b/applied-hash/fingerprinting/slides.tex
@@ -0,0 +1,118 @@
+\documentclass[ignoreframetext]{beamer}
+\input{preamble.tex}
+
+\usetheme{Berlin}
+\setbeamertemplate{footline}%{miniframes theme}
+{%
+ \begin{beamercolorbox}[colsep=1.5pt]{upper separation line foot}
+ \end{beamercolorbox}
+ \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
+ leftskip=.3cm,rightskip=.3cm plus1fil]{author in head/foot}%
+ \leavevmode{\usebeamerfont{author in head/foot}\insertshortauthor}%
+ \hfill%
+ {\usebeamerfont{institute in head/foot}\usebeamercolor[fg]{institute in head/foot}\insertshortinstitute}%
+ \end{beamercolorbox}%
+ \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
+ leftskip=.3cm,rightskip=.3cm plus1fil]{title in head/foot}%
+ {\usebeamerfont{title in head/foot}\insertshorttitle} \hfill \insertframenumber%
+ \end{beamercolorbox}%
+ \begin{beamercolorbox}[colsep=1.5pt]{lower separation line foot}
+ \end{beamercolorbox}
+}
+\setbeamercovered{transparent}
+\setbeamertemplate{bibliography item}[text]
+
+\AtBeginSection[]{%
+ \begin{frame}
+ \tableofcontents[currentsection]
+ \end{frame}
+}
+
+\ProvideDocumentEnvironment{assumption}{o}{%
+ \IfValueTF{#1}{%
+ \begin{block}{Assumption: #1}
+ }{%
+ \begin{block}{Assumption}
+ }
+}{%
+ \end{block}
+}
+
+\ProvideDocumentEnvironment{protocol}{o}{%
+ \IfValueTF{#1}{%
+ \begin{block}{Protocol: #1}
+ }{%
+ \begin{block}{Protocol}
+ }
+}{%
+ \end{block}
+}
+
+\ProvideDocumentEnvironment{remark}{o}{%
+ \IfValueTF{#1}{%
+ \begin{alertblock}{Note: #1}
+ }{%
+ \begin{alertblock}{Note}
+ }
+}{%
+ \end{alertblock}
+}
+
+\ProvideDocumentEnvironment{idea}{o}{%
+ \IfValueTF{#1}{%
+ \begin{block}{Idea: #1}
+ }{%
+ \begin{block}{Idea}
+ }
+}{%
+ \end{block}
+}
+
+\ProvideDocumentEnvironment{question}{o}{%
+ \setbeamercolor{block body}{bg=orange!15,fg=black}
+ \setbeamercolor{block title}{bg=orange,fg=white}
+ \setbeamercolor{local structure}{fg=orange}
+ \IfValueTF{#1}{%
+ \begin{block}{Question: #1}
+ }{%
+ \begin{block}{Question}
+ }
+}{%
+ \end{block}
+}
+
+\ProvideDocumentEnvironment{exercise}{o}{%
+ \setbeamercolor{block body}{bg=yellow!10,fg=black}
+ \setbeamercolor{block title}{bg=yellow,fg=black}
+ \setbeamercolor{local structure}{fg=yellow}
+ \IfValueTF{#1}{%
+ \begin{block}{Exercise: #1}
+ }{%
+ \begin{block}{Exercise}
+ }
+}{%
+ \end{block}
+}
+
+
+\begin{document}
+\title{%
+ Applied Hash Functions: Fingerprinting
+}
+\author{Daniel Bosk}
+\institute{%
+ KTH EECS
+}
+
+\begin{frame}
+ \maketitle
+\end{frame}
+
+\mode
+\input{contents.tex}
+\mode*
+
+\begin{frame}[allowframebreaks]
+ \printbibliography
+\end{frame}
+\end{document}
diff --git a/applied-hash/hash-review.tex b/applied-hash/hash-review.tex
new file mode 100644
index 0000000..8fd39c9
--- /dev/null
+++ b/applied-hash/hash-review.tex
@@ -0,0 +1,43 @@
+\mode*
+
+\section[Hash functions]{What was a hash function now again?}
+
+\begin{frame}
+ \begin{definition}[One-way function\footfullcite{GoldreichFOC-1}]
+ \begin{itemize}
+ \item Let \(h\colon \{0,1\}^*\to \{0,1\}^*\).
+ \item \(h\) is \emph{one-way} if
+ \begin{enumerate}
+ \item there exists an efficient algorithm \(A\) such that \(A(x)
+ = h(x)\);
+ \item for every efficient algorithm \(A^\prime\), every positive
+ polynomial \(p(\cdot)\) and all sufficiently large \(n\)'s
+ \[\Prob{A^\prime(h(x), 1^n) \in h^{-1}(h(x))} < \frac{1}{p(n)}\]
+ \end{enumerate}
+ \end{itemize}
+ \end{definition}
+\end{frame}
+
+\begin{frame}
+ \begin{definition}[Preimage resistance {[one way]}]
+ \begin{description}
+ \item[Input] hash function~\(H\), value~\(y\).
+ \item[Output] Any \(x\) such that \(H(x) = y\).
+ \end{description}
+ \end{definition}
+
+ \begin{definition}[Second preimage resistance {[weak collision resistance]}]
+ \begin{description}
+ \item[Input] hash function~\(H\), value \(x\).
+ \item[Output] Any value \(x'\) such that \(H(x) = H(x')\).
+ \end{description}
+ \end{definition}
+
+ \begin{definition}[Collision resistance {[strong collision resistance]}]
+ \begin{description}
+ \item[Input] hash function~\(H\).
+ \item[Output] Any two \(x, x'\) such that \(H(x) = H(x')\).
+ \end{description}
+ \end{definition}
+\end{frame}
+
diff --git a/applied-hash/passwords/.gitignore b/applied-hash/passwords/.gitignore
new file mode 100644
index 0000000..31a3e79
--- /dev/null
+++ b/applied-hash/passwords/.gitignore
@@ -0,0 +1,6 @@
+ltxobj/
+notes.pdf
+slides.pdf
+bibsp.sty
+crypto.bib
+
diff --git a/applied-hash/passwords/Makefile b/applied-hash/passwords/Makefile
new file mode 100644
index 0000000..3c1f14b
--- /dev/null
+++ b/applied-hash/passwords/Makefile
@@ -0,0 +1,37 @@
+.PHONY: all
+all: notes.pdf slides.pdf
+
+LATEXFLAGS+= -shell-escape
+
+SRC+= preamble.tex
+SRC+= abstract.tex contents.tex
+
+DEPENDS+= bibsp.sty
+DEPENDS+= crypto.bib
+
+FIGS+=
+
+notes.pdf: notes.tex
+notes.pdf: ${SRC} ${DEPENDS} $(addprefix fig/,${FIGS})
+
+slides.pdf: slides.tex
+slides.pdf: ${SRC} ${DEPENDS} $(addprefix fig/,${FIGS})
+
+
+$(addprefix fig/, ${FIGS}):
+ ${MAKE} -C $(dir $@) $(notdir $@)
+
+
+.PHONY: clean
+clean:
+ ${RM} notes.pdf slides.pdf
+
+.PHONY: distclean
+distclean:
+ ${MAKE} -C fig clean
+
+
+INCLUDE_MAKEFILES=../../makefiles
+include ${INCLUDE_MAKEFILES}/tex.mk
+INCLUDE_BIBSP=../../bibsp
+include ${INCLUDE_BIBSP}/bibsp.mk
diff --git a/applied-hash/passwords/abstract.tex b/applied-hash/passwords/abstract.tex
new file mode 100644
index 0000000..4012d9d
--- /dev/null
+++ b/applied-hash/passwords/abstract.tex
@@ -0,0 +1,22 @@
+% What's the problem?
+% Why is it a problem? Research gap left by other approaches?
+% Why is it important? Why care?
+% What's the approach? How to solve the problem?
+% What's the findings? How was it evaluated, what are the results, limitations,
+% what remains to be done?
+
+% XXX Summary
+\emph{Summary:}
+\dots
+
+% XXX Motivation and intended learning outcomes
+\emph{Intended learning outcomes:}
+\dots
+
+% XXX Prerequisites
+\emph{Prerequisites:}
+\dots
+
+% XXX Reading material
+\emph{Reading:}
+\dots
diff --git a/applied-hash/passwords/contents.tex b/applied-hash/passwords/contents.tex
new file mode 100644
index 0000000..a2cdae5
--- /dev/null
+++ b/applied-hash/passwords/contents.tex
@@ -0,0 +1,207 @@
+\mode*
+
+\mode{\input{../hash-review.tex}}
+
+
+\section{Something you know}
+
+\subsection{\enquote{Proof of knowledge}}
+
+\begin{frame}
+ \begin{idea}[Something you know]
+ \begin{itemize}
+ \item We have a prover and a verifier.
+ \item Prover must convince verifier he knows some
+ secret.
+ \end{itemize}
+ \end{idea}
+
+ \begin{idea}[Password]
+ \begin{itemize}
+ \item Prover and verifier shares a secret value.
+
+ \item Prover tells verifier the value to convince the verifier.
+ \end{itemize}
+ \end{idea}
+\end{frame}
+
+\begin{frame}
+ \begin{remark}
+ \begin{itemize}
+ \item If the adversary learns the secret, he can convince the verifier he
+ is the prover.
+ \end{itemize}
+ \end{remark}
+
+ \begin{example}
+ \begin{itemize}
+ \item Adversary might \enquote{overhear the conversation}.
+ \item Adversary might \enquote{trick} the prover to reveal the secret.
+ \item Adversary might guess the secret.
+ \end{itemize}
+ \end{example}
+\end{frame}
+
+\subsection{Online or offline guessing?}
+
+\begin{frame}
+ \begin{definition}[Online]
+ \begin{itemize}
+ \item The adversary must interact with the system for each guess.
+ \end{itemize}
+ \end{definition}
+
+ \pause
+
+ \begin{example}[Online]
+ \begin{itemize}
+ \item Guessing the password of a Google account.
+ \item Must submit each guess to Google.
+ \end{itemize}
+ \end{example}
+\end{frame}
+
+\begin{frame}
+ \begin{definition}[Offline]
+ \begin{itemize}
+ \item The adversary can verify the guess himself.
+ \end{itemize}
+ \end{definition}
+
+ \pause
+
+ \begin{example}[Offline]
+ \begin{itemize}
+ \item Guessing the password of an encrypted file.
+ \item For each guess, try to decrypt.
+ \end{itemize}
+ \end{example}
+
+ \begin{example}[Offline]
+ \begin{itemize}
+ \item Guessing the password corresponding to a hash.
+ \item For each guess, hash and compare the result.
+ \end{itemize}
+ \end{example}
+\end{frame}
+
+\subsection{Storing secrets}
+
+\begin{frame}
+ \begin{remark}
+ \begin{itemize}
+ \item The user can store the secret in its mind.
+ \item This is assumed inaccessible (for now).
+ \end{itemize}
+ \end{remark}
+
+ \pause
+
+ \begin{question}
+ \begin{itemize}
+ \item The verifier is a machine.
+ \item The verifier must verify what the prover says.
+ \item This means that the verifier must have some data to check against.
+ \item How should this be stored?
+ \end{itemize}
+ \end{question}
+\end{frame}
+
+\begin{frame}
+ \begin{remark}
+ \begin{itemize}
+ \item Our concern is that someone can read this data.
+ \item Password reuse for other services?
+ \end{itemize}
+ \end{remark}
+\end{frame}
+
+\begin{frame}
+ \begin{idea}[Password hashes]
+ \begin{itemize}
+ \item We want to compare user-entered and stored password.
+ \item We do an irreversible one-way transformation on both.
+ \item Then they are still comparable.
+ \item The preimage cannot be gained from storage.
+ \end{itemize}
+ \end{idea}
+
+ \pause{}
+
+ \begin{example}
+ \begin{itemize}
+ \item Cryptographic hash function \(h\colon \bin^*\to \bin^n\).
+ \item On registration, store \(y = h(p)\).
+ \item User authenticates with \(p'\), check if \(h(p') \stackrel{?}{=}
+ y\) equals what we stored.
+ \end{itemize}
+ \end{example}
+\end{frame}
+
+\begin{frame}
+ \begin{remark}
+ \begin{itemize}
+ \item Consider guessing again.
+ \item The used password space is small.
+ \item We only need to evaluate a subset: \(h\colon
+ \bin^{\color{red}{m}}\to \bin^n\).
+ \item With faster computers we can guess a lot.
+ \end{itemize}
+ \end{remark}
+
+ \pause
+
+ \begin{solution}
+ \begin{itemize}
+ \item Choose \(h\) to be slow to compute.
+ \item \Eg iterate it over itself 10\,000 times (\(h^{10000}(p)\)).
+ \item This will slow down guessing attacks.
+ \end{itemize}
+ \end{solution}
+\end{frame}
+
+\begin{frame}
+ \begin{remark}
+ \begin{itemize}
+ \item A list of password hashes reveals if two users have the same
+ password.
+ \item Can guess the password for all users at once:
+ \begin{enumerate}
+ \item Make a guess, compute the hash.
+ \item Check if it matches \emph{any} user's password.
+ \end{enumerate}
+ \end{itemize}
+ \end{remark}
+
+ \pause
+
+ \begin{solution}
+ \begin{itemize}
+ \item Add a \emph{salt}: a small random value (\eg 128 bits) unique for
+ each user.
+ \item Salt~\(s\rgets \bin^{128}\), change hash to \(h(s, p)\).
+ \item Now all hashes will be unique.
+ \end{itemize}
+ \end{solution}
+\end{frame}
+
+\begin{frame}
+ \begin{remark}
+ \begin{itemize}
+ \item The salt is not a secret, it just adds uniqueness.
+ \item It can be stored in plain text along with the password hash.
+ \end{itemize}
+ \end{remark}
+\end{frame}
+
+\begin{frame}
+ \begin{example}
+ \begin{itemize}
+ \item There are many libraries.
+ \item bcrypt~\cite{bcrypt} implements all this functionality.
+ \item Argon2 is another, more recent technique.
+ \item They should also be available in most languages and libraries.
+ \end{itemize}
+ \end{example}
+\end{frame}
+
diff --git a/applied-hash/passwords/fig/Makefile b/applied-hash/passwords/fig/Makefile
new file mode 100644
index 0000000..d2d980e
--- /dev/null
+++ b/applied-hash/passwords/fig/Makefile
@@ -0,0 +1,11 @@
+.PHONY: all
+all:
+
+
+.PHONY: clean
+clean:
+ true
+
+
+INCLUDE_MAKEFILES=../../../makefiles
+include ${INCLUDE_MAKEFILES}/doc.mk
diff --git a/applied-hash/passwords/notes.tex b/applied-hash/passwords/notes.tex
new file mode 100644
index 0000000..df44d84
--- /dev/null
+++ b/applied-hash/passwords/notes.tex
@@ -0,0 +1,45 @@
+\documentclass{article}
+
+\usepackage[hyphens]{url}
+\usepackage[hidelinks]{hyperref}
+
+\input{preamble.tex}
+
+\usepackage[noamsthm,notheorems]{beamerarticle}
+\setjobnamebeamerversion{slides}
+
+%\usepackage{authblk}
+%\let\institute\affil
+
+\declaretheorem[numbered=unless unique,style=theorem]{theorem}
+\declaretheorem[numbered=unless unique,style=definition]{definition}
+\declaretheorem[numbered=unless unique,style=definition]{assumption}
+\declaretheorem[numbered=unless unique,style=definition]{protocol}
+\declaretheorem[numbered=unless unique,style=example]{example}
+%\declaretheorem[style=definition,numbered=unless unique,
+% name=Example,refname={example,examples}]{example}
+\declaretheorem[numbered=unless unique,style=remark]{remark}
+\declaretheorem[numbered=unless unique,style=remark]{idea}
+\declaretheorem[numbered=unless unique,style=exercise]{exercise}
+\declaretheorem[numbered=unless unique,style=exercise]{question}
+\declaretheorem[numbered=unless unique,style=solution]{solution}
+
+\begin{document}
+\title{%
+ Applied Hash Functions: Passwords
+}
+\author{Daniel Bosk}
+\institute{%
+ KTH EECS
+}
+
+\maketitle
+
+\begin{abstract}
+ \input{abstract.tex}
+\end{abstract}
+
+\input{contents.tex}
+
+\printbibliography
+\end{document}
diff --git a/applied-hash/passwords/preamble.tex b/applied-hash/passwords/preamble.tex
new file mode 100644
index 0000000..c7f0731
--- /dev/null
+++ b/applied-hash/passwords/preamble.tex
@@ -0,0 +1,39 @@
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage[british]{babel}
+\usepackage{booktabs}
+
+\usepackage[natbib,style=alphabetic,maxbibnames=99]{biblatex}
+\addbibresource{crypto.bib}
+
+\usepackage[all]{foreign}
+\renewcommand{\foreignfullfont}{}
+\renewcommand{\foreignabbrfont}{}
+
+\usepackage{newclude}
+\usepackage{import}
+
+\usepackage[strict]{csquotes}
+\usepackage[single]{acro}
+
+\usepackage{subcaption}
+
+\usepackage[noend]{algpseudocode}
+\usepackage{xparse}
+
+\let\email\texttt
+
+\usepackage[outputdir=ltxobj]{minted}
+\setminted{autogobble,fontsize=\footnotesize}
+
+\usepackage{amsmath}
+\usepackage{amssymb}
+\usepackage{mathtools}
+\usepackage{amsthm}
+\usepackage{thmtools}
+\usepackage[unq]{unique}
+\DeclareMathOperator{\powerset}{\mathcal{P}}
+
+\usepackage[binary-units]{siunitx}
+
+\usepackage{bibsp}
diff --git a/applied-hash/passwords/slides.tex b/applied-hash/passwords/slides.tex
new file mode 100644
index 0000000..3ef5207
--- /dev/null
+++ b/applied-hash/passwords/slides.tex
@@ -0,0 +1,118 @@
+\documentclass[ignoreframetext]{beamer}
+\input{preamble.tex}
+
+\usetheme{Berlin}
+\setbeamertemplate{footline}%{miniframes theme}
+{%
+ \begin{beamercolorbox}[colsep=1.5pt]{upper separation line foot}
+ \end{beamercolorbox}
+ \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
+ leftskip=.3cm,rightskip=.3cm plus1fil]{author in head/foot}%
+ \leavevmode{\usebeamerfont{author in head/foot}\insertshortauthor}%
+ \hfill%
+ {\usebeamerfont{institute in head/foot}\usebeamercolor[fg]{institute in head/foot}\insertshortinstitute}%
+ \end{beamercolorbox}%
+ \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
+ leftskip=.3cm,rightskip=.3cm plus1fil]{title in head/foot}%
+ {\usebeamerfont{title in head/foot}\insertshorttitle} \hfill \insertframenumber%
+ \end{beamercolorbox}%
+ \begin{beamercolorbox}[colsep=1.5pt]{lower separation line foot}
+ \end{beamercolorbox}
+}
+\setbeamercovered{transparent}
+\setbeamertemplate{bibliography item}[text]
+
+\AtBeginSection[]{%
+ \begin{frame}
+ \tableofcontents[currentsection]
+ \end{frame}
+}
+
+\ProvideDocumentEnvironment{assumption}{o}{%
+ \IfValueTF{#1}{%
+ \begin{block}{Assumption: #1}
+ }{%
+ \begin{block}{Assumption}
+ }
+}{%
+ \end{block}
+}
+
+\ProvideDocumentEnvironment{protocol}{o}{%
+ \IfValueTF{#1}{%
+ \begin{block}{Protocol: #1}
+ }{%
+ \begin{block}{Protocol}
+ }
+}{%
+ \end{block}
+}
+
+\ProvideDocumentEnvironment{remark}{o}{%
+ \IfValueTF{#1}{%
+ \begin{alertblock}{Note: #1}
+ }{%
+ \begin{alertblock}{Note}
+ }
+}{%
+ \end{alertblock}
+}
+
+\ProvideDocumentEnvironment{idea}{o}{%
+ \IfValueTF{#1}{%
+ \begin{block}{Idea: #1}
+ }{%
+ \begin{block}{Idea}
+ }
+}{%
+ \end{block}
+}
+
+\ProvideDocumentEnvironment{question}{o}{%
+ \setbeamercolor{block body}{bg=orange!15,fg=black}
+ \setbeamercolor{block title}{bg=orange,fg=white}
+ \setbeamercolor{local structure}{fg=orange}
+ \IfValueTF{#1}{%
+ \begin{block}{Question: #1}
+ }{%
+ \begin{block}{Question}
+ }
+}{%
+ \end{block}
+}
+
+\ProvideDocumentEnvironment{exercise}{o}{%
+ \setbeamercolor{block body}{bg=yellow!10,fg=black}
+ \setbeamercolor{block title}{bg=yellow,fg=black}
+ \setbeamercolor{local structure}{fg=yellow}
+ \IfValueTF{#1}{%
+ \begin{block}{Exercise: #1}
+ }{%
+ \begin{block}{Exercise}
+ }
+}{%
+ \end{block}
+}
+
+
+\begin{document}
+\title{%
+ Applied Hash Functions: Passwords
+}
+\author{Daniel Bosk}
+\institute{%
+ KTH EECS
+}
+
+\begin{frame}
+ \maketitle
+\end{frame}
+
+\mode
+\input{contents.tex}
+\mode*
+
+\begin{frame}[allowframebreaks]
+ \printbibliography
+\end{frame}
+\end{document}