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

\usepackage{fancyhdr}   
\pagestyle{fancy}      
\lhead{CS 355, FALL 2025}               
\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 2}

\date{}

\maketitle 

\thispagestyle{fancy}  
\pagestyle{fancy}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% PLEASE LIST COLLABORATORS BELOW  %%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{\bfseries Collaborators :} 
%%% List your collaborators and any online resources here.



\newpage
\centering
{\Huge{Practice Questions}}

These are practice questions.
They will \textbf{NOT} be graded.
We have also provided the final answers.
However, it is up to you to understand how or why the given solution is correct.

You do not need to submit these on Gradescope.
However, you may find it easier to just include them in the pdf.
In that case, please do not mark these questions on Gradescope.

\newpage


\begin{enumerate}
    \item {\bfseries Calculating Large Powers mod $p$ (0 points).} 
    Recall that we learned the repeated squaring algorithm in class. 
    Calculate the following using this concept 
    $$ 10^{2025^{2025}+2025} \pmod{101} $$
    (Hint: Note that $101$ is a prime number and before applying repeated squaring algorithm try to simplify the problem using what you learned in part C of question 1). 

    (Note: as can be seen from the latex file, the entirety of $2025^{2025}+2025$ is in the exponent of $10$. Also recall that $a^{b^c} = a^{\left(b^c\right)}$, not $\left(a^b\right)^c$, which is $a^{b\cdot c}$)
    
    {\bfseries Solution.} 

    $100$
    \vfill
    
    
    \item {\bfseries Order of an Element in $(\bbZ_p^*,\times)$. (0 points)} 
    The \textit{order} of an element $x$ in the multiplicative group $(\bbZ_p^*,\times)$ is the smallest positive integer $h$ such that $x^h = 1 \mod p $. 
    For example, the order of 2 in $(\bbZ_5^*,\times)$ is 4, and the order of $4$ in $(\bbZ_5^*,\times)$ is 2. 
    \begin{enumerate}
    \item (0 points) What is the order of 3 in $(\bbZ_{7}^*,\times)$? 
    
    {\bfseries Solution.}  

    The order of 3 in $(\bbZ_{7}^*,\times)$ is 6.
    \vfill

    \end{enumerate}
    \newpage

    \item {\bfseries Elliptic curve (0 points).} 
In class, we have briefly discussed elliptic curve.
Here we will see some concrete examples of elliptic curve on finite prime fields.

    Let $Y^2 = X^3 + X$ be an elliptic curve over the field $(F_{23}, +, \cdot).$
    A point $(X, Y)$ lies on the elliptic curve if it satisfies the equation $Y^2 = X^3 + X.$
        \begin{enumerate}
        \item (0 points)
        Are the two points $P = (9, 18)$ and $Q = (11, 10)$ on the curve?
        
        {\bfseries Solution.}  

        Yes, they are.

        \vfill
    
        \item (0 points)
        Find the point $R$ where the line connecting $P$ and $Q$ intersects the elliptic curve $Y^2 = X^3 + X.$ 
        For $R=(x,y)$, define the ``inverse of $R$'' to be the point $S = (x,-y)$. 
        Find the inverse of point $R.$
        Recall from the lecture that ``$P + Q$'' is defined to be the point $S \defeq $ ``inverse of $R$.''  
            
        {\bfseries Solution.}  
    
        The inverse of $R$ is $S = (19, 22).$

        \vfill
    \end{enumerate}
    
\newpage
\end{enumerate}


\newpage
\centering
{\Huge{Homework Questions}}

These are homework questions and will be graded.
Please make sure to clearly mark each problem on Gradescope.
\newpage

\begin{enumerate}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%% PROBLEM 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\item {\bfseries Some properties of $(\bbZ_p^*,\times)$ (5+5 points).} 
Recall that $\bbZ_p^*$ is the set $\{1,\dotsc,p-1\}$ and $\times$ is integer multiplication $\mod p$, where $p$ is a prime. 
For example, if $p=5$, then $2\times 3$ is $1$. 
In this problem, we shall prove that $(\bbZ_p^*,\times)$ is a group when $p$ is any prime. 
The only part missing in the lecture was the proof that every $x\in\bbZ_p^*$ has an inverse. 
We will find the inverse of any element $x\in\bbZ_p^*$. 
    \begin{enumerate}
    \item(5 points) 
    For $x\in\bbZ_p^*$, prove that the inverse of $x\in\bbZ_p^*$ is given by
        $$\overbrace{x\times x \times \dotsi \times x}^{(p-2)\text{-times}}$$ 
    That is, prove that $x^{p-1}=1\mod p$, for any prime $p$ and $x\in\bbZ_p^*$.    
    
    {\bfseries Solution.}
    
    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
    
    \newpage
    \item (5 points)
    Let $p$, and $q$ be two distinct primes. Prove that $(p^q-p)+(q^p-q)$ is divisible by $pq$.
     
    {\bfseries Solution.}
    
    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
    
    \end{enumerate}
\newpage





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%% PROBLEM 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\item {\bfseries Understanding Groups: Part one (5+6+6+8+5 points).} 
Recall that when we defined a group $(G,\circ)$, we stated that there exists an element $e$ such that for all $x\in G$ we have $x\circ e=x$. 
Note that $e$ is ``applied on $x$ from the right.'' 
Similarly, for every $x\in G$, we are guaranteed that there exists $\inv(x)\in G$ such that $x\circ\inv(x)=e$. 
Note that $\inv(x)$ is again ``applied to $x$ from the right.'' 
  
In this problem, however, we shall explore the following questions: (a) Is there an ``identity from the left?,'' and (b) Is there an ``inverse from the left?'' 
  
We shall formalize and prove these results in this question. 
    \begin{enumerate}
    \item (5 points) 
    Prove that it is impossible that there exists $a,b,c\in G$ such that $a\neq b$ but $a\circ c = b\circ c$. 

    
    {\bfseries Solution.}  
    
    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
    
    \newpage
    
    \item (6 points) 
    Prove that $e\circ x = x$, for all $x\in G$.  
    
    {\bfseries Solution.}  
    
    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
    
    \newpage
    
    \item (6 points) 
    Prove that if there exists an element $\alpha \in G$ such that for \textbf{some} $x\in G$, we have $\alpha \circ x=x$, then $\alpha=e$. 
    (Remark: Note that these two steps prove that the ``left identity'' is identical to the right identity $e$.) 
    
    {\bfseries Solution.} 
    
    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
    
    \newpage

    \item (8 points) 
    Prove that $\inv(x)\circ x = e$.  
    
    {\bfseries Solution.} 
    
    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
    
    \newpage
    
    \item (5 points) 
    Prove that if there exists an element $\alpha\in G$ and $x\in G$ such that $\alpha\circ x=e$, then $\alpha=\inv(x)$. 
    
    (Remark: Note that these two steps prove that the ``left inverse of $x$'' is identical to the right inverse $\inv(x)$.) 
    
    {\bfseries Solution.}  
    
    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
    
    \end{enumerate}
\newpage





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%% PROBLEM 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\item {\bfseries Understanding Groups: Part Two (9+6 points).}
In this part, we will prove a crucial property of inverses in groups -- they are unique. And finally, using this property, we will prove a result that is crucial to the proof of security of one-time pad over the group $(G,\circ)$. 
    \begin{enumerate} 
    \item(9 points) 
    Suppose $a,b\in G$. 
    Let $\inv(a)$ and $\inv(b)$ be the inverses of $a$ and $b$, respectively (\ie, $a\circ\inv(a)=e$ and $b\circ\inv(b)=e$). 
    Prove that $\inv(a)=\inv(b)$ if and only if $a=b$.  
    
    {\bfseries Solution.}  
    
    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
    
    \newpage
  
    \item (6 points) 
    Suppose $m\in G $ is a message and $c\in G$ is a cipher text. 
    Prove that there exists a unique $\sk\in G$ such that $m\circ \sk = c$. 
    
    {\bfseries Solution.} 
    
    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
    
   \end{enumerate}
\newpage 



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%% PROBLEM 4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\item {\bfseries Order of an Element in $(\bbZ_p^*,\times)$. (10+5+10+5 points)} 
The \textit{order} of an element $x$ in the multiplicative group $(\bbZ_p^*,\times)$ is the smallest positive integer $h$ such that $x^h = 1 \mod p $. 
For example, the order of 2 in $(\bbZ_5^*,\times)$ is 4, and the order of $4$ in $(\bbZ_5^*,\times)$ is 2. 
    \begin{enumerate}
    
    \item (10 points) 
    Let $x$ be an element in $(\bbZ_p^*,\times)$ such that $x^n=1 \mod{p}$ for some positive integer $n$ and let $h$ be the order of $x$ in $(\bbZ_p^*,\times)$. 
    Prove that $h$ divides $n$.
    
    {\bfseries Solution.}  

    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
    
    \vfill

    \newpage
    
    \item (5 points) 
    Let $h$ be the order of $x$ in $(\bbZ_p^*,\times)$. 
    Prove that $h$ divides $(p-1)$.
    
    {\bfseries Solution.}  
    
    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE

    
    \newpage
    \item (10 points) 
    Let $h$ be the order of $x$ in 
    $(\bbZ_p^*,\times)$, and $k$ be a 
    positive integer. Let $r$ denote the order of $y=x^k \mod p\in \bbZ_p^*$.
    Show that $r=\frac{h}{d}\in \bbZ$ where $d$ denotes the 
    greatest common divisor of $h$ and $k$.\newline
    \textbf{Hint:} Use part (b) and prove 
    that $r$ divides $\frac{h}{d}$ 
    and $\frac{h}{d}$ divides $r$.
    
    {\bfseries Solution.}  
    
    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE

    \newpage

    \item (5 points)
    Let $p>2$ be a prime, and $a\in (\bbZ_p^*,\times)$. Then, show that the element
    $b=a^{\frac{p-1}{2}} \in (\bbZ_p^*,\times)$ is equal to $1$ or has order $2$.   

    {\bfseries Solution.}  
    
    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
    
    \end{enumerate}
\newpage





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%Problem 5%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\item {\bfseries Defining Multiplication over $\bbZ_{27}^*$ (5+10+10 points).} 
In the class, we had considered the group $(\bbZ_{26},+)$ to construct a one-time pad for one alphabet message. 
Can we define a group with 26 elements using a ``multiplication''-like operation? 
This problem shall assist you to define the $(\bbZ_{27}^*,\times)$ group that has 26 elements.
  
    {\bfseries The first attempt from class.}
    Recall that in the class, we had seen that the following is also a group.
        $$ (\bbZ_{27}\setminus\{0,3,6,9,12,15,18,21,24\},\times),$$
    where $\times$ is integer multiplication $\mod 27$. 
    However, the set had only 18 elements. 
  
    In this problem, we shall define $(\bbZ_{27}^*,\times)$ in an different manner such that the set has 26 elements. 
  
    {\bfseries A new approach.} 
    Interpret $\bbZ_{27}^*$ as the set of all triplets $(a_0,a_1,a_2)$ such that $a_0,a_1,a_2 \in \bbZ_3$ and at least one of them is non-zero. 
    Intuitively, you can think of the triplets as the ternary representation of the elements in $\bbZ_{27}^*$. 
    We interpret the triplet $(a_0,a_1,a_2)$ as the polynomial $a_0 + a_1X + a_2X^2$. 
    So, every element in $\bbZ_{27}^*$ has an associated non-zero polynomial of degree at most 2, and every non-zero polynomial of degree at most 2 has an element in $\bbZ_{27}^*$ associated with it. 
  
    The multiplication ($\times$ operator) of the element $(a_0,a_1,a_2)$ with the element $(b_0,b_1,b_2)$ is defined as the element corresponding to the polynomial
    $$(a_0 + a_1X + a_2X^2) \times (b_0 + b_1X + b_2X^2) \mod 2 + 2X + X^3$$
    
    The multiplication ($\times$ operator) of the element $(a_0,a_1,a_2)$ with the element $(b_0,b_1,b_2)$ is defined as follows.
    
    %%%%%%
      \begin{boxedminipage}{\linewidth}
      Input $(a_0,a_1,a_2)$ and $(b_0,b_1,b_2)$.
      \begin{enumerate}
      \item Define $A(X) \defeq a_0 + a_1X + a_2X^2$ and $B(X) \defeq b_0+b_1X+b_2X^2$
      \item Compute $C(X) \defeq A(X)\times B(X)$ (interpret this step as ``multiplication of polynomials with integer coefficients'') 
      \item Compute $R(X) \defeq C(X) \mod 2+2X+X^3$ (interpret this as step as taking a remainder where one treats both polynomials as polynomials with integer coefficients). 
        Let $R(X) = r_0 + r_1X + r_2X^2$
      \item Return $(c_0,c_1,c_2) = (r_0\mod 3, \; r_1\mod 3, \; r_2\mod 3)$
    
      \end{enumerate}
      \end{boxedminipage}
    %%%%%%
  
For example, the multiplication $(0,1,1)\times (1,1,2)$ is computed in the following way.
    \begin{enumerate}
    \item $A(X) = X + X^2$ and $B(X) = 1+X+2X^2$. 
    \item $C(X) = X + 2X^2 + 3X^3 + 2X^4$.
    \item $R(X) = -6-9X-2X^2$.
    \item $(c_0,c_1,c_2) = (0,0,1)$.
    \end{enumerate}

   \newpage
According to \underline{this definition} of the $\times$ operator, solve the following problems. 
    \begin{itemize}
    \item (5 points) 
    Evaluate $(2,0,1) \times (2,0,2).$
    
    {\bfseries Solution.}  
    
    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
    
    \newpage
    
    \item (10 points) 117814
    Note that $e=(1,0,0)$ is an identity element. 
    Find the inverse of $(0,0,2)$.

    {\bfseries Solution.}  
    
    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
    
    \newpage
  
    \item (10 points) 
    Assume that $(\bbZ_{27}^*,\times)$ is a group. 
    Find the order of the element $(0,0,1)$. 
    
    (Recall that, in a group $(G,\circ)$, the order of an element $x\in G$ is the smallest positive integer $h$ such that $\overbrace{x\circ x \circ \dotsi \circ x}^{h\text{-times}} = e$)
    
    {\bfseries Solution.}  

    \   %%% <-- ERASE THIS LINE AND WRITE YOUR SOLUTION HERE
    
    \end{itemize}
\newpage


\end{enumerate}
\end{document}
