Maths Project
Maths Project
Department of Mathematics
NSS Hindu College
Changanacherry , Kottayam
Kerala – 686 102
Certificate
of their original work at this centre. Ms. Parvathy Haridas has been
The Principal
NSS Hindu College
Changanacherry
Changanacherry
Certificate
Changanacherry
Certificate
University.
Changanacherry
i
Acknowledgement
We would like to express our sincerest thanks to our project guide Ms.
Parvathy Haridas, for her valuable guidance that has greatly helped in
the completion of this work. We also cordially thank Dr. Sujatha S , the
Principal of NSS Hindu College, Changanacherry and Dr. Preethi K
Pillai, the Head of the Department of Mathematics for providing the
necessary facilities for the research associated with the project. Finally,
we extend our heartfelt gratitude to all the mathematicians who have
contributed considerably to the subject. Their works have served as the
resources for our research work without which we could not have
completed this project.
Arsha P
S Sivahari
Revathy S
Changanacherry
ii
Abstract
iii
Contents
Declaration i
Acknowledgement ii
Abstract iii
Contents iv
Introduction 1
Chapter 1 : Preliminaries 3
Chapter 2 : The Basics of Cryptography 8
Chapter 3 : Symmetric Encryption 12
Chapter 4 : Cryptanalysis 18
Chapter 5 : Public Key Cryptography 23
Chapter 6 : The Discrete Logarithm Problem 29
Conclusion 32
References 33
iv
Introduction
1
Digital signatures play a crucial role in verifying the authenticity and integrity of
digital messages or documents. They are generated using asymmetric-key
cryptography, where the sender signs a message with their private key and the
recipient can verify the signature using the sender’s public key. Key exchange
protocols are another critical aspect of mathematical cryptography, enabling two
parties to establish a shared secret key over an insecure communication channel.
One widely used key exchange protocol is the Diffie-Hellman key exchange,
which allows two parties to negotiate a shared secret key without ever
transmitting the key itself. In addition to encryption and key exchange,
mathematical cryptography encompasses various cryptographic protocols and
algorithms designed to address specific security requirements such as secure
multiparty computation, homomorphic encryption and zero-knowledge proofs.
Overall, mathematical cryptography plays a crucial role in securing modern
communication systems, financial transactions and sensitive data. By leveraging
mathematical concepts and principles, cryptographic techniques provide robust
protection against unauthorised access, tampering and forgery, ensuring the
confidentiality, integrity and authenticity of digital information.
In this project, we particularly focus on the mathematical underpinnings of
cryptography which intersect several fields of mathematics including number
theory, linear algebra, abstract algebra, etc. We try to unravel the seemingly
convoluted concepts of various cryptosystems by exploring the underlying
mathematical foundation and the necessary concepts associated with it.
2
CHAPTER 1
PRELIMINARIES
3
Definition 1.6 (The Euclidean Algorithm)
Let a and b be two integers
a = q1b + r1 0 < r1 < b
b = q2r1 + r2 0 < r 2 < rl
rl = q3r2 + r3 0 < r3 < r 2
4
Definition 1.8 (Euler’s phi function)
For n 1, the Euler’s phi function (n) denote the number of positive integers not
exceeding n that are relatively prime to n.
Theorem 1.5 (Euler’s theorem)
If n 1 and gcd(a, n) = 1, then a(n) 1 (mod n)
Theorem 1.6 (Fermat’s theorem)
Let p be a prime and suppose that p does not divide a. Then ap - l 1 (mod p).
Theorem 1.7
(n) is multiplicative
Theorem 1.8
If the integer n > 1 has the prime factorization n = p1k1 p2k2 ... prkr, then
(n) = (p1k1 – p1k1 – 1) (p2k2 – p2k2 – 1) ... (prkr – prkr – 1)
= n (1 – 1/p1) (1 – 1/p2) ... (1 – 1/pr)
Definition 1.9 (Order of a(mod n))
Suppose that gcd(a,n) = 1. We define the order of a(mod n) to be the smallest
positive integer b such that
ab 1 (mod n)
and write b = ordn (a)
Definition 1.10 (Primitive root)
If gcd(a,n) = 1 and ordn(a) = (n) then we say that a is a primitive root of n.
Definition 1.11 (Multiplicative inverse modulo n)
A multiplicative inverse of a modulo n is an integer b such that ab 1(mod n).
Definition 1.12 (Group)
Let G be a set together with a binary operation that assigns to each ordered pair
(a, b) of elements of G an element in G denoted by ab. We say G is a group under
this operation if the following three properties are satisfied :
1. Associativity. The operation is associative; that is, (ab)c =a(bc) for all a, b, c in
G.
5
2. Identity. There is an element e (called the identity) in G such that ae = ea = a
for all a in G.
3. Inverses. For each element a in G, there is an element b in G, (called an inverse
of a) such that ab = ba= e
Definition 1.13 (Abelian group)
If a group has the property that ab = ba for every pair of elements a and b, we say
the group is Abelian.
Definition 1.14 (Additive group modulo n)
The Additive Group of Integers Modulo n is the group with domain{0 , 1, 2 , … ,
n-1} and with the operation of mod n addition. It is denoted as ℤn.
Definition 1.15 (Cyclic Group)
A group G is called cyclic if there is an element a in G such that G = {an | n ℤ}.
Such an element a is called a generator of G.
Definition 1.16 (Ring)
A ring R is a set with two binary operations, addition (denoted by a + b) and
multiplication (denoted by ab), such that for all a, b, c in R
1. a + b = b + a
2. (a + b) + c = a + (b + c)
3. There is an additive identity 0, i.e., there exits an element 0 in R such that
a + 0 = a for all a in R
4. There is an element -a in R such that a + (- a) = 0
5. a(bc) = (ab)c
6. a(b+c) = ab + bc and (b+c)a = ba + ca
Definition 1.17 (Commutative ring)
A ring is said to be commutative when multiplication is commutative.
Definition 1.18 (Unity and Unit of a ring)
A unity in a ring is a nonzero element that is an identity under multiplication.
A non-zero element of a commutative ring with unity that has a multiplicative
inverse is called a unit of the ring. Thus, a is a unit if a -1 exists.
Definition 1.19 (Field)
A field is a commutative ring with unity in which every nonzero element is a unit.
6
Theorem 1.9
For every prime p , ℤp is a field.
Definition 1.20 (Quadratic residue modulo p)
Suppose p is an odd prime and a is an integer. a is defined to be a quadratic
residue modulo p if
a ≡ 0 (mod p) and the congruence y2 ≡ a (mod p) has a solution y ∈ ℤp.
a is defined to be a quadratic non-residue modulo p if a ≡ 0 (mod p) and a is not
a quadratic residue modulo p.
Theorem 1.10 (Euler’s Criterion)
Let p be an odd prime. Then a is a quadratic residue modulo p if and only if
a(p−1)/2 ≡ 1 (mod p).
7
CHAPTER 2
THE BASICS OF CRYPTOGRAPHY
2.1 Introduction
(sender) (receiver)
8
The various components of the model are explained as follows :
1. The plaintext is the original data that has to be protected during transmission
from sender to receiver. This is also often referred to as the message. The
intention is to make the disguise the plaintext so that only the sender and the
receiver can read it. In particular, an interceptor cannot determine the
plaintext.
2. The encryption algorithm is a cryptographic algorithm that takes as input a
plaintext and an encryption key, and outputs a ciphertext. The choice of
encryption algorithm must be agreed between sender and receiver.
3. The ciphertext is the encrypted version of the plaintext. It is sometimes
referred to as the cryptogram. The ciphertext is not a secret and can be
obtained by anyone who has access to the communication channel.
4. The decryption algorithm is the set of rules that determines, for any given
ciphertext and decryption key, a unique plaintext. It reverses an encryption
algorithm.
5. The encryption key is a value that is known to the sender. The sender inputs
the encryption key into the encryption algorithm along with the plaintext in
order to compute the ciphertext. The receiver also usually knows the
encryption key.
6. The decryption key is a value that is known to the receiver. The decryption
key is related to the encryption key, but is not always identical to it. The
receiver inputs the decryption key into the decryption algorithm along with
the ciphertext in order to compute the plaintext. The interceptor must not know
the decryption key. It may or may not be known by the sender. The collection
of all possible decryption keys is called the keyspace.
7. An interceptor (an adversary or an attacker) is an entity other than the sender
or receiver who attempts to determine the plaintext. The interceptor will be
able to see the ciphertext. He may or may not know the encryption algorithm,
the decryption algorithm and the encryption key. However the one piece of
information that the interceptor must never know is the decryption key.
9
2.3 Two Types of Cryptosystem
There are two different types of cryptosystem – the symmetric or private-key
cryptosystem and the asymmetric or the public-key cryptosystem.
10
For each public key kpub there is a corresponding encryption function
ek pub : M → C , and for each private key kpriv there is a corresponding decryption
function dk priv : C → M.
These have the property that if the pair (kpriv , kpub) is in the key space K , then dk
priv (ek pub (m)) = m for all m ∈ M.
11
CHAPTER 3
SYMMETRIC ENCRYPTION
Symmetric Algorithms are what many people assume cryptography is about: two
parties have an encryption and decryption method for which they share a secret
key. All cryptography from ancient times until 1976 was exclusively based on
symmetric methods. Symmetric ciphers are still in widespread use, especially for
data encryption and integrity check of messages. Here we discuss some of the
symmetric ciphers in detail.
3.1 The Shift Cipher
The concept of shift cipher itself is simple : we simply shift every plaintext letter
by a fixed number of positions in the alphabet. For instance, if we shift by 3
positions, a would be substituted by d, b by e, etc. (this three-position shift is
called the Caesar cipher). We would use the Shift Cipher (with a modulus of 26)
to encrypt ordinary English text by setting up a correspondence between
alphabetic characters and residues modulo 26 as follows :
a b c d e f g h i j k l m
0 1 2 3 4 5 6 7 8 9 10 11 12
n o p q r s t u v w x y z
13 14 15 16 17 18 19 20 21 22 23 24 25
Example 3.1
Let the key for the shift cipher be K = 16 and the plaintext be ‘rhythm’
The encryption is as follows.
12
Plaintext r h y t h m
x 17 7 24 19 7 12
x + 16 33 23 40 35 23 28
ek(x) = x+16 (mod 26) 7 23 14 9 23 2
Ciphertext h x o j x c
Thus the message ‘rhythm’ gets encrypted as ‘hxojxc’ before being sent to the
recipient. It can be decrypted back to ‘rhythm’ as follows.
Ciphertext h x o j x c
y 7 23 14 9 23 2
y – 16 -9 7 -2 -7 7 -14
dk(y) = y – 16 (mod 26) 17 7 24 19 7 12
Plaintext r h y t h m
Example 3.2
Here is an example of a random permutation
a b c d e f g h i j k l m
Y V W F D B E U A T C O G
13
n o p q r s t u v w x y z
J H K S X Z L N Q I R P M
The decryption function is the inverse permutation. This is formed by writing the
second lines first, and then sorting in alphabetical order. The following is obtained
A B C D E F G H I J K L M
i f k e g d m o w n p t z
N O P Q R S T U V W X Y Z
u l y v x q j h b c r a s
14
Example 3.3
Let us encrypt the message ‘hello’ using the key K = (7, 2)
Plaintext h e l l o
x 7 4 11 11 14
7x + 2 51 30 79 79 100
ek(x) = 7x + 2 (mod 26) 25 4 1 1 22
Ciphertext z e b b w
In both the Shift Cipher and the Substitution Cipher, once a key is chosen, each
alphabetic character is mapped to a unique alphabetic character. For this reason,
these cryptosystems are called monoalphabetic cryptosystems.
15
Example 3.4
Let us encrypt the plaintext ‘math is fun’ using the keyword ‘jim’. Here m = 3
and the corresponding numerical equivalent K = (9, 8, 12)
Plaintext m a t h i s f u n
xi 12 0 19 7 8 18 5 20 13
Keyword j i m j i m j i m
ki 9 8 12 9 8 12 9 8 12
xi + ki (mod 26) 21 8 5 16 16 4 14 2 25
Ciphertext v i f q q e o c z
Ciphertext v i f q q e o c z
yi 21 8 5 16 16 4 14 2 25
Keyword j i m j i m j i m
ki 9 8 12 9 8 12 9 8 12
yi - ki (mod 26) 12 0 19 7 8 18 5 20 13
Plaintext m a t h i s f u n
16
Example 3.5
Suppose m = 6 and the key is the following permutation π
x 1 2 3 4 5 6
π 4 5 1 6 3 2
-1 3 6 5 1 2 4
17
CHAPTER 4
CRYPTANALYSIS
18
(iii) chosen-plaintext attacks require the attacker to know the encryption
algorithm and some plaintext/ciphertext pairs that correspond to
plaintexts chosen by the attacker
(iv) chosen ciphertext attack where the opponent has obtained temporary
access to the decryption machinery
These are increasingly powerful attacks, since an attacker who can choose which
plaintext/ciphertext pairs to examine is clearly in a better position than an attacker
who can only see arbitrary plaintext/ciphertext pairs.
Example 4.1 Consider the following ciphertext obtained from an affine cipher
FMXVEDKAPHFERBNDKRXRSREFMORUDSDKDVSHVUFEDKAPRKDLYEVLRHHRH
19
Letter Frequency Letter Frequency
A 2 N 1
B 1 O 1
C 0 P 2
D 7 Q 0
E 5 R 8
F 4 S 3
G 0 T 0
H 5 U 2
I 0 V 4
J 0 W 0
K 5 X 2
L 2 Y 1
M 2 Z 0
Table 4.2
The frequency analysis of this ciphertext is given in Table 4.2. The most frequent
ciphertext characters are: R (8 occurrences), D (7 occurrences), E, H, K (5
occurrences each), and F, S, V (4 occurrences each). As a first guess, we might
hypothesize that R is the encryption of e and D is the encryption of t, since e and
t are (respectively) the two most common letters . Expressed numerically, we have
eK(4) = 17 and eK(19) = 3. In Chapter 3, we have seen that the encryption is of
the form eK(x) = ax + b (mod 26), where a and b are unknowns. So we get two
linear equations in two unknowns:
4a + b = 17 (mod 26) (1)
19a + b = 3 (mod 26) (2)
Solving them, we get
-15a = 14 (mod 26) 11a = 14 (mod 26)
19 11a = 19 14 (mod 26)
a = 266 (mod 26)
We get a = 6. Substituting in equation (1), we get
b = - 7 (mod 26) b = 19
But gcd(6, 26) = 2 1. So our hypothesis is incorrect.
Our next guess might be that R is the encryption of e and E is the encryption of t.
Proceeding as above, we obtain a = 13, which is again illegal. So we try the next
possibility, that R is the encryption of e and H is the encryption of t. This yields
a = 8, again impossible. Continuing, we suppose that R is the encryption of e and
K is the encryption of t. This produces a = 3, b = 5, which is at least a legal key.
20
It remains to compute the decryption function corresponding to K = (3, 5), and
then to decrypt the ciphertext to see if we get a meaningful string of English, or
nonsense. This will confirm the validity of (3, 5).
Hence, dK(y) = a−1(y − b) mod 26 dK(y) = 9y – 19
The decryption yields the plaintext as follows :
ALGORITHMSAREQUITEGENERALDEFINITIONSOFARITHMETICPROCESSES
21
The ciphertext string CHR occurs in five places in the ciphertext, beginning at
positions 1, 166, 236, 276 and 286. The distances from the first occurrence to the
other four occurrences are (respectively) 165, 235, 275 and 285. The greatest
common divisor of these four integers is 5. So by the Kasiski test, that is very
likely the keyword length.
since the probability that two random elements both are A is p02 , the probability
that both are B is p12 , etc.
Also, a completely random string will have
The two values 0.065 and 0.038 are sufficiently far apart that we will often be
able to determine the correct keyword length by this method.
22
CHAPTER 5
PUBLIC KEY CRYPTOGRAPHY
5.1 Introduction
The idea behind a public-key cryptosystem is that it might be possible to find a
cryptosystem where it is computationally infeasible to determine dK given eK. If
so, then the encryption rule eK is a public key, the value of which can be made
known to everyone (hence the term public-key system). The advantage of a public
key system is that Alice (or anyone else) can send an encrypted message to Bob
(without the prior communication of a shared secret key) by using the public
encryption rule eK. Bob will be the only person that can decrypt the ciphertext,
using the decryption rule dK, which is called the private key. It can be understood
with the following analogy :
Alice places an object in a metal box, and then locks it with a combination lock
left there by Bob. Bob is the only person who can open the box since only he
knows the combination. When Alice wants to encrypt a message to send to Bob,
it is essential that the public encryption key that Alice is using is actually Bob’s
public key. In practice, public keys are authenticated using certificates.
Most asymmetric schemes of practical relevance are based on the principle of a
one way function :
23
5.2 The RSA Cryptosystem
The Rivest-Shamir-Adleman (RSA) cryptosystem uses computations in ℤn,
where n is the product of two distinct odd primes p and q. For such an integer n,
we have φ(n) = (p − 1)(q − 1)
24
knows this factorization, he can compute φ(n) = (p − 1)(q − 1), and then compute
the decryption exponent a using the extended Euclidean algorithm
25
Definition 5.5 (Jacobi symbol)
Suppose n is an odd positive integer, and the prime power factorization of n is
𝑎
Let a be an integer. The Jacobi symbol (−) is defined to be
𝑛
26
3. Suppose m and n are positive odd integers. Then
27
Repeating this argument, we eventually obtain
If n and φ(n) are known, and n is the product of two primes p, q, then n can be
easily factored, by solving the two equations
n = pq (1)
φ(n) = (p − 1)(q − 1) (2)
for the two unknowns p and q. If we substitute q = n/p from equation (1) into the
equation (2), we obtain a quadratic equation in the unknown value p:
p2 − (n − φ(n) + 1)p + n = 0 (3)
The two roots of equation (6.1) will be p and q, the factors of n. Hence, if a
cryptanalyst can learn the value of φ(n), then he can factor n and break the system.
Also computing φ(n) is no easier than factoring n. Thus it is important that φ(n)
is kept secret.
28
CHAPTER 6
THE DISCRETE LOGARITHM PROBLEM
29
The values that they compute, A* and B* respectively, are actually the same, since
A* ≡ Ba ≡ (gb )a ≡ gab ≡ (ga)b ≡ Ab ≡ B* (mod p)
Example 6.1
Alice and Bob agree to use the prime p = 941 and the primitive root g = 627. Alice
chooses the secret key a = 347 and computes
A = 390 ≡ 627347 (mod 941).
Similarly, Bob chooses the secret key b = 781 and computes
B = 691 ≡ 627781 (mod 941).
Alice sends Bob the number 390 and Bob sends Alice the number 691. Both of
these transmissions are done over an insecure channel, so both A = 390 and B =
691 should be considered public knowledge. The numbers a = 347 and b = 781
are not transmitted and remain secret. Then Alice and Bob are both able to
compute the number
470 ≡ 627347·781 ≡ Ab ≡ Ba (mod 941)
So 470 is their shared secret.
Suppose that Eve sees this entire exchange. She can reconstitute Alice’s and Bob’s
shared secret if she can solve either of the congruences
627a ≡ 390 (mod 941) or 627b ≡ 691 (mod 941),
since then she will know one of their secret exponents. As far as is known, this is
the only way for Eve to find the secret shared value without Alice’s or Bob’s
assistance. Current guidelines suggest that Alice and Bob choose a prime p having
approximately 1000 bits (i.e., p ≈ 21000) and an element g whose order is prime
and approximately p/2. Then Eve will face a truly difficult task.
30
6.3 ElGamal Cipher
Alice needs a large prime number p for which the discrete logarithm problem in
𝔽*p is difficult, and she needs an element g modulo p of large (prime) order. She
may choose p and g herself, or they may have been preselected by some trusted
party such as an industry panel or government agency.
Alice chooses a secret number a to act as her private key, and she computes the
quantity A ≡ ga (mod p). Now suppose that Bob wants to encrypt a message m
using Alice’s public key A. If m ≥ p then he will break up m into smaller blocks
each of which is less than p and encrypt them individually. For now we will
assume 0 < m < p. In order to encrypt m, Bob first randomly chooses another
number k modulo p. Bob uses k to encrypt one, and only one, message, and then
he discards it. The number k is called an ephemeral key, since it exists only for
the purposes of encrypting a single message.
Bob takes his plaintext message m, his chosen random ephemeral key k, and
Alice’s public key A and uses them to compute the two quantities
c1 ≡ gk (mod p) and c2 ≡ mAk (mod p).
Bob’s ciphertext, i.e., his encryption of m, is the pair of numbers (c1,c2), which
he sends to Alice.
Since Alice knows a, she can compute the quantity x ≡ c1a (mod p) and hence also
x−1 (mod p).
Alice next multiplies c2 by x−1 and the resulting value is the plaintext m since
x−1 · c2 ≡ (c1a)−1·c2 (mod p) [since x ≡ ca 1 (mod p)]
≡ (gak)−1·(mAk) (mod p) [since c1 ≡ gk, c2 ≡ mAk (mod p)]
≡ (gak)−1·(m(ga)k) (mod p) [since A ≡ ga (mod p)]
≡ m (mod p)
Example 6.2
Alice uses the prime p = 467 and the primitive root g = 2. She chooses a = 153 to
be her private key and computes her public key
A ≡ ga ≡ 2153 ≡ 224 (mod 467)
Bob decides to send Alice the message m = 331. He chooses an ephemeral key at
random, say he chooses k = 197, and he computes the two quantities
c1 ≡ 2197 ≡ 87 (mod 467) and c2 ≡ 331 · 224197 ≡ 57 (mod 467)
Finally, she computes c2 x−1 ≡ 57 · 14 ≡ 331 (mod 467) and recovers the plaintext
message m = 331
31
CONCLUSION
In this project, we explored the critical mathematical principles that form the
foundation of modern cryptography, providing an overview of how these
principles are applied in various cryptosystems. We delved into key concepts like
number theory, modular arithmetic, group theory etc. associated with various
classical and asymmetric ciphers. The examination of these cryptosystems
underscored the importance of mathematical rigour and the evolving nature of
cryptographic challenges.
The symmetric ciphers characterised by the use of a single key for both
encryption and decryption represent one of the oldest forms of cryptography. The
importance of key management and the inherent vulnerabilities in symmetric
systems were highlighted. We learnt about cryptanalysis – the breaking of
cryptographic systems – which emphasized the need for continuous improvement
in cryptographic algorithms and implementation techniques to stay ahead of
potential threats. Transitioning to public key cryptography, we explored the
fundamental shift introduced by the asymmetric encryption. The RSA algorithm,
based on the mathematical challenge of factoring large numbers and the Diffie-
Hellman key exchange, founded on the discrete logarithm problem, were
discussed. These systems allow for secure communication over insecure
channels, enabling modern secure communications and e-commerce. We
examined the mathematical principles that make these algorithms secure and the
implications of quantum computing, which could potentially undermine their
strength.
Our study concludes that mathematics is both the backbone and the driving force
behind cryptographic advancements. The project underscored the interplay
between mathematical complexity and cryptographic security. The future of
cryptography will depend on ongoing research in mathematics, computer science
and cybersecurity to develop new techniques and strengthen existing ones. As
technology progresses, cryptographers must remain vigilant to anticipate and
mitigate emerging threats, ensuring the continued confidentiality, integrity and
authenticity of data. Ultimately our exploration reinforces the notion that
cryptography is a dynamic and ever-evolving field, with mathematics serving as
its guiding light. Cryptography’s future relies on both deep mathematical insight
and practical implementation, with each advance building on a robust
mathematical foundation.
32
REFERENCES
33