\documentclass[11pt]{article}
\usepackage{jeffe,handout,multicol,tikz,kgm}

\newcommand{\kgmcomment}[1]{}
\renewcommand{\gcd}{\mathrm{gcd}}
\newcommand{\ord}{\mathrm{ord}}

\begin{document}
\headers{Math373}{Homework 6}{Due Fri, Feb. 21, 2014}

%\makeatletter
%\def\@oddfoot{\hfill \tikz \node[draw] {over} ; }
%\makeatother

%\newcommand{\seq}[1]{\left\langle #1\right\rangle}

\newcommand{\F}{\mathbb{F}}
\newcommand{\compicon}%
{%
	\begin{tikzpicture}[scale=0.15]%
		\draw[double] (0,0) rectangle (1,1) ;
		\begin{scope}[yshift=-5pt]
			\draw (-0.5, -0.5) rectangle (1.5, 0) ;
		\end{scope}
	\end{tikzpicture}
}


\makeatletter
\def\@oddfoot{}
\makeatother

\newcommand{\K}{\mathcal{K}}
\newcommand{\M}{\mathcal{M}}
\newcommand{\C}{\mathcal{C}}

\noindent
\textbf{Directions:} Solve the following problems.  All written work must be your own.  See the course syllabus for detailed rules.

\begin{enumerate}

\item {} [JJJ 1.36] Compute the value of $2^{(p-1)/2} \pmod{p}$ for every prime $3 \le p < 20$.  (You do not need to show the details of your computation.)  Make a conjecture as to the possible values of $2^{(p-1)/2} \pmod{p}$ and prove that your conjecture is correct.

\item {} [JJJ 1.41] Consider the affine cipher with key $k=(\alpha, \beta)$ whose encryption and decryption functions are given by
\begin{align*}
e_k (m) &\equiv \alpha m + \beta \pmod{p}\\
d_k (c) &\equiv \alpha^{-1} (c - \beta) \pmod{p}
\end{align*}
\begin{enumerate}
	\item Let $p=541$ and let $k=(34, 71)$.  Encrypt the message $m=204$.  Decrypt the ciphertext $c=431$.
	\item Assuming that $p$ is public knowledge, explain why the affine cipher is vulnerable to a chosen plaintext attack.  How many plaintext/ciphertext pairs are likely to be needed to recover the private key?
	\item Alice and Bob decide to use the prime $p = 601$ for their affine cipher.  The value of $p$ is public knowledge.  Eve intercepts the ciphertexts $c_1 = 324$ and $c_2 = 381$, and she also manages to find the corresponding plaintexts are $m_1 = 387$ and $m_2 = 491$.  Determine the private key $(\alpha, \beta)$ and then use it to encrypt the message $m_3 = 173$.
	\item \textbf{[Challenge]} Suppose now that $p$ is not public knowledge.  Is the affine cipher still vulnerable to a chosen plaintext attack?  Explain.
\end{enumerate}

\item {} [JJJ 1.43] Let $n$ be a large integer and let $\K = \M = \C = \Z_n$.  For each of the functions below, answer the following questions.
\begin{itemize}
	\item Is $e$ an encryption function?  In other words, is $e$ an injective function?
	\item If $e$ is an encryption function, what is the associated decryption function $d$?
	\item If $e$ is not an encryption function, can you make it into an encryption function by restricting the set of keys $\K$ to a smaller, but still reasonably large subset?
\end{itemize}
\begin{enumerate}
	\item $e_k(m) \equiv k-m \pmod{n}$
	\item $e_k(m) \equiv k\cdot m \pmod{n}$
	\item $e_k(m) \equiv (k+m)^2 \pmod{n}$
\end{enumerate}


\end{enumerate}
\end{document}
