Chapter 4. Number Theory and Cryptography
Chapter 4. Number Theory and Cryptography
Chapter 4. Number Theory and Cryptography
Contents
Contents
Contents
Division
Division
Division
Division
a = dq + r, 0 ≤ r < d
a = dq + r, 0 ≤ r < d
a = dq + r, 0 ≤ r < d
a = dq + r, 0 ≤ r < d
a = dq + r, 0 ≤ r < d
a = dq + r, 0 ≤ r < d
a = dq + r, 0 ≤ r < d
Quizz
Quizz
6|(17 − 5)?
Theorem
Theorem
Theorem
Theorem
Theorem
Theorem
Example.
Example.
1. What is the secret message produced from the
message “MEET YOU IN THE PARK” using the Caesar
cipher (k=3)?
Example.
Example.
1. What is the secret message produced from the
message “MEET YOU IN THE PARK” using the Caesar
cipher (k=3)?
2. Decrypt the ciphertext message “LEWLYPLUJL PZ H
NYLHA ALHJOLY” that was encrypted with the shift
cipher with shift k = 7.
Example.
Example.
1. What is the secret message produced from the
message “MEET YOU IN THE PARK” using the Caesar
cipher (k=3)?
2. Decrypt the ciphertext message “LEWLYPLUJL PZ H
NYLHA ALHJOLY” that was encrypted with the shift
cipher with shift k = 7.
3. What letter replaces the letter K when the function
f (p) = (7p + 3)mod26 is used for encryption?
Quizz
Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
• c: Increment (số gia) (0 ≤< m)
Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
• c: Increment (số gia) (0 ≤< m)
• x0 : seed (hạt giống) (0 ≤ x0 < m)
Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
• c: Increment (số gia) (0 ≤< m)
• x0 : seed (hạt giống) (0 ≤ x0 < m)
• m: modulus (mođun)
Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
• c: Increment (số gia) (0 ≤< m)
• x0 : seed (hạt giống) (0 ≤ x0 < m)
• m: modulus (mođun)
Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
• c: Increment (số gia) (0 ≤< m)
• x0 : seed (hạt giống) (0 ≤ x0 < m)
• m: modulus (mođun)
Example.(Random numbers from 0 to 8) Find the
sequence of pseudorandom numbers generated by the
linear congruential method with modulus m = 9, multiplier
a = 7, increment c = 4, and seed x0 = 3.
Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
• c: Increment (số gia) (0 ≤< m)
• x0 : seed (hạt giống) (0 ≤ x0 < m)
• m: modulus (mođun)
Example.(Random numbers from 0 to 8) Find the
sequence of pseudorandom numbers generated by the
linear congruential method with modulus m = 9, multiplier
a = 7, increment c = 4, and seed x0 = 3.m = 9, a = 7, c =
4, x0 = 3 =⇒ xn+1 = 7xn + 4
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems
Notes.
• a: Multiplier (nhân tử) (2 ≤ a < m)
• c: Increment (số gia) (0 ≤< m)
• x0 : seed (hạt giống) (0 ≤ x0 < m)
• m: modulus (mođun)
Example.(Random numbers from 0 to 8) Find the
sequence of pseudorandom numbers generated by the
linear congruential method with modulus m = 9, multiplier
a = 7, increment c = 4, and seed x0 = 3.m = 9, a = 7, c =
4, x0 = 3 =⇒ xn+1 = 7xn + 4 =⇒ x1 , x2 , ...
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems
Example.
H (k ) = k mod m
Using in searching data in memory
• k: data searched,
H (k ) = k mod m
Using in searching data in memory
• k: data searched,
• m: memory block.
H (k ) = k mod m
Using in searching data in memory
• k: data searched,
• m: memory block.
H (k ) = k mod m
Using in searching data in memory
• k: data searched,
• m: memory block.
Example. Find the memory locations assigned by the
hashing function h(k ) = k mod 111 to the records of
customers with Social Security numbers 064212848 and
037149212.
Representations of Integers
Representations of Integers
Representations of Integers
Representations of Integers
Representations of Integers
Representations of Integers
Representations of Integers
Representations of Integers
Representations of Integers
Representations of Integers
Representations of Integers
Representations of Integers
Examples.
Examples.
Examples.
Quizz
Quizz
1 = 0.2 + 1
1 = 0.2 + 1
2 = 1.2 + 0
1 = 0.2 + 1
2 = 1.2 + 0
2 = 1.2 + 0
1 = 0.2 + 1
2 = 1.2 + 0
2 = 1.2 + 0
3 = 1.2 + 1
1 = 0.2 + 1
2 = 1.2 + 0
2 = 1.2 + 0
3 = 1.2 + 1
1 = 0.2 + 1
1 = 0.2 + 1
2 = 1.2 + 0
2 = 1.2 + 0
3 = 1.2 + 1
1 = 0.2 + 1
1 = 0.2 + 1
2 = 1.2 + 0
2 = 1.2 + 0
3 = 1.2 + 1
1 = 0.2 + 1
Thus, (1110)2 + (1011)2 = (11001)2
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems
Rules.
• 0−0 = 0
Rules.
• 0−0 = 0
• 1−0 = 1
Rules.
• 0−0 = 0
• 1−0 = 1
• 1−1 = 0
Rules.
• 0−0 = 0
• 1−0 = 1
• 1−1 = 0
• 0 − 1 = 1( remind − 1)
Rules.
• 0−0 = 0
• 1−0 = 1
• 1−1 = 0
• 0 − 1 = 1( remind − 1)
• −1 − 1 = 0( remind − 1)
Rules.
• 0−0 = 0
• 1−0 = 1
• 1−1 = 0
• 0 − 1 = 1( remind − 1)
• −1 − 1 = 0( remind − 1)
Rules.
• 0−0 = 0
• 1−0 = 1
• 1−1 = 0
• 0 − 1 = 1( remind − 1)
• −1 − 1 = 0( remind − 1)
Let a = (1110)2 and b = (1011)2 . Find a − b
Rules.
• 0−0 = 0
• 1−0 = 1
• 1−1 = 0
• 0 − 1 = 1( remind − 1)
• −1 − 1 = 0( remind − 1)
Let a = (1110)2 and b = (1011)2 . Find a − b
(1110)2 − (1011)2 = (11)2
Addition Algorithm
Addition Algorithm
Multiplication Algorithm
Multiplication Algorithm
Division Algorithm
Division Algorithm
Modular Exponentiation
Modular Exponentiation
Primes
Definition.
• A positive integer p greater than 1 is called prime (số
nguyên tố) if the only positive factors (ước số) are 1
and p.
Primes
Definition.
• A positive integer p greater than 1 is called prime (số
nguyên tố) if the only positive factors (ước số) are 1
and p.
• A positive integer that is greater than 1 and is not
prime is called composite (hợp số).
Example.
Theorem
Theorem
Theorem
Theorem
Theorem
Theorem
Examples.
1. gcd (24, 36)
Examples.
1. gcd (24, 36)
Examples.
1. gcd (24, 36)→ gcd (24, 36) = 12
2. gcd (17, 22)
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems
Examples.
1. gcd (24, 36)→ gcd (24, 36) = 12
2. gcd (17, 22)
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems
Examples.
1. gcd (24, 36)→ gcd (24, 36) = 12
2. gcd (17, 22)→ gcd (17, 22) = 1
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems
Definition.
Definition.
Definition.
Definition.
Definition.
Examples.
1. lcm(12, 36)
Examples.
1. lcm(12, 36)
Examples.
1. lcm(12, 36)→ lcm(12, 36) = 36
2. lcm(7, 17)
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems
Examples.
1. lcm(12, 36)→ lcm(12, 36) = 36
2. lcm(7, 17)
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems
Examples.
1. lcm(12, 36)→ lcm(12, 36) = 36
2. lcm(7, 17)→ lcm(7, 17) = 119
Lai Văn Phút Chapter 4. Number Theory and Cryptography
The Integers and Division Integers and Algorithms Primes and Greatest Common Divisors Problems
Theorem
Theorem
Euler φ-function
Euler φ-function
Quizz
Quizz