Public-key cryptography relies a lot on number theory

In the set of integers we can

  • Add, Subtract, Multiply
  • not do division

Euclidean Division

To divide integers, we are left with a remainder and the quotient

The result of the division is given by

However, programming languages don’t always have a positive remainder :

DivisionJava/C/C++Python
In this class, we will always have as a positive integer

We have the notation

Quote

You have to be able to do modulo in your sleep to understand the modulo world.

  • Gastpar

Congruence

Two numbers that have the same remainder are said to be congruent

Definition

Two integers are said to be congruent to

Congruence is an equivalence relation (reflexive, symmetric and transitive)

If we have and then we have

Check Digits mod

It is a way to check if an error has occurred when typing a number (swapping digits around)

Let’s say we have a phone number we want to dial.

We compute its remainder after division by (a prime number)

We call those the check digits

If we dial the wrong number, the error can be seen easily: , which is not equal to the check digits.

Variant mod

Algorithm

We have our number , mod works as such:

  1. We multiply by
  2. We denote as the remainder
  3. The check digits are given by
  4. Replace the ending with
  5. Check that the resulting number

Here’s why it works :

This algorithm is used to describe IBAN numbers per example.

with the check digits

Prime numbers

Definition

A prime number is an integer that has no other divisor other than and itself

Theorem

Every composite (=non-prime) number has a unique prime factorization

Theorem

For two numbers , divides all prime factors of are present in the prime factorization of

We get the integers and . The largest integer that divides both is called the greatest common divisor of and , which we denote

Theorem

For two integers and , and their prime sequence given by

And the is given by

with

Relatively prime

If both numbers don’t have a common factor, then it means that their

Definition

We say that are coprime when

Theorem

If divides , and divides and , then we have that divides

02.3 Modular Arithmetic