Unit Iii Asymmetriccryptography
Unit Iii Asymmetriccryptography
Prime Factorization
Prime factorisation to compute GCD of any two numbers in prime factorization approach
we need to find prime factors of the two numbers.
Coprimes:
Sieve of Eratosthenes
The Greek mathematician Eratosthenes devised a method to find all primes less than n. This
method is called the Sieve of Eratosthenes. Suppose we wants to find all prime less than 100.
1
CB3491– Cryptography and cyber security (Regulation2021)
III Year / V Semester - CSE
Primality testing method is a method to find and to prove whether the given number is prime number.
1. Naive Algorithm
Naïve Algorithm is used to divide the given input number P by all the integers starting from 2 to
root of P – 1.
If any one of them is a divisor, then the input number P is not a prime. Otherwise, it is
considered as a prime number .
Algorithm:
Example:
Check whether the given number 12 is prime number or not using Fermat‘s theorem
Given P = 12. To check whether 12 is prime number or not, we have to check
2
CB3491– Cryptography and cyber security (Regulation2021)
III Year / V Semester - CSE
Before presenting Euler’s theorem, we need to introduce an important quantity in number theory,
referred to as Euler’s totient function, written f(n), and defined as the number of positive integers less
than and relatively primeton.By convention, f(1) = 1.
Above Table lists the first 30 values of f(n). The value f(1) is without meaning but is defined to
have the value 1.It should be clear that, for a prime number p,
3
CB3491– Cryptography and cyber security (Regulation2021)
III Year / V Semester - CSE
n = pq,
Using Fermat’s theorem, find a mod p. What is Euler’s totient function? (Nov/Dec2016)
Two theorems that play important roles in public-key cryptography are Fermat’s theorem and
Euler’s theorem.
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, c, p - 1} and multiply each element by
a, modulo p, to get the set X = {a mod p, 2a mod p, c, (p - 1) a mod p}.
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 .This yields Equation
(8.2), which completes the proof.
4
CB3491– Cryptography and cyber security (Regulation2021)
III Year / V Semester - CSE
Note that the first form of the theorem [Equation (8.2)] requires that a be relatively
prime to p, but this form does not.
Euler’s Theorem
Euler’s theorem states that for every a and n that are relatively prime:
Proof:
Above Equation is true if n is prime, because in that case, f(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
lessthann thatarerelativelyprimeton.Considerthesetofsuchintegers,labeledas
That is, each element x i of R is a unique positive integer less than n with
gcd (xi,n)=1
Which completes the proof. This is the same line of reasoning applied to the proof of Fermat’s
theorem.
As is the case for Fermat’s theorem, an alternative form of the theorem is also useful:
5
CB3491– Cryptography and cyber security (Regulation2021)
III Year / V Semester - CSE
One of the most useful results of number theory is the Chinese remainder theorem (CRT).
Inessence, the CRT says it is possible to reconstruct integers in a certain range from their residues
modulo a set of pair wise relatively prime moduli.
The CRT can be stated in several ways.We present here a formulation that is most useful from the
point of view of this text. An alternative formulation is explored in Problem8.17.Let
Where the mi are pair wise relatively prime; that is, gcd (mi, mj) = 1 for 1 ≤ i, j ≤ k, and i
≠ j. Wecan represent any integer A in Z M by a k-tuple whose elements are in Zmi using the following
correspondence:
By the definition of Mi, it is relatively prime to miand therefore has a unique multiplicative inverse
mod mi.So Equation (8.8) is well defined and produces a unique value ci.
Wecannowcompute.
To show that the value of A produced by Equation (8.9) is correct, we must show that
ai = A mod mi for 1 ≤ i ≤ k. Note that cj≡ Mj≡ 0 (mod mi) if j ≠ i, and that ci≡ 1 (mod mi). It
follows that ai=A mod mi.
6
CB3491– Cryptography and cyber security (Regulation2021)
III Year / V Semester - CSE
The second assertion of the CRT, concerning arithmetic operations, follows from the rules for
modular arithmetic. That is, the second assertion can be stated as follows: If
One of the useful features of the Chinese remainder theorem is that it provides a way to manipulate
(potentially very large) numbers mod M in terms of tuples of smaller numbers. This can be useful
when M is 150 digits or more. However, note that it is necessary to know beforehand the
factorization of M.
The RSA cryptosystem, which will be discussed in Chapter 10, uses exponentiation for both
encryption and decryption with very large exponents. Unfortunately, most computer languages
have no operator that can efficiently compute exponentiation, particularly when the exponent is
very large. To make this type of calculation more efficient, we need algorithms that are more
efficient.
Fast Exponentiation
7
CB3491– Cryptography and cyber security (Regulation2021)
III Year / V Semester - CSE
Note that y is the product of nb terms. Each term is either 1 (if the corresponding bit is 0) or a2 I
(if the corresponding bit is 1). In other words, the term is included in the multiplication if the bit
is 1, it is not included if the bit is 0 (multiplication by 1 has no effect).
Figure gives the general idea how to write the algorithm. We can continuously square the base
If the corresponding bit is 0, the term is not included in the multiplication
process; if the bit is 1, it is. Algorithm 9.7 reflects these two observations.
Algorithm uses n iterations. In each iteration, it checks the value of the corresponding bit. If the
value of the bit is 1, it multiplies the current base with the previous value of the result. It then
squares the base for the next iteration. Note that squaring is not needed in the last step (the result
is not used).
8
CB3491– Cryptography and cyber security (Regulation2021)
III Year / V Semester - CSE
LOGARITHM or INDICES
• Discrete logarithms are logarithms defined with regard to multiplicative cyclic groups. If G is a
multiplicative cyclic group and g is a generator of G, then from the definition of cyclic groups, we
know every element h in G can be written as x g for some x. The discrete logarithm to the base g of
h in the group G is defined to be x .
The conceptual differences between the two systems are based on how these systems keep a secret.
In symmetric-key cryptography, the secret must be shared between two persons. In asymmetric-key
cryptography, the secret is personal (unshared); each person creates and keeps his or her own secret.
In a community of n people, n(n - 1)/2 shared secrets are needed for symmetric-key cryptography;
only n personal secrets are needed in asymmetric-key cryptography. For a community with a
population of 1 million, symmetric-key cryptography would require half a billion shared secrets;
asymmetric-key cryptography would require 1 million personal secrets.
9
CB3491– Cryptography and cyber security (Regulation2021)
III Year / V Semester - CSE
RSA cryptosystem
Explain the RSA algorithm and its key generation, encryption and decryption Operations. Or
Perform encryption and decryption using RSA Alg.
Introduction:
It was developed by Rivest, Shamir and Adleman. This algorithm makes use of an expression with
exponentials. Plaintext is encrypted in blocks, with each block having a binary value less than
some number n.
The RSA scheme is a cipher in which the plaintext and cipher text are integers between 0 and n - 1
for some n. A typical size for n is 1024 bits, or 309 decimal digits. That is, n is less than 2^ 1024. That
is, the block size must be less than or equal to Iog 2 (n); in practice, the block size is k its, k *1 .
where 2< n < 2 k*1
Encryption and decryption are of the following form, for some plain text block M and cipher text
block C:
Both the sender and receiver know the value of n. the sender knows the value of e and only the
receiver knows the value of d. thus, this is a public key encryption algorithm with a public key
of KU = {e, n) and a private key of KR = {d, n}. For this algorithm to be satisfactory for public
key encryption, the following requirements must be met:
The purpose of the algorithm is to enable two users to exchange a key securely that can then be
used for subsequent encryption of messages. The Diffie-Hellman algorithm depends for its
effectiveness on the difficulty of computing discrete logarithms.
First, we define a primitive root of a prime number p as one whose power generate all the
integers from 1 to (p-1) i.e., if =a‘ is a primitive root of a prime number p, then the numbers a
10
CB3491– Cryptography and cyber security (Regulation2021)
III Year / V Semester - CSE
mod p, a2mod p, ... ap 1 mod p are distinct and consists of integers from 1 to (p-1) in some
permutation.
The Algorithm
Figure summarizes the Diffie-Hellman key exchange algorithm. There are publicly known
numbers: a prime number =q‘ and an integer a that is primitive root of q. suppose users A and B
wish to exchange a key. User A selects a random integer XA‹ q and computes YA = a XA mod q.
11
CB3491– Cryptography and cyber security (Regulation2021)
III Year / V Semester - CSE
The result is that two sides have exchanged a secret key. The security of the algorithm lies in the
fact that, while it is relatively easy to calculate exponentials modulo a prime, it is very difficult to
calculate discrete logarithms.
1. Darth prepares for the attack by generating two random private keys XD1 and XD2 and then
computing the corresponding public keys YD1 and
12
CB3491– Cryptography and cyber security (Regulation2021)
III Year / V Semester - CSE
Elliptic Curves:
An elliptic Curve is a Cubic equation of the form
13