Author: Zademn
Two of the skills a cryptographer must master are:
Knowing his way and being comfortable to work with numbers.
Understanding and manipulating abstract objects.
This chapter of fundamentals proposes to prepare you for understanding the basics of number theory and abstract algebra .We will start with the most basic concepts such as division and build up knowledge until you, future cryptographer, are able to follow and understand the proofs and intricacies of the cryptosystems that make our everyday life secure.
We will provide examples and snippets of code and be sure to play with them. If math is not your strongest suit, we highly suggest to pause and ponder for each concept and take it slow.
For the math-savy people we cover advanced topics in specific chapters on the subjects of number theory and group theory.
So what are we waiting for? Let's jump right in!
Let be the set denoting the integers.
Definition - Divisibility
For we say that divides if there is some such that
Notation:
Example
For we have because we can find such that .
Properties
Definition - Division with remainder
Examples:
Exercises:
Now it's your turn! Play with the proprieties of the division in Python and see if they hold.
Definition
Examples:
Remark:
Although we have functions that can compute our easily it's important enough that we need to give and study an algorithm for it: the euclidean algorithm.
It's extended version will help us calculate modular inverses which we will define a bit later.
Important Remark
If and then . Therefore
We write the following:
Or iteratively until we find a . Then we stop
Now here's the trick:
Pause and ponder. Make you you understand why that works.
Example:
Code
Exercises:
Implement the algorithm in Python / Sage and play with it. Do not copy paste the code
This section needs to be expanded a bit.
Bezout's identity
and implies
Example: Let and
and . We can find such that
and implies
if and then
Let with ,
There exists unique such that and
is called the quotient and the remainder
To find python offers us the divmod()
function that takes as arguments
If we want to find only the quotient we can use the //
operator
If we want to find the remainder we can use the modulo %
operator
Let be 2 integers. The greatest common divisor is the largest integer such that and
Notation:
for all other common divisors of we have
What can we say about numbers with ? How are their divisors?
If then divides
Calculate
Pick 2 numbers and calculate their by hand.
Let . Then there exists such that
The extended euclidean algorithm aims to find given