Cryptography and Network Security Chapter 2
Cryptography and Network Security Chapter 2
Cryptography and Network Security Chapter 2
1. Divisibility Concepts
Basic Definition
Properties of Divisibility
1. If a|1, then a = ±1
2. If a|b and b|a, then a = ±b
3. Any b ≠ 0 divides 0
4. If a|b and b|c, then a|c (transitivity)
5. If b|g and b|h, then b|(mg + nh) for any integers m and n
Proof of Property 5:
Example:
Formal Statement
For any positive integer n and any integer a, there exist unique integers q (quotient) and r
(remainder) such that:
a = qn + r
where 0 ≤ r < n
Key Points
Examples
1. When a = 11, n = 7:
o 11 = 1 × 7 + 4
o r = 4, q = 1
2. When a = -11, n = 7:
o -11 = (-2) × 7 + 3
o r = 3, q = -2
Visual Representation
Important Note
While called an "algorithm," this is actually a theorem that states the existence and uniqueness of
q and r. However, by tradition, it is referred to as the division algorithm.
1. Basic Definitions
Two integers are relatively prime if their only common positive integer factor is 1
Example: 8 and 15 are relatively prime because:
o Divisors of 8: 1, 2, 4, 8
o Divisors of 15: 1, 3, 5, 15
o Only common divisor: 1
Notation: gcd(a, b)
Definition: Largest integer that divides both a and b
Formal properties:
1. c is a divisor of both a and b
2. Any divisor of a and b is also a divisor of c
Alternative definition: gcd(a, b) = max[k, such that k|a and k|b]
Important properties:
Algorithm Steps
a = q₁b + r₁ 0 ≤ r₁ < b
b = q₂r₁ + r₂ 0 ≤ r₂ < r₁
r₁ = q₃r₂ + r₃ 0 ≤ r₃ < r₂
...
rₙ₋₁ = qₙ₊₁rₙ + 0
Flowchart Logic
1. Compare a and b
2. If a < b, swap a and b
3. Divide a by b, get remainder r
4. If r = 0, b is the GCD
5. If r ≠ 0, replace a with b and b with r
6. Repeat steps 3-5 until r = 0
310 = 3 × 90 + 40
90 = 2 × 40 + 10
40 = 4 × 10 + 0
2156 = 2 × 1078 + 0
3. Proof of Correctness
Top-Down Proof
Bottom-Up Proof
1. Basic Concepts
The Modulus
Congruence
Properties of Congruences
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)
Basic Properties
Example Calculations
11 mod 8 = 3; 15 mod 8 = 7
Modular Exponentiation
Example: 11⁷ mod 13
3. Residue Classes
Definition
Example (mod 4)
4. Special Properties
Multiplicative Inverses
Important Theorems
Purpose
1. Basic Definition
Basic Statement
Every integer a > 1 can be factored uniquely as: a = p₁ᵃ¹ × p₂ᵃ² × ... × pₜᵃᵗ
Where:
o p₁ < p₂ < ... < pₜ are prime numbers
o Each aᵢ is a positive integer
Examples
91 = 7 × 13
3600 = 2⁴ × 3² × 5²
11011 = 7 × 11² × 13
Alternative Expression
all p ∈ P
For set P of all prime numbers, any positive integer a can be written as: a = ∏(p^ap) for
Examples
12 is represented by {a₂ = 2, a₃ = 1}
18 is represented by {a₂ = 1, a₃ = 2}
Multiplication
Example
k = 12 × 18
= (2² × 3) × (2 × 3²)
= 2³ × 3³
= 216
Where:
k₂ = 2 + 1 = 3
k₃ = 1 + 2 = 3
5. Division Properties
Divisibility Rule
Example
12|36 because:
12 = 2² × 3
36 = 2² × 3²
Check:
a₂ = 2 = b₂
a₃ = 1 ≤ 2 = b₃
Rule
Example
300 = 2² × 3¹ × 5²
18 = 2¹ × 3²
gcd(18,300) = 2¹ × 3¹ × 5⁰ = 6
Important Note
While this method is theoretically elegant, it's not practical for large numbers since finding prime
factors of large numbers is computationally difficult.
1. Fermat's Theorem
Basic Statement
Alternative Form
Examples
For a = 7, p = 19:
7² = 49 ≡ 11 (mod 19)
7⁸ ≡ 49 ≡ 11 (mod 19)
Definition
Properties
Examples
3. Euler's Theorem
Basic Statement
Alternative Form
Examples
a = 3, n = 10:
φ(10) = 4
3⁴ = 81 ≡ 1 (mod 10)
a = 2, n = 11:
φ(11) = 10
4. Proof Components
5. Applications
1. Introduction
2. Miller-Rabin Algorithm
Fundamental Properties
Algorithm (TEST)
TEST(n)
4. for j = 0 to k - 1 do
6. return "composite"
Examples
1. Testing n = 29 (prime):
k = 2, q = 7
With a = 10:
10⁷ mod 29 = 17
k = 2, q = 55
With a = 5:
With a = 21:
Reliability
4. Distribution of Primes
Interesting Facts
Practical Implications
1. Basic Concept
Allows reconstruction of integers from their residues modulo relatively prime moduli
Originally discovered by Chinese mathematician Sun-Tsu (circa 100 A.D.)
Simple Example
2. Formal Statement
Prerequisites
Let M = m₁ × m₂ × ... × mₖ
Where all mᵢ are pairwise relatively prime (gcd(mᵢ,mⱼ) = 1 for i ≠ j)
Mapping
A ∈ ZM
aᵢ ∈ Zmᵢ
aᵢ = A mod mᵢ for 1 ≤ i ≤ k
3. Main Assertions
First Assertion
Second Assertion
Arithmetic Operations
(A + B) mod M ↔ ((a₁ + b₁) mod m₁, ..., (aₖ + bₖ) mod mₖ)
(A - B) mod M ↔ ((a₁ - b₁) mod m₁, ..., (aₖ - bₖ) mod mₖ)
(A × B) mod M ↔ ((a₁ × b₁) mod m₁, ..., (aₖ × bₖ) mod mₖ)
5. Practical Example
Setup
m₁ = 37, m₂ = 49
M = 1813
A = 973
Conversion to Tuple
973 mod 37 = 11
973 mod 49 = 42
Addition Example
Multiplication Example
Multiply 1651 by 73:
6. Applications
Order of an Integer
7¹ ≡ 7 (mod 19)
7² = 49 ≡ 11 (mod 19)
2. Primitive Roots
Definition
Important Properties
Existence
3. Discrete Logarithms
Definition
Basic Properties
dlogₐ,ₚ(1) = 0
dlogₐ,ₚ(a) = 1
4. Computational Aspects
Forward Calculation
5. Applications
6. Example Tables