Unit-3 Part-1 Notes CNS
Unit-3 Part-1 Notes CNS
UNIT-1
Set of Integers
The set of integers, denoted by Z, contains all integral numbers (with no fraction). from negative
infinity to positive infinity.
Binary Operations
In cryptography, we are interested in three binary operations applied to the set of integers.
Because each input can be either positive or negative, we can have four cases for each
operation.
Integer Division
In integer arithmetic, if we divide a by n, we can get q and r . The relationship between these four
integers can be shown as
a=q×n+r
Properties of Divisibility
Any b ≠ 0 divides 0.
Example:
If b/g and b/h, then b/(mg + nh) for arbitrary integers m and n.
Proof:
So b divides mg1+nh1
Divisibility Algorithm
Given any positive integer n and any nonnegative integer a, if we divide a by n, we get an integer
quotient q and an integer remainder r that obey the following relationship:
a = qn + r 0<=r<n; q = [a/n]
Euclidean Algorithm
It is a simple procedure for determining the greatest common divisor of two positive integers.
The greatest common divisor of a and b is the largest integer that divides both a and b.
More formally, the positive integer c is said to be the greatest common divisor of a and b if
1. c is a divisor of a and of b.
Given two integers a and b we need to often find other 2 integers s and t such that
sxa+txb=gcd(a,b).
The extended euclidean algorithm can calculate the gcd(a,b) and at the same time calculate the
values of s and t.
Steps:
Initialize r1->a,r2->b
s1->1,s2->0
t1->0,t2->1
Modular Arithmetic
The division relationship (a = q × n + r) discussed in the previous section has two inputs (a and n)
and two outputs (q and r).
In modular arithmetic, we are interested in only one of the outputs, the remainder r.
Modulo Operator
• a. 27 mod 5 b. 36 mod 12
• Dividing 36 by 12 results in r = 0.
Set of Residues
The modulo operation creates a set, which in modular arithmetic is referred to as the set of
least residues modulo n, or Zn.
Congruence
To show that two integers are congruent, we use the congruence operator ( ≡ ). For example, we
write:
Congruence-Residue Classes
Operations on Zn
The three binary operations that we discussed for the set Z can also be defined for the set Zn.
• a. Add 7 to 14 in Z15.
• c. Multiply 11 by 7 in Z20.
Properties of Modulo
In arithmetic, we often need to find the remainder of powers of 10 when divided by an integer.
Inverses
When we are working in modular arithmetic, we often need to find the inverse of a number
relative to an operation.
Additive Inverse
In modular arithmetic, each integer has an additive inverse. The sum of an integer and its
additive inverse is congruent to 0 modulo n.
Find all additive inverse pairs in Z10.
The six pairs of additive inverses are (0, 0), (1, 9), (2, 8), (3, 7), (4, 6), and (5, 5).
Multiplicative Inverse
In Zn, two numbers a and b are the multiplicative inverse of each other if
When it does, the product of the integer and its multiplicative inverse is congruent to 1 modulo
n.
There are only three pairs: (1, 1), (3, 7) and (9, 9). The numbers 0, 2, 4, 5, 6, and 8 do not have a
multiplicative inverse.
We need to use Zn when additive inverses are needed; we need to use Zn* when multiplicative
inverses are needed.
Cryptography often uses two more sets: Zp and Zp*. The modulus in these two sets is a prime
number.
Prime Numbers
Prime numbers only have divisors of 1 and self they cannot be written as a product of other
numbers. eg. 2,3,5,7 are prime, 4,6,8,9,10 are not
An integer p > 1 is a prime number if and only if its only divisors are ± 1 and ±p.
Any integer a > 1 can be factored in a unique way as a = p1^ a1 * p2 ^a2 * …….* pt^at where p1
< p2 < …..< pt are prime numbers and where each ai is a positive integer.
This is known as the fundamental theorem of arithmetic; a proof can be found in any text on
number theory.
91 = 7 x 13
3600 = 24 x 32 x 52
11011 = 7 x 112 x 13
If P is the set of all prime numbers, then any positive integer a can be written uniquely in the
following form:
The right-hand side is the product over all possible prime numbers p; for any particular value of
a, most of the exponents ap will be 0.
Two numbers a,b are relatively prime (coprime) if they have no common divisors apart from 1.
– eg. 8 and 15 are relatively prime since factors of 8 are 1,2,4,8 and of 15 are 1,3,5,15 and 1 is the only
common factor.
Two integers are relatively prime if their only common positive integer factor is 1.
Example:
Fermat’s theorem states the following: If ‘p’ is prime and ‘a’ is a positive integer not divisible by
p, then
ap-1 ≡ 1 mod p
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 modp, 2a modp, ….. , (p - 1)a modp}.
Because a is relatively prime to p, we can eliminate a from both sides of the equation resulting
in j ≡ k(modp).
This last equality is impossible, because j and k are both 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 the set of integers {1, 2, c , p - 1} in some order.
Multiplying the numbers in both sets (p and X) and taking the result mod p yields.
An alternative form of Fermat’s theorem is also useful: If p is prime and a is a positive integer,
then a^p ≡ a(modp)
Note that the first form of the theorem ap-1 ≡ 1 mod p requires that a be relatively prime to p,
but this form does not.
a = 7, p = 19
7^2 = 49 ≡ 11 (mod19)
7^4 ≡ 121 ≡ 7 (mod19)
7^8 ≡ 49 ≡ 11 (mod19)
Euler’s totient function, written f(n), is defined as the number of positive integers less than n
and relatively prime to n.
By convention, f(1) = 1.
Now suppose that we have two prime numbers p and q with p ≠ q. Then we can show that, for
n = pq,
To see that ɸ (n) = ɸ(p) * ɸ (q), consider that the set of positive integers less that n is the set
{1, c, (pq - 1)}.
The integers in this set that are not relatively prime to n are the set {p, 2p, c, (q - 1)p} and the set
{q, 2q, c, (p - 1)q}.
Accordingly, ɸ(n) = (pq - 1) - [(q - 1) + (p - 1)] = pq - (p + q) + 1 = (p - 1) * (q - 1) = ɸ (p) * ɸ (q)
Euler’s Theorem
Euler’s theorem states that for every a and n that are relatively prime:
aø(n) ≡1(mod n)
Proof
Euler’s equation 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.
That is, each element xi of R 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), c, (ax ø(n) mod n)
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.
As is the case for Fermat’s theorem, an alternative form of the theorem is also useful:
aø(n)+1 ≡a(mod n)
Again, similar to the case with Fermat’s theorem, the first form of Euler’s theorem requires that
a be relatively prime to n, but this form does not.
Chinese Remainder Theorem
The chinese remainder theorem (CRT) is used to solve a set of congruent equations with one
variable but different moduli, which are relatively prime as shown below:
The chinese Remainder Theorem states that the above equations have a unique solution if the
moduli are relatively prime.
2. Find M1=M/m1,M2=M/m2,……,Mk=M/mk.
X=(a1*M1*M1^-1+a2*M2*M2^-1+…….+ak*Mk*Mk^-1)modM
Derive common solution for above equations using Chinese Remainder Theorem
M=3*5*7=105
X=(2*35*2+3*21*1+2*15*1)mod105
X=23mod105