Skip to content

Commit

Permalink
add b&w versions; cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nglaeser committed Jun 25, 2022
1 parent 40fb2f5 commit c70d813
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 44 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ __pycache__
# Other
images/
spring/ShamirSS-centered.ipynb
spring/plot_examples.ipynb
spring/plot_examples.ipynb
*comments*
6 changes: 3 additions & 3 deletions packet/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Packet: Cryptographic Secret Sharing
*[Girls Talk Math Camp 2021](http://gtm.math.umd.edu/virtualcamp2021.html) at UMD*

- **Packet** [[source](main.tex) | [.pdf](main.pdf)]: General outline of the file stolen from [this other GTM packet](https://github.com/Girls-Talk-Math/curriculum/tree/master/RSA-Encryption-Cryptography).
- **Answers** [[source](answers.tex) | [.pdf](answers.pdf)]
- **Jupyter Notebook** [[source](../spring/ShamirSS.ipynb) | [CoLab](https://colab.research.google.com/drive/18NxRFaAb3H65EaUUPwlHN7pQFXYvsy6n?usp=sharing)]: Jupyter notebook for interactive portion; currently links to the spring event version.
- **[Packet](main.pdf)** ([source](main.tex)). Black-and-white version [here](main-bw.pdf).
- **[Answers](answers.pdf)** ([source](answers.tex)). Black-and-white version [here](answers-bw.pdf).
- **[Jupyter Notebook](https://colab.research.google.com/drive/18NxRFaAb3H65EaUUPwlHN7pQFXYvsy6n?usp=sharing)** ([source](../spring/ShamirSS.ipynb)): Jupyter notebook for interactive portion; currently links to the spring event version.
49 changes: 39 additions & 10 deletions packet/ans/shamir.tex
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,64 @@ \subsection{Polynomials}
ymax=8.5,
grid,
]
\ifbw
%%% BLACK-AND-WHITE VERSION %%%
% part a
\node [magenta] (point-a1) at (axis cs: 3,2) {\textbullet};
\node (point-a1) at (axis cs: 3,2) {$\star$};
\addplot[domain=-1.5:5.5,samples=50,mark=none,dashed]{-2*x+8};
\addplot[domain=-1.5:5.5,samples=50,mark=none,dashed]{.33*x+1};
% part b
\node (point-b1) at (axis cs: 0,0) {$\diamond$};
\node (point-b2) at (axis cs: 2,2) {$\diamond$};
\addplot[domain=-1.5:5.5,samples=50,mark=none,densely dotted]{x};
% part c
\node (point-c1) at (axis cs: 1,3) {$\times$};
\node (point-c2) at (axis cs: 3,4) {$\times$};
\node (point-c3) at (axis cs: 4,5) {$\times$};
\addplot[domain=-1.5:5.5,samples=50,mark=none,dashdotted]{.5*x+2.5};
\addplot[domain=-1.5:5.5,samples=50,mark=none,dashdotted]{x+1};
% part d
\node (point-d1) at (axis cs: -1,1) {\textbullet};
\node (point-d2) at (axis cs: 0,3) {\textbullet};
\node (point-d3) at (axis cs: 2,7) {\textbullet};
\addplot[domain=-1.5:5.5,samples=50,mark=none,thick]{2*x+3};
\else
%%% COLOR VERSION %%%
% part a
\node (point-a1) [magenta] at (axis cs: 3,2) {\textbullet};
\addplot[domain=-1.5:5.5,samples=50,mark=none,magenta,dashed]{-2*x+8};
\addplot[domain=-1.5:5.5,samples=50,mark=none,magenta,dashed]{.33*x+1};
% part b
\node [cyan] (point-b1) at (axis cs: 0,0) {\textbullet};
\node [cyan] (point-b2) at (axis cs: 2,2) {\textbullet};
\addplot[domain=-1.5:5.5,samples=50,mark=none,cyan,thick]{x};
% part c
\node [green] (point-c1) at (axis cs: 1,3) {\textbullet};
\node [green] (point-c2) at (axis cs: 3,4) {\textbullet};
\node [green] (point-c3) at (axis cs: 4,5) {\textbullet};
\addplot[domain=-1.5:5.5,samples=50,mark=none,green,dashed]{.5*x+2.5};
\addplot[domain=-1.5:5.5,samples=50,mark=none,green,dashed]{x+1};
\node [orange] (point-c1) at (axis cs: 1,3) {\textbullet};
\node [orange] (point-c2) at (axis cs: 3,4) {\textbullet};
\node [orange] (point-c3) at (axis cs: 4,5) {\textbullet};
\addplot[domain=-1.5:5.5,samples=50,mark=none,orange,dashed]{.5*x+2.5};
\addplot[domain=-1.5:5.5,samples=50,mark=none,orange,dashed]{x+1};
% part d
\node (point-d1) at (axis cs: -1,1) {\textbullet};
\node (point-d2) at (axis cs: 0,3) {\textbullet};
\node (point-d3) at (axis cs: 2,7) {\textbullet};
\addplot[domain=-1.5:5.5,samples=50,mark=none,thick]{2*x+3};
\fi
\end{axis}
% labels
\node [below,font=\small,\ifbw\else magenta\fi] at (point-a1) {(a)};
\node [font=\small,\ifbw\else cyan\fi] at (5.2,2.7) {(b)};
\node [above left,font=\small,\ifbw\else orange\fi] at (point-c2) {(c)};
\node [font=\small] at (4.2,6) {(d)};
\end{tikzpicture}
\end{center}

\renewcommand{\labelenumi}{(\alph{enumi})}
\begin{enumerate}
\item No; there are not enough points to define a \emph{unique} degree-1 polynomial, and in fact there are infinitely many degree-1 polynomials passing through this point. (In \textcolor{magenta}{pink} above.)
\item Yes; these points uniquely define the polynomial $f(x) = x$. (In \textcolor{cyan}{light blue} above.)
\item No; there is no degree-1 polynomial passing through these points because they are not properly aligned. However, they do define a unique degree-2 polynomial. (In \textcolor{green}{green} above.)
\item Yes; these points uniquely define the polynomial $f(x) = 2x + 3$. (In black above.)
\item No; there are not enough points to define a \emph{unique} degree-1 polynomial, and in fact there are infinitely many degree-1 polynomials passing through this point. \ifbw($\star$ above.)\else(In \textcolor{magenta}{pink} above.)\fi
\item Yes; these points uniquely define the polynomial $f(x) = x$. \ifbw($\diamond$ above.)\else(In \textcolor{cyan}{light blue} above.)\fi
\item No; there is no degree-1 polynomial passing through these points because they are not properly aligned. However, they do define a unique degree-2 polynomial. \ifbw($\times$ above.)\else(In \textcolor{orange}{orange} above.)\fi
\item Yes; these points uniquely define the polynomial $f(x) = 2x + 3$. \ifbw(\textbullet\ above.)\else(In black above.)\fi
\end{enumerate}
\end{answer}

Expand Down
Binary file added packet/answers-bw.pdf
Binary file not shown.
Binary file modified packet/answers.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions packet/answers.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
\documentclass[12 pt]{article}
\newif\ifbw
\bwfalse

\hbadness=10

\input{src/header.tex}

\def\share{\ensuremath{\mathsf{Share}}}
Expand Down
Binary file added packet/main-bw.pdf
Binary file not shown.
Binary file modified packet/main.pdf
Binary file not shown.
6 changes: 5 additions & 1 deletion packet/main.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
\documentclass[12 pt]{article}
\hbadness=10
\newif\ifbw
\bwfalse

\hbadness=200

\input{src/header.tex}

%%% Title and Abstract
Expand Down
5 changes: 3 additions & 2 deletions packet/src/header.tex
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@
%%%% added by NG
\usetikzlibrary{shapes,backgrounds,decorations,patterns}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usepackage{xurl}
\usepackage{pifont}% http://ctan.org/pkg/pifont
\usepackage{colortbl}
\newcommand{\cmark}{\ding{51}}%
\newcommand{\xmark}{\ding{55}}%
% externalize the figures
% \usepgfplotslibrary{external
% \usepgfplotslibrary{external}
% \tikzexternalize

% Crypto commands
Expand All @@ -62,7 +63,7 @@
%%% Exercises & Examples
\newcounter{exercise}[section]
\newenvironment{exercise}{\refstepcounter{exercise}\par\bigskip \begin{quotation}{}{\leftmargin .25in\rightmargin .25in}
\noindent \textbf{Exercise~\thesection.\theexercise } \rmfamily}{\end{quotation}\par\bigskip}
\noindent \textbf{Exercise~\thesection.\theexercise } \rmfamily}{\end{quotation}\hfill\par\bigskip}
\newcommand{\exref}[1]{\hyperref[#1]{\thesection.\ref*{#1}}}

\newenvironment{bonus}{\refstepcounter{exercise}\par\bigskip \begin{quotation}{}{\leftmargin .25in\rightmargin .25in}
Expand Down
27 changes: 12 additions & 15 deletions packet/src/probability.tex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ \section{Probability and Randomness}\label{sec:prob}
\footnotetext[2]{
\url{https://www.statista.com/statistics/236550/percentage-of-us-population-that-own-a-iphone-smartphone/}
}
\item The distribution over the outcomes of a dice roll $\{1,2,3,4,5,6\}$
\item The distribution over the outcomes $\{1,2,3,4,5,6\}$ of a dice roll
is $\{\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6},\frac{1}{6}\}$.
\end{enumerate}
\end{example}
Expand All @@ -38,8 +38,7 @@ \section{Probability and Randomness}\label{sec:prob}
\renewcommand{\labelenumi}{(\alph{enumi})}
\begin{enumerate}
\item Card drawn from a shuffled deck.
\item Whether or not a student is registered for classes at a 2000-person high school
where all but 100 students register for classes every year.
\item Whether or not a student is registered for classes at a 2000-person high school where all but 100 students register for classes every year.
\end{enumerate}
\end{exercise}

Expand Down Expand Up @@ -117,19 +116,17 @@ \section{Probability and Randomness}\label{sec:prob}
would mean that there's some other event that could happen instead, so the sample space
is incomplete.

The pie charts below illustrate this idea. On the left is the probability
distribution of a coin toss; on the right, the probability distribution
of a dice roll. Notice that in both cases, the probabilities sum to 1.

\begin{figure}[h]
\includegraphics[width=.5\linewidth]{imgs/coin-pie.png}
\includegraphics[width=.5\linewidth]{imgs/die-pie.png}
% \caption{Left: probability distribution of a coin toss. Right:
% probability distribution of a dice roll. Probabilities always
% sum to 1.}
\begin{figure}[hb]
\centering
\includegraphics[width=.45\linewidth]{imgs/coin-pie.png}
\includegraphics[width=.45\linewidth]{imgs/die-pie.png}
\label{fig:pies}
\end{figure}

The pie charts above illustrate this idea. On the left is the probability
distribution of a coin toss; on the right, the probability distribution
of a dice roll. Notice that in both cases, the probabilities sum to 1.

When two events are not mutually exclusive, however, we can't add
their probabilities. For example, what's the probability of rolling a
multiple of 2 or a multiple of 3? These are not mutually exclusive
Expand All @@ -150,7 +147,7 @@ \section{Probability and Randomness}\label{sec:prob}

where $d$ is the random variable representing the outcome of the die roll.

\hfill\\
\bigskip

Conditional probability is the probability that something occurs
\emph{assuming that another event has already happened}. This is written with the symbol
Expand Down Expand Up @@ -350,7 +347,7 @@ \section{Probability and Randomness}\label{sec:prob}
\end{tikzpicture}
\end{center}

Now exactly one number, 11, is in both $A$ and $B$, so $\Pr[A \text{ and }
Now exactly one number, 11, is in both $A$ and $B$, so $\Pr[A \text{ and }\allowbreak
B] = \frac{1}{16}$. Thus $\Pr[A \mid B] = \frac{1}{16} \div \frac{1}{2}
= \frac{1}{8}$. Visually, we notice that $A$ in fact occupies one-eighth
of $B$'s space.
Expand Down
33 changes: 21 additions & 12 deletions packet/src/shamir.tex
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,23 @@ \subsubsection{Uniqueness}\label{sec:unique}
\addplot[domain=-1:5,samples=50,mark=none,thick]{x^2-4*x+3};
% other degree-2 polys through these points
%%% BW VERSION %%%%%%
% \addplot[domain=-1:5,samples=50,mark=none,dotted]{-(x^2-4*x+3)+6};
% \addplot[domain=-1:5,samples=50,mark=none,dotted]{x^2/4-x+3};
\ifbw
\addplot[domain=-1:5,samples=50,mark=none,dashed]{-(x^2-4*x+3)+6};
\addplot[domain=-1:5,samples=50,mark=none,dashed]{x^2/4-x+3};
\else
%%% COLOR VERSION %%%%%
\addplot[domain=-1:5,samples=50,mark=none,magenta]{-(x^2-4*x+3)+6};
\addplot[domain=-1:5,samples=50,mark=none,cyan]{x^2/4-x+3};
\fi
% points (on top)
\node (point1) at (axis cs: 0,3) {\textbullet};
\node [above right,font=\small] at (point1) {$(0,3)$};
\node (point2) at (axis cs: 4,3) {\textbullet};
\node [above left,font=\small] at (point2) {$(4,3)$};
\end{axis}
\node [font=\small] at (8,5) {$f(x)=x^2-4x+3$};
\node [font=\small,magenta] at (-1,1.3) {$f(x)=-x^2+4x+3$};
\node [font=\small,cyan] at (8,3.3) {$f(x)=\frac{1}{4}x^2-x+3$};
\node [font=\small,\ifbw\else magenta\fi] at (-1,1.3) {$f(x)=-x^2+4x+3$};
\node [font=\small,\ifbw\else cyan\fi] at (8,3.3) {$f(x)=\frac{1}{4}x^2-x+3$};
\end{tikzpicture}
\end{center}

Expand Down Expand Up @@ -313,7 +316,7 @@ \subsubsection{Uniqueness}\label{sec:unique}
\item $\sum_{i=1}^5 2i$
\item $\sum_{i=1}^5 1$
\item $\sum_{i=0}^4 x_i$ where $x_i$ means the $i$th
elements of the set $\{1, 5, -3, 0, 8\}$ and the numbering
elements of the set $\{1, 5, -3,\allowbreak 0, 8\}$ and the numbering
starts at 0 (that is, $x_0=1$).
\item $\sum_{i=0}^2 x_i$ for the same set.
\end{enumerate}
Expand All @@ -323,8 +326,8 @@ \subsubsection{Uniqueness}\label{sec:unique}
Repeat the previous exercise, substituting $\prod$ for $\sum$.
\end{bonus}

Now, back to Lagrange interpolation. We start with a set of points $(x_0, y_0),
\ldots,\allowbreak (x_m, y_m)$. For each point $(x_i, y_i)$, we compute the
Now, back to Lagrange interpolation. We start with a set of points $(x_0, y_0),\allowbreak
\ldots, (x_m, y_m)$. For each point $(x_i, y_i)$, we compute the
expression $\ell_i(x)$. For instance, for $i=2$, it will be of the form

\newcommand{\cyan}[1]{\textcolor{cyan}{#1}}
Expand Down Expand Up @@ -414,7 +417,8 @@ \subsubsection{Uniqueness}\label{sec:unique}
\end{align*}

Just as we deduced above!
\hfill\\

\bigskip

To return to our main task of computing $P(x)$, let's plug the expressions
for $\ell_0$ and $\ell_1$ back into the summation:
Expand Down Expand Up @@ -493,7 +497,7 @@ \subsubsection{Uniqueness}\label{sec:unique}

\begin{bonus}
Use Lagrange interpolation to find the unique degree-2
polynomial through the points $\{(-1,-16),(1,-2),(2,14)\}$.
polynomial through the points $\{(-1,-16),(1,-2),\allowbreak (2,14)\}$.
\end{bonus}

\subsection{Sharing Secrets Using Polynomials}
Expand All @@ -519,14 +523,14 @@ \subsection{Sharing Secrets Using Polynomials}
\end{definition}

Now we're ready to put everything we've learned together and define
Shamir's secret sharing scheme\footnotemark.
\allowbreak Shamir's secret sharing scheme\footnotemark.
\footnotetext{Adi Shamir introduced this scheme in a short 1979
paper entitled ``How to share a secret''\cite{shamir1979share}.
The paper is only two pages long, so if you're feeling adventurous
you could have a go at it! You can find it online at
\url{http://web.mit.edu/6.857/OldStuff/Fall03/ref/Shamir-HowToShareASecret.pdf}.}

\begin{figure}[h!]
\begin{figure}[ht]
\begin{pchstack}[center]
\fbox{%
\procedure{$\share(s)$}{%
Expand Down Expand Up @@ -593,8 +597,13 @@ \subsection{Sharing Secrets Using Polynomials}
\node (share1) at (axis cs: 1,17) {\textbullet};
\node (share2) at (axis cs: 2,22) {\textbullet};
\node (share3) at (axis cs: 3,27) {\textbullet};
\node [magenta] (s) at (axis cs: 0,12) {\textbullet};
\node [\ifbw\else magenta\fi] (s) at (axis cs: 0,12) {\textbullet};
\ifbw
\setlength{\fboxsep}{.1\fboxsep}
\node [right,font=\small] at (s) {$\boxed{s=12}$};
\else
\node [right,magenta,font=\small] at (s) {$s=12$};
\fi
\end{axis}
\node [right,font=\small] at (share1) {$s_1=(1,17)$};
\node [right,font=\small] at (share2) {$s_2=(2,22)$};
Expand Down

0 comments on commit c70d813

Please sign in to comment.