CNS_MODULE_2
CNS_MODULE_2
The division relationship (a = q × n + r) 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.
The modulo operator is shown as mod. The second input (n) is called the modulus. The output
r is called the residue.
Examples
Find the result of the following operations:
a. 27 mod 5 b. 36 mod 12
Solution
a. Dividing 27 by 5 results in r = 2
b. Dividing 36 by 12 results in r = 0.
CONGRUENCE
Two integers a and b are said to be congruent modulo n if
a (mod n)≡ b (mod n) a ≡ b (mod n)
Properties of Congruences
Congruences have the following properties:
1. a≡ b (mod n) if n|(a-b)
2. a≡ b (mod n) implies b≡ a( mod n)
3. a ≡ b (mod n) and b ≡ c (mod n) imply a ≡ c (mod n).
To show that two integers are congruent, we use the congruence operator ( ≡). For example,
we write:
RELATIVELY PRIME
Two integers are relatively prime, if their only common positive integer factor is 1.
8 and 15 are relatively prime because
Positive divisors of 8 are 1,2,4,8
Positive divisors of 15 are 1, 3, 5, 15
Therefore, common positive factor = 1.
EUCLIDEAN ALGORITHM
Euclidean algorithm is a simple procedure for determining the greatest common divisor of
two positive integers.
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.
2. Any divisor of a and b is a divisor of c.
EUCLID(a, b)
1. A a; B b
2. if B = 0 return A = gcd(a, b)
3. R = A mod B
4. A B
5. B R
6. goto 2
Euclidean Algorithm Revisited
For any integers a, b, with a ≥ b ≥ gcd(a, b) = gcd(b, a mod b)
Example:
gcd(55, 22) = gcd(22, 55 mod 22) = gcd(22, 11) = 11
gcd(18, 12) = gcd(12, 6) = gcd(6, 0) = 6
gcd(11, 10) = gcd(10, 1) = gcd(1, 0) = 1
Example 2 Find the greatest common divisor of 2740 and 1760. Solution:
We have gcd (2740, 1760) = 20.
GROUPS
A group G, sometimes denoted by {G, •}, is a set of elements with a binary operation denoted
by • that associates to each ordered pair (a, b) of elements in G an element (a • b) in G, such
that the following axioms are obeyed:
RINGS
A ring R, sometimes denoted by {R, +, *}, is a set of elements with two binary operations,
called addition and multiplication, such that for all a, b, c in R the following axioms are
obeyed.
(A1–A5) R is an abelian group with respect to addition; that is, R satisfies axioms A1 through
A5.
(M1) Closure under multiplication: If a and b belong to R, then ab is also in R.
(M2) Associativity of multiplication: a(bc) = (ab)c for all a, b, c in R.
(M3) Distributive laws: a(b + c) = ab + ac for all a, b, c in R.
(a + b)c = ac + bc for all a, b, c in R.
An integral domain, which is a commutative ring that obeys the following axioms.
(M5) Multiplicative identity: There is an element 1 in R such that a1 = 1a = a for all a in R.
(M6) No zero divisors: If a, b in R and ab = 0, then either a = 0 or b = 0.
FIELDS
A field F, sometimes denoted by {F, +, *}, is a set of elements with two binary operations,
called addition and multiplication, such that for all a, b, c in F and the following axioms are
obeyed.
(A1–M6) F is an integral domain; that is, F satisfies axioms A1 through A5 and M1 through M6.
(M7) Multiplicative inverse: For each a in F, except 0, there is an element a-1 in F such that
aa-1 = (a-1)a = 1
FINITE FIELDS / GALOIS FIELDS / FINITE (GALOIS) FIELDS
• Finite fields play a key role in cryptography.
• Finite field is a field that contains a finite number of elements
• It can show number of elements in a finite field must be a power of a prime pn
• known as Galois fields, denoted GF(pn)
• In particular often use the fields:
n=1 then we say as GF(p), or p=2 then we say as GF(2^n).
• GF(p) is the set of integers {0,1, … , p-1} with addition & multiplication modulo p.
• This forms a “well-behaved” finite field.
POLYNOMIAL ARITHMETIC
Where: ai – coefficients
Addition is defined as
Multiplication is defined as
Where:
If a is a prime number and b < a, then clearly a and b are relatively prime and have a greatest
common divisor of 1. We now show that we can easily compute b-1 using the extended
Euclidean algorithm.
PRIME NUMBER
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
where p1 <p2 <…< pt are prime numbers and where each ai is a positive integer.
EX: 91 = 7 * 13
3600 = 24 * 32 * 52
11011 = 7 * 112 * 13
If P is the set of all prime numbers, then any positive integer a can be written uniquely in the
following form:
It is easy to determine the greatest common divisor of two positive integers if we express each
integer as the product of primes
EX: 300 = 22 * 31 * 52 18 = 21 * 32
gcd(18, 300) = 21 * 31 * 50 = 6
The following relationship always holds: If k = gcd(a, b), then kp = min(ap, bp) for all p.
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.
TEST (n)
1. Find integers k, q, with k > 0, q odd, so that (n - 1 = 2kq);
2. Select a random integer a, 1 < a < n - 1;
3. if aqmod n = 1 then return("inconclusive");
4. for j = 0 to k - 1 do
5. if a2jqmod n = n - 1 then return("inconclusive");
6. return("composite");