\documentclass[12pt,ifthen]{article} \usepackage{url} \newcommand{\lf}{\left\lfloor} \newcommand{\rf}{\right\rfloor} \newcommand{\lc}{\left\lceil} \newcommand{\rc}{\right\rceil} \newcommand{\Ceil}[1]{\left\lceil {#1}\right\rceil} \newcommand{\ceil}[1]{\left\lceil {#1}\right\rceil} \newcommand{\floor}[1]{\left\lfloor{#1}\right\rfloor} \newcommand{\abit }{\hat{a}} \newcommand{\bbit }{\hat{b}} \newcommand{\nth}{n^{th}} \newif{\ifshowsoln} %\showsolntrue \newcommand{\und}{\_\_\_\_\_\_\_\_\_} \newcommand{\Z}{\mathbb{Z}} \usepackage{amsmath} \usepackage{amssymb} % for \nmid \begin{document} \centerline{\textbf{HW 6 CMSC 456. DUE Oct 22}} \ifshowsoln \centerline{\textbf{SOLUTIONS}} \fi {\textbf{NOTE- THE HW IS FIVE PAGES LONG}} \begin{enumerate} \item (0 points) READ the syllabus- Content and Policy. What is your name? Write it clearly. What is the day and time of the first midterm? Read all of the slides on Public Key Crypto. \centerline{\bf GOTO NEXT PAGE} \newpage \item (Read the slides on LWE-Diffie Helman) (WARNING- this problem continues onto the next page) Write the following programs. I highly suggest using python's numpy library to implement this easier. \begin{enumerate} \item $GENMATRIX(n,p)$: gen a rand $n\times n$ matrix of elements of $\{0,\ldots,p-1\}$. We view entries as elements of $\Z_p$. \newline (See numpy.randint - it can generate random integer arrays. This can be done with one line) \item $GENVEC(n,p)$: gen a rand $n$-vector of elements of $\{0,\ldots,p-1\}$. We view entries as elements of $\Z_p$. \newline (See numpy.randint) \item $GENERR(n,p)$: gen a rand $n$-vector of elements of $\{0,1,p-1\}$. We view entries as elements of $\Z_p$. \newline (See numpy.randint, you can use min = -1, max = 1 and then use \% over the resulting array) \item $GENDATA(n,p,N)$: \begin{enumerate} \item $A:=GENMATRIX(n,p)$ \item $\vec y:=GENVEC(n,p)$ \item $\vec e_y:=GENERR(n,p)$ \item $\vec x:=GENVEC(n,p)$ \item $\vec e_x:=GENERR(n,p)$ \item $a = \vec y A \vec x + (\vec y \cdot \vec e_x)$ \newline (numpy.mod(numpy.dot($\vec y, A$), p) can be used to preform a dot product over modulo p) \item $b = \vec y A \vec x + (\vec x \cdot \vec e_y)$ \item if $a\in \{0,\ldots,\floor{p/4}\} \cup \{\floor{3p/4},\ldots, p-1\}$ $\abit=0$, else $\abit=1$. \item if $b\in \{0,\ldots,\floor{p/4}\} \cup \{\floor{3p/4},\ldots, p-1\}$, $\bbit=0$, else $\bbit=1$. \item the variable {\tt agree} is Y if $\abit=\bbit$ and N otherwise. \item Your code will output a tuple or an array of [$a,b,\abit,\bbit,agree$] \newline \newline \centerline{\bf GOTO NEXT PAGE} \newpage \item Here is a sample of printing your output: \noindent OUTPUT STARTS HERE $n=5$, $p=17$, $N=5$. \[ \begin{array}{|c|c|c|c|c|} \hline a & b & \abit & \bbit & \hbox{\tt agree} \cr \hline 3 & 2 & 0 & 0 & Y \cr 10 & 12 & 0 & 1 & N \cr 7 & 9 & 0 & 0 & Y \cr 1 & 0 & 0 & 0 & Y \cr 5 & 6 & 0 & 0 & Y \cr \hline \end{array} \] $\abit$ and $\bbit$ agree 80\% of the time. \noindent END OF OUTPUT \bf ***Note that $N=5$ and there are five lines.*** \end{enumerate} \end{enumerate} \centerline{\bf GOTO NEXT PAGE} \newpage \begin{enumerate} \item (10 points). Run program $GENDATA$ with the following inputs. Present the entire output. Using tabs (\textbackslash t) to delineate variables makes the output more readable. You can pipe your code into a text file to make it easy to submit ex.~\texttt{LWE.py >> output.txt} \begin{enumerate} \item $n=4$, $p=19$ \item $n=10$, $p=23$ \end{enumerate} \item Make a method to take [$n,p,N$] as input and output the percent of agreement. Call this method $GENDATA2(n,p,N)$. \item Make a method to take a LIST of [$n,p,N$] inputs and output a table of the $n,p,N$ and percent of agreement. Call this method $GENDATA3(n,p,N)$. A sample output is: \[ \begin{array}{|c|c|c|c|c|} \hline n & p & N & \hbox{\tt percent agree} \cr \hline 5 & 17 & 5 & 80 \cr 6 & 19 & 5 & 75 \cr 7 & 23 & 10 & 90 \cr \hline \end{array} \] This can be generated by printing ``n\textbackslash tp\textbackslash tN\textbackslash tagree'' If you follow this format for the entries of the table, your results should line up. \item (20 points) Run $GENDATA(n,p,N)$ on all $5\le n\le 10$, all primes $p$ where $11\le p\le 23$, and $N = 10000$. \item (10 points) Note the highest and lowest percentages. \item (0 points) If you spot any trends in the data report them. \end{enumerate} \newpage \item (30 points). In class we tried to find $m$ such that $m^2\equiv 101 \pmod {1147}$. We noted that $1147=31\times 37$ and that $m^2\equiv 101 \equiv 8 \pmod {31}$ has solutions $m=\pm 15$ which is really $\{15,16\}$ $m^2\equiv 101 \equiv 27 \pmod {37}$ has solutions $m=\pm 8$ which is really $\{8,29\}$ From the pair $(15,8)$ we found that $m=1007$ satisfies $m^2\equiv 101 \pmod {1147}$. Find the other three square roots that same way. You must explain your procedure. You can use programs on line (tell us which ones) if you do Chinese Remainder Theorem, but you can't use a SQRT program. Clearly list all four square root in numeric order (to make life easier for the graders). ADVICE: Check your answer by squaring all four of them mod 1147 and seeing if you always get 101. \centerline{\bf GOTO NEXT PAGE} \newpage \item (30 points). In this problem you will do the Blum-Williams variant of Rabin Encryption. Let $p=3$, $q=11$. \begin{enumerate} \item What is the Public Key? \item List all $m$ such that Bob can send $m$ (encoded of course) to Alice. List the $m$'s in numeric order (easy for the grader). And tell us how you got this list. \item Alice gets 4 from Bob. What does Alice do to decode it? Give us all her steps and what the final answer is! \end{enumerate} \end{enumerate} \end{document}