Unit 6 - Notes

MTH401

Unit 6: Number theory and its application in cryptography

1. Divisibility and Modular Arithmetic

Divisibility

Let and be integers with . We say that divides (denoted ) if there exists an integer such that .

  • If , then is a factor of , and is a multiple of .
  • If does not divide , we write .

Properties of Divisibility:
For all integers :

  1. Reflexive: .
  2. Transitive: If and , then .
  3. Linear Combination: If and , then for any integers .

Modular Arithmetic

Modular arithmetic is a system of arithmetic for integers, where numbers "wrap around" when reaching a certain value, called the modulus.

Congruence Definition:
Let be a positive integer. Two integers and are said to be congruent modulo if divides their difference ().
This is denoted as:

Equivalent Statements:

  1. for some integer .
  2. and have the same remainder when divided by .
  3. .

Properties of Congruence:
If and , then:

  • for any positive integer .

2. Primes

Definition

A positive integer is called prime if its only positive divisors are $1$ and .
A positive integer greater than $1$ that is not prime is called composite.

Fundamental Theorem of Arithmetic

Every integer can be written uniquely as a product of primes, up to the order of the factors.


Where are distinct primes and .


3. GCD, LCM, and Euclidean Algorithm

Greatest Common Divisor (GCD)

The greatest common divisor of two integers and (not both zero), denoted , is the largest integer such that and .

  • If , then and are relatively prime (or coprime).

Least Common Multiple (LCM)

The least common multiple of two integers and , denoted , is the smallest positive integer that is divisible by both and .

Relationship between GCD and LCM:

The Euclidean Algorithm

An efficient method for computing the GCD without factoring the numbers. It relies on the property: .

Procedure:
To find where :

  1. Divide by to find remainder : .
  2. .
  3. Repeat until the remainder is $0$. The last non-zero remainder is the GCD.

Example: Find .


  1. Since the remainder is 0, the previous remainder is the answer.
    .

Bezout's Lemma

If and are positive integers, then there exist integers and such that:


These integers and can be found using the Extended Euclidean Algorithm by working backward through the Euclidean Algorithm steps.


4. Linear Congruence and Inverses

Linear Congruence

A linear congruence is an equation of the form:


where is an unknown integer.

Solvability Condition:
The congruence has a solution if and only if , where .

  • If , there are no solutions.
  • If , there are exactly incongruent solutions modulo .

Inverse of modulo

The modular multiplicative inverse of modulo is an integer (or ) such that:

Existence: The inverse exists if and only if (i.e., and are coprime).

How to find it: Use the Extended Euclidean Algorithm to find and such that . Then is the inverse of modulo .

Chinese Remainder Theorem (CRT)

CRT allows solving a system of simultaneous congruences with pairwise coprime moduli.

Theorem:
Let be pairwise relatively prime positive integers ( for ).
The system:


has a unique solution modulo .

Solution Formula:


Where:

  • is the modular inverse of modulo (i.e., ).

5. Fermat’s Little Theorem

Theorem Statement

If is a prime number and is an integer not divisible by (i.e., ), then:

Alternative Form:
For any integer and prime :

Applications:

  1. Simplifying powers: Computing where is very large. You can reduce the exponent by modulo .
  2. Finding Inverses: If is prime and , then .
  3. Primality Testing: Used as a probabilistic test to check if a number is prime.

6. Cryptography Applications

Cryptography involves transforming a message (Plaintext, ) into an unreadable format (Ciphertext, ) using a Key.

Map of Alphabet to Integers

For these algorithms, we map standard English letters to integers:
A=0, B=1, C=2, ..., Z=25. The modulus is .

Caesar Cipher

A shift cipher where each letter is shifted by a fixed number .

  • Encryption:
  • Decryption:
  • Key: The integer .

Example:
Shift .
Plaintext "A" (0) Ciphertext "D".

Affine Cipher

A monoalphabetic substitution cipher using a linear function.

  • Encryption:

    • and are the keys.
    • Constraint: must be $1$ for the cipher to be invertible (decryptable).
    • Possible values for : 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25.
  • Decryption:
    To decrypt, we solve for .


    Multiply by (the modular inverse of modulo 26):

Example of Affine Decryption:
Let .
To decrypt, we need the inverse of .
Using Euclidean Algorithm, (since ).
Decryption formula: