WINSEM2024-25 BCSE309L TH VL2024250501948 2024-12-17 Reference-Material-I
WINSEM2024-25 BCSE309L TH VL2024250501948 2024-12-17 Reference-Material-I
Module 1-
Fundamentals of Number
Theory
Winter Semester 2024-25
𝑎𝑠 + 𝑏𝑡 = 𝑑 = 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 .
9) Commutativity of multiplication:
a b = b a for all a, b, c, in R
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
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