Presentation on theme: "Data encryption with big prime numbers"— Presentation transcript:
1 Data encryption with big prime numbers Daniel FreemaN, SLU
2 Old school codesFull knowledge of the code is needed to both encrypt messagesand to decrypt messages.The code can only be used between a small number of trusted people.
3 Public key encryptionIf you buy something online, you need to send your credit card number to Amazon.Your computer needs to be able to encrypt your credit card number.Amazon does NOT want you to be able to decrypt other people’s credit card numbers.Everyone needs to be able to encrypt but only Amazon should be able to decrypt.We need a mathematical technique that is computationally very simple to evaluate, but is extremely computationally difficult to invert.
4 Multiplication is easy, factoring is hard Typing in the following into Wolfram Alpha*gives an output ofTyping in the following into Wolfram Alphafactorgives an output offactor
5 Mod n We think of x mod n as the remainder when x is divided by n. 1≡7 𝑚𝑜𝑑 32≡12 𝑚𝑜𝑑 50≡15 𝑚𝑜𝑑 5More generally, x≡y mod n means that x and y have the same remainder when divided by n,or that x-y is a multiple of n.10≡7 𝑚𝑜𝑑 322≡12 𝑚𝑜𝑑 530≡15 𝑚𝑜𝑑 5
6 Modular exponentiation 3 1 ≡3 𝑚𝑜𝑑 53 42 ≡ 𝑚𝑜𝑑 53 2 ≡9≡4 𝑚𝑜𝑑 5≡ 𝑚𝑜𝑑 53 3 ≡3∗ 3 2 ≡3∗4 ≡12≡2 𝑚𝑜𝑑 5≡ (3 2 ) 5 (3 2 ) 𝑚𝑜𝑑 53 4 ≡3∗ 3 3 ≡3∗2 ≡6≡1 𝑚𝑜𝑑 5≡ 4 5 ∗4 3 ∗4 𝑚𝑜𝑑 5⋮≡4 𝑚𝑜𝑑 5Fermat’s little theorem:Let p be a prime number and let x be an integer that is not divisible by p. Then,𝑥 𝑝−1 ≡1 mod p or 𝑥 𝑝 ≡x mod p
7 Key points of modular exponentiation xm mod n can be efficiently calculated by expressing the exponent m in binary.Fermat’s little theorem:Let p be a prime number and let x be an integer that is not divisible by p. Then,𝑥 𝑝−1 ≡1 mod pEuler’s theorem:Let p and q be distinct prime numbers and let x be an integer that is not divisible by p or q. Then,𝑥 (𝑝−1)(𝑞−1) ≡1 𝑚𝑜𝑑 𝑝𝑞𝑥 𝑝−1 𝑞−1 +1 ≡𝑥 𝑚𝑜𝑑 𝑝𝑞More generally, if m ≡ 1 mod (p-1)(q-1) then𝑥 𝑚 ≡𝑥 𝑚𝑜𝑑 𝑝𝑞
8 RSA encryption Choose 2 large prime numbers p and q. Calculate n=pq. p and q should be so large that it is not computationally feasible to factor n.n will be publicly shared, but p and q will be secret.Choose a positive integer e which is relatively prime to (p-1)(q-1). e will be publicly shared.Choose a positive integer d such thated ≡ 1 mod (p-1)(q-1)d will be secretSuppose someone wants to encrypt the integer x such that 1<x<n-1.They encrypt x as the value y ≡ xe mod nTo decrypt, we exponentiate to the power d to get yd ≡ xed ≡ x mod n
9 RSA example Choose p = 2498359 q = 5418341 p and q are just two big prime numbersCalculate n = pq = * =Calculate φ(n) = (p-1)(q-1) = * =Choose e =e was picked to be a prime number big enough to most likely not a factor of (p-1)(q-1)Solve ed ≡ 1 mod (p-1)(q-1)d =Suppose you want to send the number x= to Amazon.You calculate and send y= ≡ xe mod nAmazon then calculates x ≡ yd mod n