-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrypto-groups.tex
3121 lines (2777 loc) · 120 KB
/
crypto-groups.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass[12pt]{amsart}
%\usepackage{srcltx}
\usepackage{verbatim}
\usepackage{amsmath,amsthm,amssymb,amsfonts}
\usepackage{marvosym}
\usepackage{graphicx}
\usepackage[colorlinks]{hyperref}
%\usepackage{wrapfig}
\usepackage{array}
\usepackage{amscd}
\usepackage[all]{xy}
\setlength{\extrarowheight}{1pt}
% it would be better if the bf and it did not apply in math mode
\newcommand{\terminology}[1]{\textbf{\textit{#1}}}
\renewcommand{\terminology}[1]{#1}
\newcommand{\term}{\terminology}
\newcommand{\nc}{\newcommand}
\nc{\con}{\text{\reflectbox{\Lightning}\Lightning}}
%\nc{\con}{*}
%\nc{\con}{\includegraphics[keepaspectratio=true, width=1em]{lightn.png}}
%\def\con{ ⚡⚡ }
\nc{\Q}{\mathbb{Q}}
\nc{\Z}{\mathbb{Z}}
\nc{\C}{\mathbb{C}}
\nc{\R}{\mathbb{R}}
\nc{\F}{\mathbb{F}}
\nc{\Qstar}{\Q^\times}
\nc{\Cstar}{\C^\times}
\nc{\Rstar}{\R^\times}
\nc{\Znstar}{\Zn^\times}
\nc{\Nat}{\mathbb{N}}
\nc{\Zp}{\Z_p}
\nc{\Zn}{\Z_n}
\nc{\Fp}{\F_p}
\nc{\pr}{\mathbb{P}}
\nc{\af}{\mathbb{A}}
\nc{\bx}{\mathbf{x}}
\nc{\Fpbar}{\overline{\F}_p}
\nc{\Kbar}{\overline{K}}
\nc{\Qbar}{\overline{\Q}}
\nc{\Qpbar}{\overline{\Q}_p}
\nc{\cfp}{\mathcal{F}_p}
\nc{\calA}{\mathcal{A}}
\nc{\calC}{\mathcal{C}}
\nc{\calP}{\mathcal{P}}
\nc{\calK}{\mathcal{K}}
\nc{\Oc}{\mathcal{O}}
\nc{\orig}{\Oc}
\nc{\fal}{f_\alpha}
\nc{\cots}{, \ldots,}
\nc{\ccots}{: \cdots:}
\nc{\seq}{\subseteq}
\nc{\pots}{+ \cdots +}
\nc{\leg}[2]{{\displaystyle\left(\frac{#1}{#2}\right)}}
\nc{\ty}[1]{\texttt{#1}}
\nc{\of}{\circ}
\nc{\ds}{\displaystyle}
\nc{\exdiv}{\,||\,}
\nc{\Nr}{\textrm{N}}
\nc{\gen}[1]{\langle #1\rangle}
\nc{\frob}{\mathcal{F}}
\nc{\frobp}{\frob_p}
\nc{\frobq}{\frob_q}
\nc{\Ord}{\mathrm{Ord}}
\renewcommand{\Im}{\mathrm{Im}} % don't need imaginary part
\DeclareMathOperator{\Div}{Div}
\DeclareMathOperator{\Pic}{Pic}
\DeclareMathOperator{\ord}{ord}
\DeclareMathOperator{\ddiv}{div}
\DeclareMathOperator{\cok}{cok}
\DeclareMathOperator{\disc}{disc}
\DeclareMathOperator{\Hom}{Hom}
\DeclareMathOperator{\End}{End}
\DeclareMathOperator{\im}{Im}
\DeclareMathOperator{\GL}{GL}
\DeclareMathOperator{\chr}{char}
\nc{\cbar}{\overline{E}}
\nc{\abar}{\overline{a}}
\nc{\bbar}{\overline{b}}
\newcounter{probs}
\newenvironment{prob}{%
\refstepcounter{probs}
\par\medskip\noindent\textbf{Exercise \theprobs:} }{\par\medskip}
\nc{\pp}{\pr^1}
\nc{\tg}{\langle e\rangle}
\DeclareMathOperator{\tr}{Tr}
\DeclareMathOperator{\N}{N}
\DeclareMathOperator{\charr}{char}
\DeclareMathOperator{\aut}{Aut}
\DeclareMathOperator{\gal}{Gal}
\nc{\uph}{\mathcal{H}}
\nc{\from}{\leftarrow}
\nc{\ilim}{\displaystyle\lim_{\from}}
\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\newtheorem{prop}[thm]{Proposition}
\newtheorem{lemma}[thm]{Lemma}
\newtheorem{cor}[thm]{Corollary}
\theoremstyle{definition}
\newtheorem{defn}[thm]{Definition}
\theoremstyle{remark}
\newtheorem*{notation}{Notation}
\newtheorem*{note}{Note}
\newtheorem*{remark}{Remark}
\newtheorem*{exam}{Example}
%\let\oldsec\section
%\def\section{\clearpage\oldsec}
\title{Algebra for Cryptologists}
\author{John W.{} Jones}
\begin{document}
\maketitle
These notes were written for the beginning of MAT 448, \emph{Cryptography
II}. There are basic notions from abstract algebra, particularly from
group theory, which are essential
throughout the course. On the other hand, we will not need advanced
aspects of group theory like the Sylow theorems, so we will cover
everything we need relatively quickly.
\tableofcontents
\section{Notation and conventions}
Note that in proofs by contradiction, we use the symbol \con{} to
indicate that a contradiction has been reached.
\subsection{Famous sets}
Here we collect definitions and notation to be used throughout. It is
intended more as a reference than an introduction. In particular, we
specify what natural algebraic structures these sets possess even
though those structures are not defined until later sections.
We let
\begin{enumerate}
\item[] $\term{\Z}$ : the set of integers \quad (a group under $+$ and a ring)
\item[] $\term{\Q}$ : the set of rational numbers \quad (a group under $+$ and a field)
\item[] $\term{\R}$ : the set of real numbers \quad (a group under $+$ and a field)
\item[] $\term{\C}$ : the set of complex numbers \quad (a group under $+$ and a field)
\item[] $\term{\Qstar}$ : $\{a\in\Q\mid a\neq 0\}$ \quad (a group under multiplication)
\item[] $\term{\Rstar}$ : $\{a\in\R\mid a\neq 0\}$ \quad (a group under multiplication)
\item[] $\term{\Cstar}$ : $\{a\in\C\mid a\neq 0\}$\quad (a group under multiplication)
\item[] $\term{\Zn}$ : integers modulo $n$ \quad (a group under $+$ and a ring)
\item[] $\term{\mathbb N}$ : $\{a\in\Z\mid a\geq 0\}$
\end{enumerate}
%\begin{align*}
%&\Z = \text{the set of integers} \quad\text{(a group under $+$ and a ring)} \\
%&\Q = \text{the set of rational numbers} \quad\text{(a group under $+$ and a field)} \\
%&\R = \text{the set of real numbers} \quad\text{(a group under $+$ and a field)} \\
%&\C= \text{the set of complex numbers} \quad\text{(a group under $+$ and a field)} \\
%&\Qstar= \{a\in\Q\mid a\neq 0\} \quad\text{(a group under multiplication)}\\
%&\Rstar= \{a\in\R\mid a\neq 0\} \quad\text{(a group under multiplication)}\\
%&\Cstar= \{a\in\C\mid a\neq 0\}\quad\text{(a group under multiplication)}\\
%&\Zn = \text{integers modulo $n$} \quad\text{(a group under $+$ and a ring)} \\
%&\mathbb N=\{a\in\Z\mid a\geq 0\}
%\end{align*}
A superscript of $+$ means we want the positive elements, so
$$\term{\Z^+}=\{a\in \Z\mid a>0\},$$ and similarly for $\term{\Q^+}$ and $\term{\R^+}$.
If we have a set $R$ and positive integer $n\in\Z^+$, then we let
\[ M_n(R)=\{n\times n \text{ matrices with entries from $R$}\}.\]
We will only use this when $R$ is a ring, specifically $R=\Q$, $\R$,
$\C$, $\Zn$, or $\Z$.
% In any of these cases, $M_n(R)$ is a ring with
% identity under matrix addition and matrix multiplication. We let
% $I_n\in M_n(R)$ be the identity matrix (ones on the main diagonal and
% zeros everywhere else).
% Since $M_n(R)$ is a ring with identity, we can consider its group of
% units:
In each case, we are also interested in the group
\[ \GL_n(R) =\{A\in M_n(R)\mid \det(A)\in R^\times\}.\]
For this definition, $\Zn^\times$ is defined in Section~\ref{zn}
below; $\Z^\times=\{-1,1\}$.
\subsection{Functions}
If we have a function $f:A\to B$, then we assume $f$ is defined for
every element of $A$, so $A$ is the domain of $f$. We refer to $B$ as
the codomain of $f$, as opposed to its image:
\[ \text{Im}(f)=f(A) = \{f(a)\mid a\in A\}\seq B\]
\subsection{$\Zn$}
\label{zn}
An essential construction for us is $\Zn$. There are three ways of
viewing it. First, we fix $n\in\Z^+$.
First, we can think of integers up to congruences. If $a,b\in \Z$, we
define
\[ a\equiv b\pmod n \iff n\mid b-a.\]
Here, we are dealing with integers, but only think of them as
different if they are not congruent modulo $n$. Every integer is
congruent to its remainder on division by $n$, and no two remainders
from $\{0,\ldots, n-1\}$ are congruent modulo $n$, so we have $n$
things (see Section~\ref{div-alg} for more on remainders and the
Division algorithm).
Building on this idea gives the second point of view, namely that
$\Zn=\{0\cots n-1\}$, and when we perform operations, we always
replace the result with its remainder on division by $n$. This is
very concrete and well-suited for implimentation on a computer, but is
less elegant mathematically. To assist in working with this version,
we define
\[ a\bmod n = \text{ the remainder when $a$ is divided by $n$}.\]
This is the unique integer $r$ such that $0\leq r<n$ and $a=nq+r$ for
some integer $q$.
The third approach also builds on the first. One can show that
congruence modulo $n$ is an equivalence relation on $\Z$, in which
case we have equivalence classes:
\[ [a]_n = \{b\in\Z\mid a\equiv b\pmod n\}.\]
From the comments above, we again get a set with $n$ things, namely
$\{[0]_n, [1]_n, \ldots, [n-1]_n\}$, but with the classes, $[0]_n=[n]_n$, and
$[5]_n=[n+5]_n=[-n+5]_n$.
We can sum up the connections between these points of view as
follows. If $n\in\Z^+$ and $a,b\in \Z$
\[
\begin{array}{ccccc}
\text{Classes} && \text{Relation} && \text{Remainders} \\[1ex]
[a]_n=[b]_n & \iff & a\equiv b\pmod n & \iff & (a\bmod n) = (b \bmod n)
\end{array}
\]
In all cases, we want to be able to add and multiply elements of
$\Zn$. From the point of view of congruences, this says that we can
replace one integer with another it is congruent to when performing
addition or multiplication.
\begin{prop}\label{cong-well-def}
Let $n\in\Z^+$, $a,b,c,d\in \Z$ with
\[ a\equiv b \pmod n \quad\text{and}\quad c\equiv d\pmod n.\]
Then,
\begin{enumerate}
\item $a+c\equiv b+d\pmod n$
\item $ac\equiv bd \pmod n$
\item $a-c\equiv b-d\pmod n$
\end{enumerate}
\end{prop}
We leave the proofs as exercises to the reader. Note, the final part
can be deduced from the first two since $a-c=a+(-1)\cdot c$.
\begin{prob}
Prove Proposition~\ref{cong-well-def}.
\end{prob}
The corresponding statement in terms of congruence classes looks like
this:
\begin{cor}
Let $n\in\Z^+$, $a,b,c,d\in \Z$ with
\[ [a]_n=[b]_n \quad\text{and}\quad [c]_n= [d]_n.\]
Then
\begin{enumerate}
\item $[a+c]_n=[b+d]_n$
\item $[ac]_n= [bd]_n$
\item $[a-c]_n=[b-d]_n$
\end{enumerate}
\end{cor}
Phrased in this way, it shows that addition, multiplication, and
subtraction of congruence classes is well-defined. That is, the
operations can be computed by chosing elements from the classes, and
the final result does not depend on the choices.
Using $\Zn=\{0\cots n-1\}$, we can write down complete addition and
multiplication tables for small $n$. For example, here are the
operation tables for $\Z_4$.
\[
\begin{array}{c|*{4}{|c}}
+ & 0 & 1 & 2 & 3 \\ \hline \hline
0 & 0 & 1 & 2 & 3 \\ \hline
1 & 1 & 2 & 3 & 0 \\ \hline
2 & 2 & 3 & 0 & 1 \\ \hline
3 & 3 & 0 & 1 & 2
\end{array}
\qquad
\qquad
\begin{array}{c|*{4}{|c}}
\cdot & 0 & 1 & 2 & 3 \\ \hline \hline
0 & 0 & 0 & 0 & 0 \\ \hline
1 & 0 & 1 & 2 & 3 \\ \hline
2 & 0 & 2 & 0 & 2 \\ \hline
3 & 0 & 3 & 2 & 1
\end{array}
\]
We consider another instance of something being \emph{well-defined}.
If $[a]_n\in\Zn$, then we would like to define $\gcd([a]_n,n)$ to be
simply $\gcd(a,n)$. Since it is possible for a single congruence
class to be represented by many different integers, we have to prove
that the final result does not depend on this choice.
\begin{prop}
If $n\in\Z^+$ and $a,b\in\Z$ with $[a]_n=[b]_n$, then
$\gcd(a,n)=\gcd(b,n)$.
\end{prop}
\begin{proof} \label{gcd-well-def}
Since $[a]_n=[b]_n$, $a\equiv b\pmod n$, which implies that
\begin{equation}\label{abnk}
a=b+nk
\end{equation}
for some $k\in\Z$. Since $\gcd(b,n)\mid b$ and $\gcd(b,n)\mid n$,
we get from equation~\ref{abnk} that $\gcd(b,n)\mid a$. Since
$\gcd(b,n)\mid n$ as well, we get $\gcd(b,n)\leq \gcd(a,n)$.
We can also solve equation~\ref{abnk} for $b$: $b=a+n(-k)$.
Repeating the same argument with the roles of $a$ and $b$ reversed
gives $\gcd(a,n)\leq \gcd(b,n)$. Together with the first part, we
get $\gcd(a,n)=\gcd(b,n)$.
\end{proof}
\begin{exam}
To see an example where something is \emph{not} well-defined,
supposed we wanted to define $\gcd([a]_n,[b]_n)$ to be $\gcd(a,b)$.
This will not work in general; here is a counterexample. Let $n=3$,
$a=b=1$. Then $\gcd(a,b)=\gcd(1,1)=1$. But, $[1]_3=[4]_3$. On one
hand, we would have $\gcd([1]_3,[1]_3)=1$, and on the other hand
$\gcd([1]_3,[1]_3) = \gcd([4]_3,[4]_3) =\gcd(4,4)=4$. The result
depends on what integers we pick for representing the congruence classes.
\end{exam}
By Proposition~\ref{gcd-well-def}, we can define
\[ \term{\Znstar} = \{[a]_n\in\Zn\mid \gcd(a,n)=1\},\]
and define the Euler phi-function for $n\in\Z^+$:
\[ \term{\varphi(}n) = |\Znstar|.\]
Note, although $\Z_1=[0]_1$ has only one element, $\gcd(0,1)=1$ so
$\Z_1^\times=\{[0_1]\} = \{[1]_1\}$, giving $\varphi(1)=1$.
\section{Groups}
Here we introduce definitions and some notions from group theory. As
we will see, they apply to crytography in many situations and can
unify ideas applied in different places.
We start with something more basic, the notion of a binary operation
which is central to the definition of group.
\subsection{Binary operations}
\begin{defn}
A \term{binary operation} $*$ on a set $S$ is a function
\[ *:S\times S \to S.\]
We write $a*b$ for the value of this function on the ordered pair
$(a,b)\in S$.
\end{defn}
Note:
\begin{itemize}
\item by saying that $*$ is a function, it implies that $a*b$ is defined
for every pair of elements $a,b\in S$.
\item The codomain is $S$, so always $a*b\in S$.
\end{itemize}
\begin{exam}
Three familiar examples are given by addition, subtraction, and
multiplication on $\Z$.
\end{exam}
\begin{exam}
Similarly, addition, subtraction,
and multiplication are each binary operations on $\R$, but division is
not a binary operation since $5\div 0$ is not defined as a real number.
\end{exam}
\begin{exam} On the other hand, division is a binary operation on
$\R^\times$.
\end{exam}
There are several properties of interest which a binary operation may
satisfy.
\begin{defn}
Let $*$ be a binary operation on a set $S$.
\begin{itemize}
\item $*$ is \term{associative} if for all
$a,b,c\in S$,
\[ a*(b*c)=(a*b)*c.\]
\item $*$ is \term{commutative} if for all $a,b\in S$,
\[ a*b = b*a.\]
\item $*$ has \term{identity} $e$ if $e\in S$ and for all $a\in S$,
\[ a*e=e*a=a.\]
\end{itemize}
\end{defn}
\begin{exam}
Addition and multiplication on $\Z$ are both commutative,
associative, and have identity ($0$ for addition and $1$ for
multiplication). Note, subtraction is neither commutative ($3-5\neq
5-3$) nor associative ($1-(2-3)\neq (1-2)-3$), and does not have an
identity element.
\end{exam}
\begin{prob}
Prove that $\Z$ does not have an identity element under subtraction.
\end{prob}
Our first proposition shows that if there is an identity element for a
binary operation, then it is unique.
\begin{prop} \label{unique-identity}
If $*$ is a binary operation on a set $S$, then there is at most one
identity element for $*$.
\end{prop}
\begin{proof}
Suppose to contrary that $e$ and $e'$ are both identity elements
for $*$ on $S$. Then
\begin{align*}
e*e' &= e \text{ since $e'$ is an identity element, and} \\
e*e' &= e' \text{ since $e$ is an identity element.}
\end{align*}
Thus $e=e'$.
\end{proof}
We have one more definition.
\begin{defn}
Let $*$ be a binary operation on a set $S$ which has identity $e$.
If $a\in S$, we say that $b\in S$ is an \term{inverse} of $a$ if
\[ a*b=b*a=e.\]
\end{defn}
When an inverse exists, it is unique.
\begin{prop} \label{unique-inverse}
Let $*$ be an associative binary operation on a set $S$ which has
identity $e$, and $a\in S$. Then $a$ has at most one inverse in
$S$.
\end{prop}
\begin{proof}
Suppose $b$ and $c$ are both inverses of $a$. Then
\[ b*(a*c) = b*e= b\]
and
\[ (b*a)*c = e*c=c.\]
Since the operation is associative, $b*(a*c)=(b*a)*c$, so $b=c$.
\end{proof}
\begin{exam}
In $\Z$ under addition where $0$ is the identity, every integer
$n\in\Z$ has an inverse $-n$ because $n+(-n) = 0=(-n)+n$. On the
other hand, for $\Z$ under multiplication (where $1$ is the identity),
the only elements with inverses are $1$ and $-1$ (because $1\cdot 1 =
1$ and $(-1)\cdot (-1) = 1$).
\end{exam}
\begin{notation}
In almost every binary operation we encounter, it will already be
naturally an addition or a multiplication. Addition in every case
will be commutative, and we will only use $+$ for binary operations
which are commutative. In these cases, the inverse of $a$ will be
denoted by $-a$.
In other cases, we will generally use $\cdot$ instead of $*$ for the
operation, or use no symbol at all for the operation and just write
$ab$ for $a*b$. In these cases, we are not assuming the operation
is commutative unless it is explicitly mentioned. The inverse of an
element $a$ (if it exists) is then denoted by $a^{-1}$.
\end{notation}
\subsection{Definition of group}
\begin{defn}
A \term{group} is a set $G$ with a binary operation $*$ such that
\begin{enumerate}
\item $*$ is associative
\item $G$ has an identity element for $*$
\item every element of $G$ has an inverse.
\end{enumerate}
\end{defn}
\begin{exam}
Addition is a group operation on many familiar sets: $\Z$, $\Q$,
$\R$, $\C$. Note, $\Z^+$ is not a group for addition because it
does not have an identity element. Similarly, $\mathbb N$ is not a
group for addition because it contains elements which do not have
inverses (such as $3$, or $5$, or any positive integer).
\end{exam}
\begin{exam}
Multiplication is a group operation on other familiar sets:
$\Q^\times$, $\R^\times$, $\C^\times$, and $\R^+$.
\end{exam}
% \begin{exam}
% The one element set $G=\{0\}$ is a group under addition. The
% identity element is of course $0$ (it is the only option), and $0$
% is its own inverse.
% In fact, $\{0\}$ is a group under multiplication. In this case, $0$
% functions as the identity for multiplication, and since $0\cdot
% 0=0$, it is also its own inverse.
% In fact, these two examples are the same. The set is the same
% $\{0\}$, and the binary operation is the same (i.e., the function
% $G\times G\to G$ has a unique ordered pair $((0,0), 0)$ in both
% cases). The only difference is the notation we use for the binary
% operation.
% \end{exam}
\begin{remark}
From Propositions \ref{unique-identity} and \ref{unique-inverse}, we
know that the identity element of a group is unique and that each
element has a unique inverse.
\end{remark}
\begin{defn}
A group $G$ is \term{abelian} if the operation is commutative.
\end{defn}
It might seem more natural to call these groups commutative groups,
but the terminology is universally accepted in
mathematics\footnote{The term \em{abelian} comes from the name of a
mathematician, Abel.}. The additive and multiplicative groups given
above are all abelian. Here is an example which is not.
\begin{exam}
Let $G=\GL_2(\R)$, the set of $2\times 2$ matrices over the real
numbers non-zero determinant. This is a group under matrix
multiplication with identity being the $2\times 2$ identity matrix
and inverses being inverse matrices (using that for $2\times 2$
matrices over $\R$, a matrix has an inverse if and only if it
has non-zero determinant). However, this group
is not commutative.
\end{exam}
\section{Subgroups}
We often have groups which are subsets of bigger groups. Suppose $G$
is a group and $H\seq G$.
If we restrict the domain of the binary operation from
$G\times G$ to $H\times H$, and then want the results to always lie in
$H$. In other words, for all $a,b$,
\[ a,b\in H \implies a*b\in H.\]
When this happens, we say that $H$ is \term{closed under} $*$.
\begin{defn}
If $G$ is a group with operation $*$ and $H\seq G$, then we say that
$H$ is a \term{subgroup} of $G$ if
\begin{enumerate}
\item $H$ is closed under $*$,
\item the identity element $e$ for $G$ is in $H$,
\item for all $a\in H$, its inverse (in $G$) is contained in $H$.
\end{enumerate}
\end{defn}
One could say that a subset is a subgroup if it is closed under the
binary operation, contains the identity, and is closed under
inverses.
Our definition is not an literal match to the concept (subset which is
also a subgroup). The missing steps are explored in the exercises.
\begin{exam}
Addition is a binary operation on $\R$. If we restrict to rational
numbers $a,b\in\Q$, then $a+b\in\Q$, so $\Q$ is closed for $+$.
\end{exam}
\begin{exam}
On the other hand, division is a binary operation on $\Q^+$, the set
positive rational numbers. However, if we try to restrict to
positive integers $a,b\in\Z^+$, then $a\div b$ is a positive
rational number, but it need not be a positive integer. For
example, $3\div 7\not\in\Z^+$. So $\Z^+$ is not closed under
division.
\end{exam}
The first problem makes it easier to prove that an element of a group
is the identity element.
\begin{prob} \label{ident-prob}
Let $G$ be a group with identity $e$. Then $c*c=c$ if and only if $c=e$.
\end{prob}
\begin{prob}
We would like to define subgroup as follows: ``If $G$ is a group and
$H\seq G$, then $H$ is a \emph{subgroup} of $G$ if the binary
operation for $G$ induces a binary operation on $H$ and $H$ is a
group for that operation.'' A subset which is a subgroup under our
definition definitely satisfies this definition as well. To show
the implication goes both ways, prove that if $H$ satisfies the
quoted statement, then
\begin{enumerate}
\item $H$ is closed for $*$,
\item $e_G=e_H$ (hint, use problem~\ref{ident-prob})
\item for all $a\in H$, the inverse of $a$ in $G$ is in $H$.
\end{enumerate}
\end{prob}
\section{Groups acting on sets}
Groups are fun, but they are much more fun when they are doing
something, like acting on a set.
\begin{defn}
Let $G$ be a group and $S$ a set. An \term{action} of $G$ on $S$ is a
function
\[ \cdot:G\times S\to S\]
such that
\begin{enumerate}
\item for all $s\in S$, $e\cdot s = s$ where $e$ is the identity of
$G$;
\item for all $g_1, g_2\in G$ and all $s\in S$, $g_1\cdot (g_2\cdot
s) = (g_1g_2)\cdot s$.
\end{enumerate}
\end{defn}
In the second condition, both dots on the left hand side represent the
action where as $g_1g_2$ on the right hand side is multiplication
within the group.
We will see several examples of group actions in the next section
where they have applications to cryptography, so we just give two
quick ones now.
\begin{exam}
The group $G=\Z$ acts on $S=\R$ by $n\cdot a=n+a$. In other words,
we use addition to define the action.
\end{exam}
\begin{prob}
Prove that the action of $\Z$ on $\R$ given by $n\cdot a=n+a$ is a
group action.
\end{prob}
\begin{exam} If $G$ is a group, define an action of $G$ on $G$ by $g\cdot
a=ga$. In other words, we use the group operation to define the
action. This particular action is famous and is known as \term{left
translation}.
\end{exam}
\begin{prob}
Prove that if $G$ is a group, then left translation gives a
group action.
\end{prob}
\section{Cryptosystems from group actions}
For background and notation for cryptosystems, see Section~\ref{crypto-101}.
Suppose $G$ is a group which acts on a set $A$, and we find a
way to match elements of $A$ with the plaintexts. Then we will let
$A$ also be the set of ciphertexts, and $G$ is the set of keys. Given
a key $k\in G$ and a plaintext $P\in A$, our encryption function is
\[ e_k(P) = k\cdot P\]
where the right hand side comes from the group action. The decryption
function uses the inverse of $k$ in the group:
\[ d_k(C) = k^{-1}\cdot P\]
To check that this works, we compute:
\begin{align*}
d_k(e_k(P)) &= d_k(k\cdot P) \\
&= k^{-1}\cdot (k\cdot P) \\
&= (k^{-1}k)\cdot P & \text{property 2 of group action} \\
&= e\cdot P \\
&= P & \text{property 1 of group action}
\end{align*}
We now consider some classic ciphers, and see how they are examples of
this one idea.
\subsection{Shift Cipher}
For the \term{shift cipher},
$\calP=\calC=\calA=\calK=\Zn=G$.
We let $G$ act on itself by left
translation, so for a key $k\in G$, our encryption is given by
\[ e_k(p) = p+k\]
where the addition is taken modulo $n$ since we are working in $\Zn$.
Decryption is simply
\[ d_k(c) = c-k.\]
\subsection{Affine Cipher}
For the \term{affine cipher}, we let $\calA=\calP=\calC=\Zn$.
Our group is
the \term{affine group modulo $n$}:
\[ \textit{Aff}(n) = \{ ax+b\mid a\in \Zn^\times\text{ and } b\in\Zn\}\]
where the operation is composition.
\begin{prob}
Verify that if $n\in\Z^+$, then $\textit{Aff}(n)$ is a group.
\end{prob}
If $ax+b\in \calK= \textit{Aff}(n)$, then $ax+b$ acts on $m\in \Zn$ by
\[ (ax+b)\cdot m = am+b\]
with the computation done modulo $n$. This gives encryption functions
\[ e_{ax+b}(p) = ap+b.\]
Since $a\in \Z_n^\times$,
there exists $a'\in\Z_n^\times$ such that $aa'\equiv 1\pmod n$. Then
\[d_{ax+b}(c) = a'(c-b).\]
\subsection{Hill Cipher}
For the \term{Hill cipher}, we let $\calA=\Zn$ and pick
$m\in\Z^+$. Then we take $\calP=\calC=\Z_n^m$.
The group
\[ G=\GL_m(\Zn)=\{A\in M_m(\Zn)\mid \det(A)\in \Z_n^\times\}\]
is the group of matrices over $\Zn$ which are invertible for matrix
multplication. It acts on $\Z_n^m$ in the usual way of matrix times
vector.
If $A\in \calK=\GL_m(\Zn)$ and $\vec p \in \Z_n^m$, then encryption is
\[ e_A(\vec p) = A\vec p\]
and decryption is
\[ d_A(\vec c) = A^{-1}\vec c,\]
where $A^{-1}$ is the inverse of $A$ modulo $n$.
\subsection{Permutation Cipher}
Let $n\in\Z^+$. A \term{permutation} on a set $A$ is a bijective
function $f:A\to A$. The \term{symmetric group} on $A$ is
\[ S_A = \{ f:A\to A\mid \text{$f$ is a permutation}\}.\]
This is a group under composition:
\begin{itemize}
\item the composition of bijective functions is bijective
\item function composition is always associative
\item the identity function $I_A:A\to A$ given by $I_A(a)=a$ for all
$a\in A$ acts as the identity under composition
\item bijective functions have inverse functions (which are also bijective)
\end{itemize}
For any set $A$, $S_A$ acts on $A$ by $f\cdot a=f(a)$ for any $f\in S_A$ and any
$a\in A$.
In the special case of $A=\{1\cots n\}$, we write $S_n$ for the set of
permutations. Then $S_n$ acts on $n$ tuples from another set $B$ by
\[ \sigma \cdot (b_1\cots b_m) = (b_{\sigma(1)}\cots b_{\sigma(n)}).\]
So, we fix $n$ and take $\calA^n=\calP=\calC$ and $\calK=S_{n}$. If
$\sigma\in S_n$, encoding is given by
\[ e_\sigma(a_1\cots a_n) = (a_{\sigma(1)}\cots a_{\sigma(n)})\]
and decoding by
\[ d_\sigma(a_1\cots a_n) = (a_{\sigma^{-1}(1)}\cots a_{\sigma^{-1}(n)}).\]
\subsection{Substitution Cipher}
If $\calA$ is our alphabet, we let $\calP=\calC=\calA$ and key space
$\calK=S_\calA$.
Then for any $f\in S_\calA$, we encrypt and decrypt by
\[ e_f(p) = f(p) \quad\text{ and }\quad d_f(c) = f^{-1}(c).\]
Many other ciphers are special cases of the substitution cipher, such
as shift, affine, and RSA. If $n=|\calA|$, then the size of the key
space is $n!$, which grows very quickly. This means that to
communicate a key with large $n$, one must transmit many bits. The
more specialized ciphers have smaller key spaces, and hence,
transmitting the key is easier. If $\calA$ is an ordinary alphabet
from a natural language, then this cipher can be readily attacked with
frequency analysis.
\subsection{Vigen\`ere Cipher}
\label{vigenere}
We first introduce a way to construct new groups from others which
we will need later.
If $G_1$ and $G_2$ are groups with operations $*_1$ and $*_2$, then
we can make $G_1\times G_2$ into a group with the operation
\[ (a_1,a_2)*(b_1,b_2) = (a_1*_1 b_2, a_2*_2 b_2) \]
It has identity $(e_1, e_2)$ and the inverse of an element $(a_1,a_2)$
is $(a_1^{-1}, a_2^{-2})$ where the inverses are computed in $G_1$
and $G_2$ respectively. The resulting group is called the {\em
direct product} of $G_1$ and $G_2$, and is denoted $G_1\times G_2$.
In some cases, it may also be denoted by $G_1\oplus G_2$.
This construction can be iterated with a list of groups
$G_1\cots G_n$. The elements then are $n$-tuples where the $i$th
coordinate comes from $G_i$.
For a Vigen\`ere cipher, we take $m$ to be a positive integer, and let
$\calP=\calC=\calA^m$. Let $n=|\calA|$ and identify $\calA$ with
$\Zn$. Our group is $G=\Zn\times\Zn\times\cdots \times \Zn$ where we
use $m$ copies of $\Zn$. So a key is an $m$-tuple of elements of
$\calA$, i.e., an $m$-letter word. The group action is $G$ acting on
itself by left translation.
\subsection{RSA}
The main feature of RSA is that it is a public key cryptosystem. But
under the hood, it works on the same principle of groups acting on
sets.
Let $N$ be a positive integer which is a product of distinct primes.
We let $\calP=\calC=\Z_N$. The traditional choice for the group is
$G=\calK=\Z_{\varphi(N)}^\times$. It acts on $\Z_N$ as follows
\begin{align*}
\Z_{\varphi(N)}^\times\times\Z_N &\to \Z_N \\
(a, b) &\mapsto b^a
\end{align*}
For encryption, we pick a key $a$ such that $\gcd(a, \varphi(N))=1$,
i.e., such that $a\in\Z_{\varphi(N)}$ and then
\[ e_a(m) = m^a \bmod N.\]
For decryption, we find $b$ such that $ab\equiv 1\pmod{\varphi(N)}$,
but this is just $a^{-1}\in\Z_{\varphi(N)}^\times$ and
\[ d_a(c) = c^b\bmod N.\]
It may be hard to see why we take the hypothesis that the prime
factors of $N$ must be distinct. We illustrate the problem with an
example.
\begin{exam}
Let $N=9=3^2$, so $\varphi(N) = 6$. Then $1\equiv 7
\pmod{\varphi(N)}$ and certainly $\gcd(1,6)=1$, so $1\in
\Z_6^\times$. If we compute the group action with $1$ and
$3\in\Z_9$, we get $3^1=3$, but if we use $7$, we get $3^7\equiv
0\pmod 9$, a different result. This is not a group action because
the ``action'' needs to be a function, and it is not well-defined.
\end{exam}
\begin{prob}
Suppose $N$ is a product of distinct primes and $m=\varphi(N)$.
Prove that if $[a]_m=[b]_m\in\Z_m$ and $[c]_N\in\Z_N$, then $[c^a]_N=[c^b]_N$.
\end{prob}
\subsection{LFSRs}
For background on LFSRs, see Chapter~\ref{lfsr}.
If an $n$-stage LFSR has associated matrix $C\in\GL_n(\Z_2)$, then
groups enter directly since the order of $C$ in the group
$\GL_n(\Z_2)$ gives the longest period one can achieve from the LFSR.
In general, if a group $G$ acts on a set $S$, we can make a stream
cipher with one more ingredient, a function $f:S\to\{0,1\}$. Then
we choose an element $g\in G$ and an initial
element $s_0\in S$. We construct a sequence of elements of $S$, and
the corresponding stream of $x_i \in \{0,1\}$ via
\[ s_n = g\cdot s_{n-1} \qquad x_n = f(s_n).\]
In the case of an LFSR, the group is $\GL_n(\Z_2)$, the set
$S=\Z_2^n$, and the action is the usual matrix times vector giving
vector. Then $g=C$, the matrix associated to the LFSR, and
$s_0\in\Z_2^n$ is the initial load of the LFSR. The function $f$ is
given by $f(a_1,\ldots, a_n) = a_n$.
\subsection{Pseudo-random number generators}
It is worth noting that a small generalization of this construction
produces another important object in cryptography. Many aspects of
cryptography make use of random number numbers. Often times, these
need not be truely random, and a computer language's random number
generator is good enough. These are not random; they are completely
determined by the algorithm used and an initial seed.
A commonly used pseudo-random number generator is a {\em linear
congruenential generator}. Suppose you want pseudo-random numbers
in $\Z_{2^k}$. Then pick a large positive integer $m>2^k$, $a\in\Z_m^\times$, and
$b\in\Z_m$. Starting with an initial seed $s_0\in \Z_m$, we construct
the sequence defined recursively by $s_n = as_{n-1}+b \bmod m$. The
random numbers are then given by something like taking the top
$k$-bits of $s_n$, i.e., it uses a function $f:\Z_m\to \Z_{2^k}$ which
extracts $k$ bits.
This fits our setup for a stream cipher from a group action where
\[G=\textit{Aff}(m) = \{ax+b\mid a\in\Z_m^\times\text{ and }
b\in\Z_m\}\]
and $S=\Z_m$ (the action given by plugging a value into the linear
polynomial). The only difference is the codomain of the function
$f$. In a stream cipher, it would be a function $f:S\to \Z_2$; for
the random number generator, it is $f:S\to \Z_{2^k}$.
\section{Isomorphisms and homomorphisms}
Consider the following two operation tables for $\{1,-1\}$ under
multiplication and $\Z_2$:
\[
\begin{array}{c||c|c}
\cdot & 1 & -1 \\ \hline\hline
1 & 1 & -1 \\ \hline
-1 & -1 & 1
\end{array}
\qquad
\begin{array}{c||c|c}
+ & 0 & 1 \\\hline\hline
0 & 0 & 1 \\ \hline
1 & 1 & 0
\end{array}
\]
Then we can get from the table on the left to the table on
the right by simply renaming elements systematically. In
particular, if we take the table on the left and use the
following replacements:
\begin{align*}
1 &\mapsto 0\\
-1 &\mapsto 1
\end{align*}
This is the idea of an isomorphism. Renaming elements from one set
to elements of another is formalized as a bijective function between
the sets $f:G_1\to G_2$.
The idea that the group tables match up can be thought of elements
$a\in G_1$ have their old name, $a\in G_1$, and a new name
$f(a)\in G_2$. Then the group tables matching after renaming amounts
to,
\begin{quote}
if we take any two elements of $G_1$, multiply in $G_1$, and then rename
the result, it is the same as first renaming the elements and then
multiplying them in $G_2$.
\end{quote}
Formally, this leads to
\begin{defn}
If $G_1$ is a group with operation $*$ and $G_2$ is a group with
operation $*'$, then an \term{isomorphism} from $G_1$ to $G_2$ is a
bijective function
\[ f:G_1\to G_2\]
such that
\[ f(a*b) = f(a)*'f(b)\qquad\text{for all $a,b\in G_1$.}\]
We then say that $G_1$ and $G_2$ are \emph{isomorphic} and write
$G_1\cong G_2$.
\end{defn}
The idea of ``same except for renaming of elements'' should behave
like an equivalence relation. The formal proof of this is left
as a sequence of exercises.
\begin{prob}
Prove that every group is isomorphic to itself. (Hint: for any
set $G$, there is a simple bijective function $G\to G$.)
\end{prob}
\begin{prob}
Suppose $G_1$ is isomorphic to $G_2$. Prove that $G_2$ is isomorphic
to $G_1$. (Hint: the hypothesis gives you a bijective function
$G_1\to G_2$; you need to start by constructing a bijective function
$G_2\to G_1$.
\end{prob}
\begin{prob}
Suppose $G_1$ is isomorphic to $G_2$ and $G_2$ is isomorphic to $G_3$.
Prove $G_1$ is isomorphic to $G_3$.
\end{prob}
Here is an example of an isomorphism from familiar objects.
\begin{prob}
Prove that the group $\R$ under addition is isomorphic to the group
$\R^+$ under multiplication. (Hint: try an exponential map.)
\end{prob}
It is useful to consider functions between groups which respect the
operations, but are not necessarily bijective:
\begin{defn}
If $H$ is a group with operation $*$ and $K$ is a group with
operation $*'$, then a function
\[ f:H\to K\]
such that
\[ f(a*b) = f(a)*'f(b)\qquad\text{for all $a,b\in H$}\]
is called a \term{homomorphism} from $H$ to $K$.
\end{defn}
\begin{exam}
The inclusion map $i:\Z\to \Q$ (defined by $i(n)=n$ for all integers
$n$) is a homomorphism which is 1-1, but not onto.
\end{exam}
\begin{exam}
If $n$ is a positive integer, the map $f:\Z\to \Zn$ given by
\[ f(a) = \text{ the congruence class of $a$ modulo $n$} \]
is a homomorphism called the \term{reduction map}. It is onto, but
not 1-1.
\end{exam}
\begin{exam}
If $H$ and $K$ are any two groups, the constant function $f:H\to K$
given by $f(a)=e_K$ for all $a\in H$ is a homomorphism, called the
\term{trivial map}. If $H$ and $K$ have more than one element each,
it is neither 1-1 nor onto.
\end{exam}
We collect the basic properties of homomorphisms in the next proposition.
\begin{prop}
If $f:H\to K$ is a group homomorphism, then
\begin{enumerate}
\item $f(e_H) = e_K$
\item for all $h\in H$, $f(h^{-1})=f(h)^{-1}$
\end{enumerate}
\end{prop}
\begin{proof}
We start by noting that $f(e_H)=f(e_H*e_H) = f(e_H)f(e_H)$, so $f(e_H)=e_K$ by
exercise~\ref{ident-prob}.
Let $h\in H$. We prove the second part by showing $f(h^{-1})$ does the job of an
inverse. So we compute
\[ f(h)f(h^{-1}) = f(hh^{-1}) = f(e_H) = e_K\]
and
\[ f(h^{-1})f(h) = f(h^{-1}h) = f(e_H) = e_K\,.\]
So, $f(h^{-1}) = f(h)^{-1}$.
\end{proof}
\begin{exam}
In linear algebra, one considers vector spaces and linear
transformations between them. According to the definitions,
every vector space is an abelian group for $+$, and every
linear transformation is a homomorphism.
\end{exam}
An important construction for homomorphsims is its kernel. In
the linear algebra situation, this is the same as the kernel, which
is also called the null space.
\begin{defn}
If $f:G\to K$ is a group homomorphism, the \term{kernel} of $f$ is
\[ \term{\ker}(f) = \{g\in G\mid f(g) = e_K\}.\]
\end{defn}
\begin{prob}
Suppose $f:G\to K$ is a homomorphism. Prove $\ker(f)$ is a subgroup
of $G$.
\end{prob}
An important family of examples of homomorphisms applies to any
abelian group.
\begin{exam}
Suppose $G$ is an abelian group and $m\in\Z$. Then the {\em
multiplication by $m$ map} in additive notation is defined by
\begin{align*}
[m]:G&\to G \\
g&\mapsto mg
\end{align*}
If we are using multiplicative notation, $[m](g) = g^m$. This is a
homomorphism whenever $G$ is abelian.
\end{exam}
Our main interest is the case when $m\in\Z^+$.
\begin{prob}
Suppose $G$ is an abelian group written multiplicatively and
$m\in\Z^+$. Prove that the multiplication by $m$ map is a