0% found this document useful (0 votes)
23 views52 pages

WINSEM2024-25 BCSE309L TH VL2024250501948 2024-12-17 Reference-Material-I

Uploaded by

Deena Patel
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)
23 views52 pages

WINSEM2024-25 BCSE309L TH VL2024250501948 2024-12-17 Reference-Material-I

Uploaded by

Deena Patel
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/ 52

BCSE309L

Module 1-
Fundamentals of Number
Theory
Winter Semester 2024-25

Dr. Sunil Kumar


Outline
• Euclidian Algorithm
• Modular arithmetic
• Finite Fields
• Polynomial Arithmetic
Why?
• Modern cryptography is based on Number Theory, a branch of
mathematics concerned with the properties of integers.
• In order to understand how modern cryptographic techniques work,
and to estimate the extent to which they are secure, it is important to
understand the basics of number theory.
Modular Arithmetic Operations
• is 'clock arithmetic'
• uses a finite number of values, and loops back from either end
• modular arithmetic is when do addition & multiplication and modulo
reduce answer
• can do reduction at any point, ie
• a+b mod n = [a mod n + b mod n] mod n
Example:
7 mod 3 = 1 -7 mod 3 = 2
Congruence Relation
Definition: Let a, b, n be integers with n>0, we say
that a  b (mod n),
if a – b is a multiple of n.
Properties: a  b (mod n)
if and only if n | (a – b)
if and only if n | (b – a)
if and only if a = b+k·n for some integer k
if and only if b = a+k·n for some integer k
Properties of the Congruence Relation
Proposition: Let a, b, c, n be integers with n>0
1. a  0 (mod n) if and only if n | a
2. a  a (mod n)
3. a  b (mod n) if and only if b  a (mod n)
4. if a  b and b  c (mod n), then a  c (mod n)
Corollary: Congruence modulo n is an equivalence relation.
Every integer is congruent to exactly one number in {0, 1, 2, …, n–1}
modulo n
Properties of the Congruence Relation

Proposition: Let a, b, c, n be integers with n>0


If a  b (mod n) and c  d (mod n), then:
a + c  b + d (mod n),
a – c  b – d (mod n),
a·c  b·d (mod n)
E.g., 5  12 (mod 7) and 3  -4 (mod 7), then, …
Properties of Modular Arithmetic
Modular arithmetic exhibits the following properties:
[(a mod n) + (b mod n)] mod n = (a + b) mod n
[(a mod n) - (b mod n)] mod n = (a - b) mod n
[(a mod n) * (b mod n)] mod n = (a * b) mod n
the rules for ordinary arithmetic involving addition,
subtraction, and multiplication carry over into modular
arithmetic.
Properties of Modular Arithmetic for Integers in Zn
(w + x) mod n = (x + w) mod n
• Commutative laws (w x x) mod n = (x x w) mod n
• Associative laws
[(w + x) + y] mod n = [w + (x + y)] mod n
[(w x x) x y] mod n = [w x (x x y)] mod n
• Distributive laws
[w + (x + y)] mod n = [(w x x) + (w x y)] mod n
[w + (x x y)] mod n = [(w + x) x (w + y)] mod n
• Identities (0 + w) mod n = w mod n
(1 + w) mod n = w mod n

• Additive inverse (-w)


For each w  Zn, there exists a z such that w + z ≡ 0 mod n
Multiplicative Inverse
• Definition: Given integers n>0, a, b, we say that b is a
multiplicative inverse of a modulo n if
ab  1 (mod n).
• Proposition: Given integers n>0 and a, then a has a
multiplicative inverse modulo n if and if only if a and n are
relatively prime.
Modulo 8 Addition Example
+ 0 1 2 3 4 5 6 7
0 0 1 2 3 4 5 6 7
1 1 2 3 4 5 6 7 0
2 2 3 4 5 6 7 0 1
3 3 4 5 6 7 0 1 2
4 4 5 6 7 0 1 2 3
5 5 6 7 0 1 2 3 4
6 6 7 0 1 2 3 4 5
7 7 0 1 2 3 4 5 6
Modulo 8 Multiplicative Inverse Example

Note that not all integers mod 8 have a multiplicative inverse


Euclidean Algorithm
• an efficient way to find the GCD(a,b)
• uses theorem that:
• GCD(a,b) = GCD(b, a mod b)
• Euclidean Algorithm to compute GCD(a,b) is:
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
Finding Multiplicative Inverse
Extended Euclidean algorithm not only calculate the greatest common
divisor but also two additional integers and that satisfy the following
equation.

𝑎𝑠 + 𝑏𝑡 = 𝑑 = gcd(𝑎, 𝑏)
Extended Euclidean algorithm
𝒒 = 𝒓𝟏/𝒓𝟐 𝒓 = 𝒓𝟏 − 𝒒 ∗ 𝒓 𝟐 𝒔 = 𝒔𝟏 − 𝒒 ∗ 𝒔𝟐 𝒕 = 𝒕𝟏 − 𝒒 ∗ 𝒕𝟐
Extended Euclidean algorithm
Extended Euclidean algorithm: Example
• a = 5 and b = 3, find gcd (a, b) and the values of s and t.
q r1 r2 r s1 s2 s t1 t2 t

1 5 3 2 1 0 1 0 1 -1

1 3 2 1 0 1 -1 1 -1 2

2 2 1 0 1 -1 3 -1 2 -5

1 0 -1 3 2 -5
Extended Euclidean algorithm: Example
• a = 161 and b = 28, find gcd (a, b) and the values of s and t.
q r1 r2 r s1 s2 s t1 t2 t

5 161 28 21 1 0 1 0 1 -5

1 28 21 7 0 1 -1 1 -5 6

3 21 7 0 1 -1 4 -5 6 -23

1 0 -1 4 6 -23
Problem
• find the integers x and y solving the equation 161𝑥 + 28𝑦 = 𝑧
𝑎𝑠 + 𝑏𝑡 = 𝑑
a b q r s1 s2 s3 t1 t2 t3
161 28 5 21 1 0 1 0 1 -5
28 21 1 7 0 1 -1 1 -5 6
21 7 3 0 1 -1 4 -5 6 -23
Using extended Euclidean algorithm to find
multiplicative inverse
𝑎𝑠 + 𝑏𝑡 = 𝑑 = 𝑔𝑐𝑑(𝑎, 𝑏)
𝑎𝑠 + 𝑏𝑡 = 1, 𝑖𝑓 𝑔𝑐𝑑 𝑎, 𝑏 = 1
𝑎𝑠 𝑚𝑜𝑑 𝑎 + 𝑏𝑡 𝑚𝑜𝑑 𝑎 𝑚𝑜𝑑 𝑎 = 1 𝑚𝑜𝑑 𝑎
0 + 𝑏𝑡 𝑚𝑜𝑑 𝑎 = 1
𝑏𝑡 𝑚𝑜𝑑 𝑎 = 1
𝒕 = 𝒃−𝟏
Using extended Euclidean algorithm to find
multiplicative inverse

𝒒 = 𝒓𝟏/𝒓𝟐 𝒓 = 𝒓 𝟏 − 𝒒 ∗ 𝒓𝟐 𝒕 = 𝒕𝟏 − 𝒒 ∗ 𝒕𝟐
Exercise
• Find the multiplicative inverse of 11 in 𝑍26 .

t1 is -ve, so add 26.


t=-7+26=19
multiplicative inverse 11 mod 26=19
Exercise
• Find the multiplicative inverse of 23 in 𝑍100 .

t1 is -ve, so add 100.


t=-13+100=87
multiplicative inverse 23 mod 100=87
Practice Questions
• Using the extended Euclidean algorithm, find the multiplicative
inverse of
• 125 mod 20
• 123 mod 17
• 134 mod 17
• 550 mod 1747
Practice Questions
• a=1640 and b=428 find s and t and gcd(a,b).
• Find the multiplicative inverse of each of the following integers in Z180
using the extended Euclidean algorithm.
• a. 38
• b. 7
• c. 132
• d. 27
Groups, Rings, and Fields
Groups
• A group, G, is a set of elements with an associated binary operation, •. It is sometimes
denoted {G, • }
• For each ordered pair (a, b) of elements in G, there is an associated element (a •b), such that
the following axioms hold:

1) Closure : If a and b  G, then a • b  G


2) Associativ e : a • (b • c) = (a • b) • c for all a, b, c  G
3) Identity element : There is an element e  G such that
a • e = e • a = a for all a  G
4) Inverse element : For each a  G there is an element a'  G such that
a • a' = a' • a = e
Groups
• A finite group is a group with a finite number of elements, otherwise,
a group is an infinite group.
• A group is said to be an abelian group if it satisfies the following
condition:
5) Commutativ e : a • b = b • a for all a, b  G

• Examples of abelian groups:


• The set of integers (negative, zero, and positive), Z, under addition.
The identity element of Z under addition is 0;
the inverse of a is -a, for all a in Z.
• The set of non-zero real numbers, R*, under multiplication.
The identity element of R* under multiplication is 1;
the inverse of a is 1/a for all a in R*.
Exponentiation and Cyclic Groups
• Exponentiation within a group is repeated application of the group
operator, such that:
a 0 = e, the identity element
a n = a • a •  • a (i.e. • applied n-1 times)
a -n = (a' ) n , where a' is the inverse of a

• A group G is cyclic if every element of G is a power gk (k is an integer) of a


fixed element g  G. The element g is said to generate the group, or to be
a generator of the group.
• A cyclic group is always abelian, and may be finite or infinite
• Example of a cyclic group:
• The group of positive integers, {N, +}, (N = {1, 2, 3, ...}) under addition is an infinite cyclic
group generated by the element 1. (i.e. 1 + 1 = 2, 1 + 1 + 1 = 3, etc.)
Rings
• A ring, R, denoted by {R, +,  }, is a set of elements with two binary operations, called
addition (+) and multiplication ( ), such that, for a, b, c in R:
addition and multiplication are abstract operations here
1)-5) R is an abelian group with respect to addition; for this case of an additive group, we denote the
identity element as 0, and the inverse of a as -a.
6) Closure under multiplication:
If a and b belong to R, then a  b is also in R
7) Associativity of multiplication:
Note that we often
a  (b c) = (a  b) c for all a, b, c, in R write a b as simply ab
8) Distributive Laws:
Commutative Rings
• A ring is commutative if it satisfies the following additional condition:

9) Commutativity of multiplication:
a  b = b  a for all a, b, c, in R

Example of a commutative ring:


The set of even integers, {..., -4, -2, 0, 2, 4, ...}) under the normally
defined integer operations of addition and multiplication.
Integral Domains
• An integral domain is a commutative ring that obeys the following:

10) Multiplicative identity:


There is an element 1 in R such that a x 1 = 1 x a = a for all a in R
11) No zero divisors:
If a, b in R and a x b = 0, then either a = 0 or b = 0

Example of an integral domain:


The set of all integers (Z = {..., -3, -2, -1, 0, 1, 2, 3, ...}) under the normally
defined integer operations of addition and multiplication, {Z, +, x}

Fields
• A field, F, denoted by {F, +, x}, is a set of elements with two binary
operations, called addition and multiplication, such that, for all a, b, c
in F, the following apply:
Again, addition and multiplication are abstract operations

1)-11) F is an integral domain

12) Multiplicative inverse:


For each a in F, except 0, there is an element a-1 in F such that:
a x a-1 = a-1 x a = 1
Fields
• A field is a set in which we can do addition, subtraction, multiplication, and
division without leaving the set.
• Division is defined:
a/b = a(b-1)

Examples:
• The set of rational numbers, Q; the set of real numbers, R, the set of complex
numbers, C.
• The set of all integers, Z, is not a field, because only the elements 1 and -1
have multiplicative inverses in the integers.
Galois Fields
• finite fields play a key role in cryptography
• order (number of elements) in a finite field must be a power of a
prime 𝑝𝑛
• known as Galois fields
• denoted 𝐺𝐹(𝑝𝑛)
• Two cases:
• 𝐺𝐹 𝑝 , 𝑛 = 1
• 𝐺𝐹 𝑝𝑛 , 𝑛 > 1
• GP(P) has a different structure than 𝐺𝐹 𝑝𝑛
Galois Fields GF(p)
• 𝐺𝐹(𝑝) is the set of integers {0,1, … , 𝑝 − 1} with arithmetic
operations modulo prime 𝑝
• these form a finite field
• since have multiplicative inverses
• Hence, can do addition, subtraction, multiplication, and division
without leaving the field GF(p)
GF(7) Example
 0 1 2 3 4 5 6 + 0 1 2 3 4 5 6
0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6
1 0 1 2 3 4 5 6 1 1 2 3 4 5 6 0
2 0 2 4 6 1 3 5 2 2 3 4 5 6 0 1
3 0 3 6 2 5 1 4 3 3 4 5 6 0 1 2
4 0 4 1 5 2 6 3 4 4 5 6 0 1 2 3
5 0 5 3 1 6 4 2 5 5 6 0 1 2 3 4
6 0 6 5 4 3 2 1 6 6 0 1 2 3 4 5
Polynomial Arithmetic
• represent a bit pattern by a polynomial in, say, the variable x. Each
power of x in the polynomial can stand for a bit position in a bit
pattern.
• For example, we can represent the bit pattern 111 by the polynomial x2 + x
+ 1.
• the bit pattern 101 would be represented by the polynomial x2 + 1.
• representing a bit pattern with a polynomial will allow us to create
a finite field with bit patterns.
Polynomial Arithmetic
• Can compute using polynomials 𝑛
_1
𝑓 𝑥 = 𝑎𝑛𝑥𝑛 + 𝑎𝑛−1 𝑥𝑛 + … + 𝑎1𝑥 + 𝑎0 = ෍ 𝑎𝑖𝑥𝑖
𝑖=0
• nb. not interested in any specific value of x
• which is known as the indeterminate
• Three classes of polynomial arithmetic
• Ordinary polynomial arithmetic
• Polynomial arithmetic in which the arithmetic on the coefficients
is performed modulo 𝒑; that is, the coefficients are in 𝐺𝐹(𝑝)
• Polynomial arithmetic in which the coefficients are in 𝐺𝐹(𝑝), and
the polynomials are defined modulo a polynomial 𝒎(𝒙) whose
highest power is some integer.
Ordinary Polynomial Arithmetic
• add or subtract corresponding coefficients
• multiply all terms by each other
• eg
let f(x) = x3 + x2 + 2 and g(x) = x2 – x + 1
f(x) + g(x) = x3 + 2x2 – x + 3
f(x) – g(x) = x3 + x + 1
f(x) x g(x) = x5 + 3x2 – 2x + 2
Ordinary Polynomial Arithmetic
Polynomial Arithmetic with Coefficients in 𝑍𝑝
• set of all polynomials over a field constitutes a ring. Such a ring is also
called the polynomial ring.
• polynomial multiplication is commutative, the set of polynomials over
a field is actually a commutative ring.
• Polynomial division is not allowed for polynomials that are not
defined over fields. For example, for polynomials defined over the set
of all integers, you cannot divide 4x2 + 5 by the polynomial 5x.
• if 𝑔(𝑥) has no divisors other than itself & 1 say it is irreducible (or
prime) polynomial
• arithmetic modulo on irreducible polynomial forms a field
• 𝑒. 𝑔. 𝑥 3 + 𝑥 + 1
Finite fields of the form n
GF(2 )
• For polynomials over 𝑝𝑛, with 𝑛 > 1, operations modulo 𝑝𝑛 do not
produce a field.
• Modular polynomial arithmetic
• With the appropriate definition of arithmetic operations, each such
set S is a finite field.
1. Arithmetic follows the ordinary rules of polynomial arithmetic using
the basic rules of algebra, with the following two refinements.
2. If multiplication results in a polynomial of degree greater than n-1,
then the polynomial is reduced modulo some irreducible
polynomial m(x) of degree n.
Finite fields of the form n
GF(2 )
• can compute in field GF(2n)
• polynomials with coefficients modulo 2
• whose degree is less than n
• hence must reduce modulo an irreducible poly of degree n (for multiplication
only)
• form a finite field
• can always find an inverse
• can extend Euclid’s Inverse algorithm to find
Finite fields of the form n
GF(2 )
• Example 1. For a=𝑥2 + 𝑥 + 1 and b=𝑥 + 1 with a primitive of 𝑥4 + 𝑥 +
1 (GF(24)).
• add: 𝑥2 + 2𝑥 + 2
• Multiply: 𝑥3 + 2𝑥2 + 2𝑥 + 1
• Example 2. For a=𝑥3 and b=𝑥2 + 1 with a primitive of 𝑥4 + 𝑥 + 1
(GF(24)).
• 𝐴𝑑𝑑 = (𝑥3) + (𝑥2 + 1) = 𝒙𝟑 + 𝒙𝟐 + 𝟏
• 𝑀𝑢𝑙𝑡 = 𝑥3 × 𝑥2 + 1 = 𝑥5 + 𝑥3
• 𝑥5 + 𝑥3 𝑚𝑜𝑑 𝑥4 + 𝑥 + 1 = 𝒙𝟑 + 𝒙𝟐 + 𝒙
Example GF(23)
Example GF(23)
Arithmetic in 3
GF(2 )
Arithmetic in 3
GF(2 )
Practice Questions
• Let’s consider the set of all polynomials whose coefficients belong
to the finite field 𝑍7 (which is the same as GF (7)).
𝑓 (𝑥) = 5𝑥 2 + 4𝑥 + 6
𝑔(𝑥) = 2𝑥 + 1
𝑓 (𝑥) + 𝑔(𝑥) =
𝑓 𝑥 − 𝑔 𝑥 =
𝑓 (𝑥) × 𝑔 𝑥 =
• Develop a table similar to Table 4.7 for 𝐺𝐹(24) with 𝑚(𝑥) = 𝑥4 +
𝑥+1
Summary
• Euclidian Algorithm
• Modular arithmetic
• Finite Fields
• Polynomial Arithmetic
Reference
• Cryptography and Network Security-Principles and Practice, 8th
Edition, by Stallings William, published by Pearson, 2020
• Cryptography and Network Security, 3rd Edition, by Behrouz A
Forouzan and Depdeep Mukhopadhyay, published by McGrawHill,
2015

You might also like