Fermat's little theorem
Last updated
Last updated
This page is about modular arithmetic.
The integers modulo p
define a field, denoted Fp
.\
A finite field Fp
is the set of integers {0,1,...,p-1}
, and under both addition and multiplication there is an inverse element b
for every element a
in the set, such that
a + b = 0
and a * b = 1
.
Fermat's Little Theorem is a result in number theory that states that if **a
** is an integer and p
is a prime number, then for all integers a
:
This means that :
In cryptography, it is used in the modular exponentiation algorithm, which is a basic building block in many public key encryption algorithms such as the RSA algorithm.
Modular inversion, also known as modular reciprocal, is the process of finding the multiplicative inverse of an integer a
modulo p
.
The multiplicative inverse of a
modulo p
is an integer b
such that :
b
and is unique for each a
and m
couple
There is two methods in order to calculate the modular inverse of a number
The extended euclid's algorithm permit to quickly find the modular inverse such as :
Where u
is solution for :
This equation is solved using the extended Euclid's algorithm.
Exemple with a = 3 and p = 13
The theorem says :
The equation can be continued :
Using the same example as before :