0% found this document useful (0 votes)
3 views

CNS_MODULE_2

The document provides an overview of modular arithmetic, including definitions, operations, and properties of congruences. It also discusses groups, rings, and fields in abstract algebra, along with the Euclidean algorithm for finding the greatest common divisor. Additionally, it covers prime numbers, their unique factorization, and the Miller-Rabin algorithm for testing primality.

Uploaded by

gdgbitj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

CNS_MODULE_2

The document provides an overview of modular arithmetic, including definitions, operations, and properties of congruences. It also discusses groups, rings, and fields in abstract algebra, along with the Euclidean algorithm for finding the greatest common divisor. Additionally, it covers prime numbers, their unique factorization, and the Miller-Rabin algorithm for testing primality.

Uploaded by

gdgbitj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

MODULAR ARITHMETIC

If a is an integer and n is a positive integer, we define a mod n to be the remainder when a is


divided by n. The integer n is called the modulus.

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:

MODULAR ARITHMETIC OPERATIONS


Modular arithmetic exhibits the following properties:
1. [(a mod n) + (b mod n)] mod n = (a + b) mod n
2. [(a mod n) - (b mod n)] mod n = (a - b) mod n
3. [(a mod n) * (b mod n)] mod n = (a * b) mod n
Example: 11 mod 8 = 3; 15 mod 8 = 7
[(11 mod 8) + (15 mod 8)] mod 8 = 10 mod 8 = 2
(11 + 15) mod 8 = 26 mod 8 = 2
[(11 mod 8) - (15 mod 8)] mod 8 = -4 mod 8 = 4
(11 - 15) mod 8 = -4 mod 8 = 4
[(11 mod 8) * (15 mod 8)] mod 8 = 21 mod 8 = 5
(11 * 15) mod 8 = 165 mod 8 = 5

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.

Fact 1: gcd (a, 0) = a


Fact 2: gcd (a, b) = gcd (b, r), where r is the remainder of dividing a by b

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.

Example 3 Find the greatest common divisor of 25 and 60. Solution


: We have gcd (25, 65) = 5.

GROUPS, RINGS, AND FIELDS


Groups, rings, and fields are the fundamental elements of a branch of mathematics known
as abstract algebra, or modern algebra.

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:

(A1) Closure: If a and b belong to G, then a • b is also in G.


(A2) Associative: a•(b•c) = (a•b)•c for all a, b, c in G.
(A3) Identity element: There is an element e in G such that a • e = e • a = a for all a in G.
(A4) Inverse element: For each a in G, there is an element a -1 in G such that a • a -1 = a -1• a
= e.
If a group has a finite number of elements, it is referred to as a finite group, and the order of
the group is equal to the number of elements in the group. Otherwise, the group is an infinite
group. A group is said to be abelian if it satisfies the following additional condition:
(A5) Commutative: a • b = b • a for all a, b in G.
A group G is cyclic if every element of G is a power ak (k is an integer) of a fixed element a ε
G. The element a is said to generate the group G or to be a generator of G. A cyclic group is
always abelian and may be finite or infinite.

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.

A ring is said to be commutative if it satisfies the following additional condition:


(M4) Commutativity of multiplication: ab = ba for all a, b 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

A polynomial of degree n (integer n ≥ 0) is an expression of the form

Where: ai – coefficients

Addition is defined as

Multiplication is defined as

Where:

Eg.: Let f(x) = x3 + x2 + 2 and g(x) = x2 - x + 1, where S is the set of integers.


Then f(x) + g(x) = x3 + 2x2 - x + 3
f(x) - g(x) = x3 + x + 1
f(x) * g(x) = x5 + 3x2 - 2x + 2

Example 1 Find gcd[a(x), b(x)] for a(x) = x6 + x5 + x4 + x3 + x2 + x + 1 and b(x) = x4 + x2


+ x + 1.

Euclidean algorithm to compute the greatest common divisor of two polynomials


gcd[a(x), b(x)] = gcd[b(x), a(x) mod b(x)]
= gcd(b(x), r1(x))
= gcd[r1(x), b(x) mod r1(x)]
MULTIPLICATIVE INVERSE
It is easy to find the multiplicative inverse of an element in GF(p) for small values of p by
constructing a multiplication table, such as shown in Table and the desired result can be read
directly. However, for large values of p, this approach is not practical.
If a and b are relatively prime, then b has a multiplicative inverse modulo a. That is, if gcd(a,
b) = 1, then b has a multiplicative inverse modulo a. That is, for positive integer b < a, there
exists a b-1 < a such that bb-1 = 1 mod a.

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.

TESTING FOR PRIMALITY

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");

Example 1: Let us apply the test to the prime number n = 29.


(n - 1) = 28 =22(7) = 2kq.
First, let us try a = 10.
Compute 107 mod 29 = 17,
(107)2 mod 29 = 28, and the test returns inconclusive. So n is prime number.

You might also like