You are on page 1of 51

More Number Theory

and The RSA Cryptosystem


More number Theory
Write function gcd(a,b)
in Python

example
Exercise
example
Write
gcdex(a, b, ’s’, ’t’)
in Python
Exercise
Multiplicative inverse
• Proof
Exercise
example

Write
a^(-1) mod b in
Python
Chinese Remainder Theorem
Write function
chrem([a1, …, ar],[m1, …, mr]) in Python
Exercise
The order of a group element
The order of group elements
• Definition: The order of an element g in G is the
smallest positive integer m such that gm = 1.

• Example: Find the order of 3 and 2 in Z7*.


– 31 = 3; 32 = 2; 33 = 6; 34 = 4; 35 = 5; 36 = 1 (mod 7).
– 21 = 2; 22 = 4; 23 = 1 (mod 7).

Write function
order(3,7) in Python
• The order of an element g in Z7* must divides 6,
ord(g) is in{1, 2, 3, 6}.
• The order of an element g in Z11* must divides 10,
ord(g) is in{1, 2, 5, 10}.
Facts
Primitive element

Definition: An element having order p – 1 modulo p is


call a primitive element modulo p.
Exercise
Public key cryptosystem
Symmetric key cryptosystem
Public key cryptosystem (PKC)
Remind: One-way function
The RSA cryptosystem
Exercise: show that (xb)a = x (mod n) if x in Zn\ Zn*.
Example
Cryptool it!
The trapdoor in RSA
RSA Parameter generation
Implementation
• Fast exponentiation
Primality testing
A simple deterministic algorithm
• For i from 2 to sqrt(n) do
– If n mod i = 0 then return FALSE
– End if
• End do
• Return TRUE

• Time complexity is O(sqrt(n)).


Randomized Algorithm
• They can make random choices during their
execution.
• Las Vegas algorithm:
– may fail to give an answer, but if the algorithm does return
an answer, then the answer must be correct.
• Mote Carlo algorithm:
Quadratic residue
Legendre symbol
Jacobi symbol
Example
Compute Jacobi symbol
Compute Jacobi symbol
The Solovay-Strassen Algorithm
The Solovay-Strassen Algorithm properties

• This is a yes-biased Monte Carlo algorithm with


error probability at most ½.
• If we run the algorithm m times, the probability that
such an integer n is prime is 1 – 2-m.

Write isprime(a) in Python;


Factoring Algorithms
Trial division

5
15
30 3
60 2
2

60 = 2 * 2 * 3* 5.
The three most effective algorithms
1. The Quadratic Sieve
2. The Elliptic Curve Factoring Algorithm
3. The Number Field Sieve

write ifactor(n) in Python

You might also like