tags: math, cryptography

Prime Numbers

prime numbers are essential in cryptography, they are the essence of cryptography due to their properties. Any number can be written as multiplication of prime numbers. We create a large prime number by multiplying the prime factors together, leading to a large prime number that is hard to be factorized by the crypt-analyst.

GCD of two numbers can be calculated from their prime number decomposition.

Example

And it is clear why it works, 300 has 2 and 3 its factors the same is 18, so the greatest factors they share are

Fermat’s Theorem

Where is a positive integer relatively prime to and is a prime number.

NOTE: multiplying a relative prime number to p by another relative prime number to p will also give you a number relative prime to p.

Proof of Fermat

Alt. Fermat’s Theorem

If p is prime and a is any positive integer If a is relatively prime to p then proving this is easy, just follow Fermat’s and multiply the last step by a. If a a positive integer then both terms equals 0, there is no other answer.

Euler’s Formula and Euler’s Totient function

Euler’s Totient function is defined as and it gives the number of numbers that are less than and relatively prime to it, if is prime then totient function will give and it is clear why.

Now if and are two prime numbers and then . Proof: and are the number of number in the sets of number that are not relatively prime to n. (it looks like p and q are the private keys)

Euler Theorem states that:

NOTE: a must be relatively prime to n

The proof for it is nearly the same as Fermat’s proof: And S is a permutation of R, since a is relatively prime to n X is relatively prime to n so their multiplication will always give a number relatively prime to n.

Alt Euler’s Theorem

To prove it, just the same as we said with Alt. Fermat Theorem

Chinese Remainder Theorem

The theorem says that we re-construct integers in a range from their residues modulo the factorization of a number, let’s say we have the number 10, we can factorize it to two relatively prime number 2 and 5, i.e . Now we have a range of numbers from 0 to 9: Let’s say we want to do operations on 9, we can transform 9 to a set of residues: We can do any operations on these numbers and reconstruct them back by the following formula: where is the integer 9 and are the residues is the selector, without doing the mod and , proving the reconstruction: is called the selector because if I want to get , will select and cancel the other because the other can be divisible by , also look here. The benefit of CRT is that it allows the simplification of large number operation.

Discrete Exponent and Logarithm

If we have an integer and the exponentiation of a by numbers from 1 to the answer will be a repeating sequence of numbers, if the period of that sequence is then is a primitive root of .

According to the book the first exponent that gets to one is the period. We can deduce that:

The discrete logarithm is hard to calculate, because there is no other way than brute-forcing.

Discrete logarithm only exist if is a primitive root because if the period is smaller than then some solutions wont exist.