\documentclass[11pt]{article}
\input{headers06}

\usepackage{fancyhdr}   
\pagestyle{fancy}      
\lhead{CS 355, FALL 2020}               
\rhead{Name: Hemanta K. Maji} %%% <-- REPLACE Hemanta K. Maji WITH YOUR NAME HERE

\usepackage[strict]{changepage}  
\newcommand{\nextoddpage}{\checkoddpage\ifoddpage{\ \newpage\ \newpage}\else{\ \newpage}\fi}  


\begin{document}

\title{Homework 6}

\date{}

\maketitle 

\thispagestyle{fancy}  
\pagestyle{fancy}      


\begin{enumerate}

\item {\bfseries RSA Assumption (5+12+5).} Consider RSA encryption scheme with parameters $N=35=5\times 7$.
\begin{enumerate}
    \item Find $\varphi(N)$ and $\mathbb{Z}^{*}_N$. 
    \newline
    %\newpage
    \vspace{0.3 \textheight}
    \item Use repeated squaring and complete the rows $X,X^2, X^4$ for all $X\in \mathbb{Z}^{*}_N$ as you have seen in the class (slides), that is, fill in the following table by adding as many columns as needed.

  {\bfseries Solution.}  \newline
   \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
       \begin{center}
 %      \centering
       \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|}
       \hline
        $X$ &&&&&&&&&&&& \\
       \hline
        $X^2$ &&&&&&&&&&&&\\
       \hline
        $X^4$ &&&&&&&&&&&&\\
        \hline
       \end{tabular}
    \end{center}
      \begin{center}
 %      \centering
       \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|}
       \hline
        $X$ &&&&&&&&&&&& \\
       \hline
        $X^2$ &&&&&&&&&&&&\\
       \hline
        $X^4$ &&&&&&&&&&&&\\
        \hline
       \end{tabular}
    \end{center}
   \vspace{0.2 \textheight}
    \item Find the row $X^5$ and show that $X^5$ is a bijection from $\mathbb{Z}^{*}_N$ to $\mathbb{Z}^{*}_N$.
     \newline
  {\bfseries Solution.}  \newline
   \   %%%
   \begin{center}
 %      \centering
       \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|}
       \hline
        $X$ &&&&&&&&&&&& \\
       \hline
        $X^4$ &&&&&&&&&&&&\\
        \hline
        $X^5$ &&&&&&&&&&&&\\
       \hline
        
       \end{tabular}
    \end{center}
      \begin{center}
 %      \centering
       \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|}
       \hline
        $X$ &&&&&&&&&&&& \\
       \hline
        $X^4$ &&&&&&&&&&&&\\
        \hline
        $X^5$ &&&&&&&&&&&&\\
       \hline        
       \end{tabular}
    \end{center}
    
     \newpage
\end{enumerate}
   

\item {\bfseries Answer to the following questions (7+7+7+7):}
\begin{enumerate}
    \item Compute the three least significant (decimal) digits of $6251007^{1960404}$ by hand.\newline 
    {\bfseries Solution.}  \newline

    \vspace {0.4\textheight}
    \item Is the following RSA signature scheme valid?(Justify your answer)\newline
    $(r||m)=24, \sigma=196, N=1165, e=43$\newline
    Here, $m$ denotes the message, and $r$ denotes the randomness used to sign $m$ and $\sigma$ denotes the signature. Moreover, $(r||m)$ denotes the concatenation of $r$ and $m$. The signature algorithm $Sign(m)$ returns $(r||m)^d \mod{N}$ where $d$ is the inverse of $e$ modulo $\varphi(N)$. The verification algorithm $Ver(m,\sigma)$ returns ($(r||m)==\sigma^e \mod{N}$). 
    \newline
    {\bfseries Solution.}  \newline
 
    \newpage
    \item 
    Remember that in RSA encryption and signature schemes, $N=p\times q$ where $p$ and $q$ are two large primes. Show that in a RSA scheme (with public parameters $N$ and $e$), if you know $N$ and $\varphi(N)$, then you can find the factorization of $N$ i.e. you can find $p$ and $q$.
    \newline
   {\bfseries Solution.}  \newline

    \vspace {0.3\textheight}
    \item Consider an encryption scheme where 
    $Enc(m):=m^e \mod{N}$ where $e$ is a positive integer relatively prime to $\varphi(N)$ and $Dec(c):=c^d \mod{N}$ where $d$ is the inverse of $e$ modulo $\varphi(N)$.
    Show that in this encryption scheme, if you know the encryption of $m_1$ and the encryption of $m_2$, then you can find 
    the encryption of $(m_1\times m_2)^5$.
    \newline 
   {\bfseries Solution.}  \newline
\end{enumerate}
    \newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%% PROGRAMMING ASSIGNMENT  %%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\item {\bfseries Programming Assignment: Compute the Cube Root of a Large Integer.} (50 points)\newline
This problem requires you to find the cube-root of very large perfect cube integers (each number is roughly 30K bits in binary representation). 
The inputs shall be given using a text file \textsf{inputs.txt} containing five (roughly) 30K-bit numbers in binary representation.
These numbers are separated by a new line character. 
Your program must output the cube roots of the five numbers, represented as binary and separated by a new line character, to a text file named as \textsf{outputs.txt}.
Make sure that you follow the conventions, otherwise you will get zero credit. 
You can use Java, Python, C, or SageMath. 
Turn in your code and the output file via Gradescope.
%In this programming assignment, you are asking to write a program that computes the cube root of a very large (roughly 30K bits in binary representation) perfect cube number using binary search algorithm. Since the given number is a perfect cube, it is guaranteed that its cube root is an integer. You will be given a text file named \textit{inputs.txt} containing five (roughly) 30K-bit numbers in binary representation. These numbers are separated by new line characters.  Your program must output the cube roots of the five numbers, represented as binary and separated by new line characters, to a text file named as \textit{yourLastName-yourFirstName.txt}. Make sure that you follow the naming convention. You can use Java, Python, C, or SageMath. Turn in your code and the output file. 
\end{enumerate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%% PLEASE LIST COLLABORATORS BELOW  %%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
{\bfseries Collaborators :} \newline 
% ENTER THEIR NAMES HERE  

\end{document}

