Data encryption with big prime numbers DANIEL FREEMAN, SLU.

9
Data encryption with big prime numbers DANIEL FREEMAN, SLU

Transcript of Data encryption with big prime numbers DANIEL FREEMAN, SLU.

Page 1: Data encryption with big prime numbers DANIEL FREEMAN, SLU.

Data encryption with big prime numbersDANIEL FREEMAN, SLU

Page 2: Data encryption with big prime numbers DANIEL FREEMAN, SLU.

Old school codes

Full 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.

Page 3: Data encryption with big prime numbers DANIEL FREEMAN, SLU.

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.

Page 4: Data encryption with big prime numbers DANIEL FREEMAN, SLU.

Multiplication is easy, factoring is hard

3568535685356853568535723 * 7564533681359827542555893

Typing in the following into Wolfram Alpha

gives an output of 26994308385016394749558484505346578147056894665639

Typing in the following into Wolfram Alpha factor 26994308385016394749558484505346578147056894665639

gives an output of factor 26994308385016394749558484505346578147056894665639

Page 5: Data encryption with big prime numbers DANIEL FREEMAN, SLU.

Mod nWe think of x mod n as the remainder when x is divided by n.

1≡7𝑚𝑜𝑑3 5 5

More 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𝑚𝑜𝑑3 5 5

Page 6: Data encryption with big prime numbers DANIEL FREEMAN, SLU.

Modular exponentiation31≡3𝑚𝑜𝑑5

32≡9≡4𝑚𝑜𝑑5

33≡3∗32≡3∗4≡12≡2𝑚𝑜𝑑5

34≡3∗33≡3∗2≡6≡1𝑚𝑜𝑑5

Fermat’s little theorem: Let p be a prime number and let x be an integer that is not divisible by p. Then,

𝑥𝑝−1≡1mod p∨𝑥𝑝≡ xmod p

342≡325+23+2𝑚𝑜𝑑5

≡325+23+2𝑚𝑜𝑑5

≡(3¿¿2)5(3¿¿2)332𝑚𝑜𝑑5¿¿

≡45∗43∗4𝑚𝑜𝑑5

≡4𝑚𝑜𝑑5

Page 7: Data encryption with big prime numbers DANIEL FREEMAN, SLU.

Key points of modular exponentiation

𝑥(𝑝− 1)(𝑞− 1)≡1𝑚𝑜𝑑𝑝𝑞

𝑥 (𝑝− 1) (𝑞−1 )+1≡ 𝑥𝑚𝑜𝑑𝑝𝑞

More generally, if m ≡ 1 mod (p-1)(q-1) then 𝑥𝑚≡𝑥𝑚𝑜𝑑𝑝𝑞

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,

Euler’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,

Page 8: Data encryption with big prime numbers DANIEL FREEMAN, SLU.

RSA encryptionChoose 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.

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 that ed ≡ 1 mod (p-1)(q-1)

Suppose someone wants to encrypt the integer x such that 1<x<n-1.

They encrypt x as the value y ≡ xe mod n

n will be publicly shared, but p and q will be secret.

d will be secret

To decrypt, we exponentiate to the power d to get yd ≡ xed ≡ x mod n

Page 9: Data encryption with big prime numbers DANIEL FREEMAN, SLU.

RSA exampleChoose p = 2498359 q = 5418341

Calculate n = pq = 2498359 * 5418341 = 13536961002419

Choose e = 234234239

Solve ed ≡ 1 mod (p-1)(q-1)

You calculate and send y=10021380275883 ≡ xe mod n

Amazon then calculates x ≡ yd mod n

p and q are just two big prime numbers

e was picked to be a prime number big enough to most likely not a factor of (p-1)(q-1)

Calculate φ(n) = (p-1)(q-1) = 2498358 * 5418340 = 13536953085720

d = 9846393595559

Suppose you want to send the number x=432564456 to Amazon.