Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

LA2 REPORT

on

CRYPTOGRAPHY AND NETWORK SECURITY

Bachelor of Engineering
in

Computer Science and Engineering


Submitted by:
Avishek Chaudhary 1NT19CS044
Rashish Neupane 1NT19CS153
Anubhav Sapkota 1NT19CS035
Mohammad Kashif Gani 1NT19CS114

Under the Guidance of


Dr. Vijaya Shetty
Professor, Dept. of CS&E, NMIT

Department of Computer Science and Engineering


(Accredited by NBA Tier-1)
Table of Contents

Prime Numbers.......................................................................................... 1
Fermat’s and Euler’s Theorem ................................................................... 2
Testing for Primality .................................................................................. 3
Chinese Remainder Theorem....................................................................... 5
Discrete Logarithms................................................................................... 6
Knapsack Cryptosystem............................................................................. 7
Rabin Cryptosystem................................................................................... 8
Elgamal Cryptosystem ............................................................................... 8
References ................................................................................................ 10
Prime Numbers
• A prime number is a whole number greater than 1 whose only factors are 1 and
itself.
• The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23 and 29.
• Numbers that have more than two factors are called composite numbers. The
number 1 is neither prime nor composite.
• Prime numbers can be used for a number of reasons. For example, some types
of cryptography will use prime numbers.
• For every prime number, for example "p," there exists a prime number that is
greater than p, called p’.
• This mathematical proof, which was demonstrated in ancient times by the Greek
mathematician Euclid, validates the concept that there is no "largest" prime
number.
• As the set of natural numbers N = {1, 2, 3, ...} proceeds, prime numbers do
generally become less frequent and are more difficult to find in a reasonable
amount of time.
• Encryption always follows a fundamental rule: the algorithm -- or the actual
procedure being used -- doesn't need to be kept secret, but the key does.
• Prime numbers can be very useful for creating keys. For example, the strength
of public/private key encryption lies in the fact that it's easy to calculate the
product of two randomly chosen prime numbers.
• However, it can be very difficult and time-consuming to determine which two
prime numbers were used to create an extremely large product, when only the
product is known.
• In RSA (Rivest-Shamir-Adleman), a well-known example of public key
cryptography, prime numbers are always supposed to be unique.
• The primes used by the Diffie-Hellman key exchange and the Digital Signature
Standard (DSS) cryptography schemes, however, are frequently standardized
and used by a large number of applications.

Computer Science and Engineering

1
Fermat’s And Euler’s Theorems.

Fermat’s Theorem
Fermat’s theorem states the following: If p is prime and a is a positive integer not
divisible by p, then

Proof: Consider the set of positive integers less than p: {1, 2, ......., p - 1} and
multiply each element by a, modulo p, to get the set X = {a mod p, 2a m od
p, ..... , (p - 1)a mod p}. None of the elements of X is equal to zero becau se p does
not divide a. Furthermore, no two of the integers in X are equal. To see this, assume
that ja == ka (mod p)), where 1 <= j < k <= p - 1. Because a is relatively prime5 to p,
we can eliminate a from both sides of the equation [see Equation (4.3)] resulting in j
=== k (mod p). This last equality is impossible, because j an d k are bot h positive
integers less than p. Therefore, we know that the (p - 1) elements of X are all positive
integers with no two elements equal. We can conclude the X consists of t h e set of
integers {1, 2, , p - 1} in some order. Multiplying the numbers in both sets (p and
X) and taking the result mod p yields

We can cancel the ((p - 1)! term because it is relatively prime to p [see Equation (4.5)].
This yields Equation (8.2), which completes the proof.

Computer Science and Engineering

2
Euler’s Theorem
Euler’s theorem states that for every a and n that are relatively prime:

Equation (8.4) is true if n is prime, because in that case, ϕ(n) = (n - 1) and


Fermat’s theorem holds. However, it also holds for any integer n. Recall that f(n) is
the number of positive integers less than n that are relatively prime to n. Consider
the set of such integers, labeled as
R = {x1, x2, ......., xϕ(n)}
That is, each element xi is a unique positive integer less than n with gcd(xi, n)
= 1. Now multiply each element by a, modulo n:
S = {(ax1 mod n), (ax2 mod n), ..... , (axϕ(n) mod n)}
The set S is a permutation6 of R, by the following line of reasoning:
1. Because a is relatively prime to n and xi is relatively prime to n, axi must also be
relatively prime to n. Thus, all the members of S are integers that are less than n and
that are relatively prime to n.
1. There are no duplicates in S. Refer to Equation (4.5). If axi mod n = axj mod n,
then xi = xj.

Therefore, this theorem is proved.

Computer Science and Engineering

3
Primality Testing.
• A primality test is an algorithm for determining whether an input number is
prime.
• Amongst other fields of mathematics, it is used for cryptography.
• Unlike integer factorization, primality tests do not generally give prime factors,
only stating whether the input number is prime or not.
• As of 2010 , factorization is a computationally hard problem, whereas primality
testing is comparatively easy (its running time is polynomial in the size of the
input).
• Some primality tests prove that a number is prime, while others like Miller-
Rabin prove that a number is composite.
• Therefore we might call the latter compositeness tests instead of primality tests.

For many cryptographic algorithms, it is necessary to select one or more very large
prime numbers at random. Thus, we are faced with the task of determining whether
a given large number is prime. There is no simple yet efficient means of
accomplishing this task.

Miller-Rabin Algorithm.
The algorithm due to Miller and Rabin [MILL75, RABI80] is typically used to test
a large number for primality. Before explaining the algorithm, we need some back-
ground. First, any positive odd integer n >= 3 can be expressed as

To see this, note that n - 1 is an even integer. Then, divide (n - 1) by 2 until the
result is an odd number q, for a total of k divisions. If n is expressed as a binary
number, then the result is achieved by shifting the number to the right until the
rightmost digit is a 1, for a total of k shifts. We now develop two properties of
prime numbers that we will need.

Computer Science and Engineering

4
Chinese remainder theorem.
• Chinese remainder theorem, ancient theorem that gives the conditions necessary
for multiple equations to have a simultaneous integer solution.
• The theorem has its origin in the work of the 3rd-century-AD Chinese
mathematician Sun Zi, although the complete theorem was first given in 1247
by Qin Jiushao.
• The Chinese remainder theorem addresses the following type of problem.
• One is asked to find a number that leaves a remainder of 0 when divided by 5,
remainder 6 when divided by 7, and remainder 10 when divided by 12.
• The simplest solution is 370. Note that this solution is not unique, since any
multiple of 5 × 7 × 12 (= 420) can be added to it and the result will still solve
the problem.

Let r and s be positive integers which are relatively prime and let a and b be any
two integers. Then there is an integer N such that

• Moreover, N is uniquely determined modulo rs. An equivalent statement is that


if (r,s)=1, then every pair of residue classes modulo r and s corresponds to a
simple residue class modulo rs.
• The Chinese remainder theorem is implemented in the Wolfram Language as
Chinese Remainder[{a1, a2, ...}{m1, m2, ...}]. The Chinese remainder theorem
is also implemented indirectly using Reduce in with a domain specification of
Integers.
• The theorem can also be generalized as follows. Given a set of simultaneous
congruences

for i=1, ..., r and for which the mi are pairwise relatively prime, the solution of the
set of congruences is

where
and the b_i are determined from

Computer Science and Engineering

5
Discrete Logarithm.
Suppose I tell you that I have a secret number a that satisfies
aemodM=c
The discrete logarithm problem is to find a given only the integers c,e and M.
e.g. without the modulus function, you could use log(c)/e = log(a), but the modular
arithmetic prevents you using logarithms effectively.
The discrete logarithm problem is interesting because it's used in public key
cryptography (RSA and the like). You can pick e,M so that there is another number
d such that
(aemodM)dmodM=a∀1≤a≤M
In cryptography, when you want to send the message a in secret, you send the cipher
text c found as:
c=aemodM
and then the receiver recovers the message only if he knows d, using
cdmodM=(ae)dmodM=a
Alternatively, you can publish d,M and keep e secret. Then, an yone can decode
your message, but only you can encode messages - this is used for signing
messages, e.g. you make M large and use a = MD5(message) as a digital signature,
to prove the message was not altered in transit.
If you could solve the discrete logarithm program and work out a from c wit h out
knowing d, it's assumed you could break SSL, spy on people's com munications,
drain the bank account of Bill Gates, launch NATO's nuclear missiles and generally
cause havoc.
A simple example of this is M=33, e=7, d=3.

• Given a primitive element g of a finite field GF(q), the discrete logarithm of a


nonzero element
• u ∈ GF(q) is that integer k, 1 ≤ k ≤ q − 1, for which u = g
• k.
• The well-known problem of computing
• discrete logarithms in finite fields has acquired additional importance in recent
years due to its applicability in cryptography.
• Several cryptographic systems would become insecure if an efficient discrete
logarithm algorithm were discovered.

Computer Science and Engineering

6
• It appears that in order to be safe from attacks using these algorithms, the value
of n for which GF( 2n) is used in a cryptosystem has to be very large and
carefully chosen.
• Due in large part to recent discoveries, discrete logarithms in fields GF( 2n) are
much easier to compute than in fields GF(p) with p prime.
• Hence the fields GF( 2n) ought to be avoided in all cryptographic applications.
On the other hand, the fields GF(p) with p prime appear to offer relatively high
levels of security

Knapsack Cryptosystem.
• Knapsack Encryption Algorithm is the first general public key cryptography
algorithm.
• It is developed by Ralph Merkle and Mertin Hellman in 1978.
• As it is a Public key cryptography, it needs two different keys.
• One is Public key which is used for Encryption process and the other one is
Private key which is used for Decryption process.
• In this algorithm we will two different knapsack problems in which one is easy
and other one is hard.
• The easy knapsack is used as the private key and the hard knapsack is used as
the public key. The easy knapsack is used to derived the hard knapsack.

The knapsack algorithm works like this:


• Imagine you have a set of different weights which you can use to make any total
weight that you need by adding combinations of any of these weights together.

Let us look at an example:


• Imagine you had a set of weights 1, 6, 8, 15 and 24. To pack a knapsack
weighing 30, you could use weights 1, 6, 8 and 15. It would not be possible t o
pack a knapsack that weighs 17 but this might not matter.
• You might represent the weight 30 by the binary code 11110 (one 1, one 6, one
8, one 15 and no 24).

Computer Science and Engineering

7
Rabin Cryptosystem.
• Rabin Cryptosystem is an public-key cryptosystem invented by Michael Rabin.
It uses asymmetric key encryption for communicating between two parties and
encrypting the message.
• The security of Rabin cryptosystem is related to the difficulty of factorization.
It has the advantage over the others that the problem on wh ich it ban ks h as
proved to be hard as integer factorization.
• It has the disadvantage also, that each output of t h e Rabin fu nction can be
generated by any of four possible inputs.
• If each output is a ciphertext, extra complexity is requ ired on decryption t o
identify which of the four possible inputs was the true plaintext.

Elgamal Cryptosystem.
• In cryptography, the ElGamal encryption system is an asymmetric key
encryption algorithm for public-key cryptography which is based on the Diffie–
Hellman key exchange.
• It was described by Taher Elgamal in 1984.[1] ElGamal encryption is u sed in
the free GNU Privacy Guard software, recent versions of PGP, and other
cryptosystems.
• The Digital Signature Algorithm is a variant of the ElGamal signature scheme,
which should not be confused with ElGamal encryption.
• ElGamal encryption can be defined over any cyclic group {\displaystyle G}. Its
security depends upon the difficulty of a certain problem in {\displaystyle G}
related to computing discrete logarithms.

Suppose Alice wants to communicate with Bob.

• Bob generates public and private keys:


• Bob chooses a very large number q and a cyclic group Fq.
• From the cyclic group Fq, he choose any element g and
• an element a such that gcd(a, q) = 1.
• Then he computes h = ga.
• Bob publishes F, h = ga, q, and g as his public key and retains a as private key.

Computer Science and Engineering

8
• Alice encrypts data using Bob’s public key :
• Alice selects an element k from cyclic group F
• such that gcd(k, q) = 1.
• Then she computes p = gk and s = hk = gak.
• She multiples s with M.
• Then she sends (p, M*s) = (gk, M*s).
• Bob decrypts the message :
• Bob calculates s′ = pa = gak.
He divides M*s by s′ to obtain M as s = s′.

Computer Science and Engineering

9
References
• https://www.techtarget.com/whatis/definition/prime-number
• https://www.brainkart.com/article/Fermat-s-And-Euler-s-Theorems_8430/
• https://cryptography.fandom.com/wiki/Primality_test
• https://www.brainkart.com/article/Testing-for-Primality_8431/
• https://www.britannica.com/science/Chinese-remainder-theorem
• https://mathworld.wolfram.com/ChineseRemainderTheorem.html
• https://www.quora.com/What-is-a-discrete-logarithm-problem-How-is-useful-
for-cryptography
• https://www.geeksforgeeks.org/knapsack-encryption-algorithm-in-
cryptography/
• https://nrich.maths.org/2199
• https://www.geeksforgeeks.org/rabin-cryptosystem-with-implementation/
• https://cryptography.fandom.com/wiki/ElGamal_encryption
• https://mathstats.uncg.edu/sites/pauli/112/HTML/secelgamal.html

Computer Science and Engineering

10

You might also like