RSA and Public Key Cryptography Chester Rebeiro IIT Madras CR CR - - PowerPoint PPT Presentation

rsa and public key cryptography
SMART_READER_LITE
LIVE PREVIEW

RSA and Public Key Cryptography Chester Rebeiro IIT Madras CR CR - - PowerPoint PPT Presentation

RSA and Public Key Cryptography Chester Rebeiro IIT Madras CR CR STINSON : chapter 5, 6 Ciphers Symmetric Algorithms EncrypAon and DecrypAon use the same key i.e. K E = K D Examples: Block Ciphers : DES, AES, PRESENT, etc.


slide-1
SLIDE 1

CR CR

RSA and Public Key Cryptography

Chester Rebeiro IIT Madras

STINSON : chapter 5, 6

slide-2
SLIDE 2

CR CR

Ciphers

  • Symmetric Algorithms

– EncrypAon and DecrypAon use the same key – i.e. KE = KD – Examples:

  • Block Ciphers : DES, AES, PRESENT, etc.
  • Stream Ciphers : A5, Grain, etc.
  • Asymmetric Algorithms

– EncrypAon and DecrypAon keys are different – KE ≠ KD – Examples:

  • RSA
  • ECC

2

slide-3
SLIDE 3

CR CR

Asymmetric Key Algorithms

Alice Bob Plaintext “APack at Dawn!!” untrusted communicaAon link

The Key K is a secret

E D KE KD “APack at Dawn!!” encrypAon decrypAon #%AR3Xf34^$ (ciphertext)

3

Encryp<on Key KE not same as decryp<on key KD KE known as Bob’s public key; KD is Bob’s private key

Advantage : No need of secure key exchange between Alice and Bob

Asymmetric key algorithms based on trapdoor one-way func<ons

slide-4
SLIDE 4

CR CR

One Way Func<ons

  • Easy to compute in one direcAon
  • Once done, it is difficult to inverse

Press to lock (can be easily done) Once locked it is difficult to unlock without a key

4

slide-5
SLIDE 5

CR CR

Trapdoor One Way Func<on

  • One way funcAon with a trapdoor
  • Trapdoor is a special funcAon that if possessed can be used to

easily invert the one way

Locked (difficult to unlock) Easily Unlocked trapdoor

5

slide-6
SLIDE 6

CR CR

Public Key Cryptography (An Anology)

  • Alice puts message into box and locks it
  • Only Bob, who has the key to the lock can open it and read

the message

6

slide-7
SLIDE 7

CR CR

Mathema<cal Trapdoor One way func<ons

  • Examples

– Integer FactorizaAon (in NP, maybe NP-complete)

  • Given P, Q are two primes
  • and N = P * Q

– It is easy to compute N – However given N it is difficult to factorize into P and Q

  • Used in cryptosystems like RSA

– Discrete Log Problem (in NP)

  • Consider b and g are elements in a finite group and bk = g, for some k
  • Given b and k it is easy to compute g
  • Given b and g it is difficult to determine k
  • Used in cryptosystems like Diffie-Hellman
  • A variant used in ECC based crypto-systems

7

slide-8
SLIDE 8

CR CR

Applica<ons of Public key Cryptography

  • Encryp<on
  • Digital Signature :

“Is this message really from Alice?”

  • Alice signs by ‘encrypAng’ with private key
  • Anyone can verify signature by ‘decrypAng’ with Alice’s public key
  • Why it works?

– Only Alice, who owns the private key could have signed

8

slide-9
SLIDE 9

CR CR

Applica<ons of Public key Cryptography

  • Key Establishment :

“Alice and Bob want to use a block cipher for encrypAon. How do they agree upon the secret key”

9

Alice and Bob agree upon a prime p and a generator g. This is public information choose a secret a compute A = ga mod p choose a secret b compute B = gb mod p B A Compute K = Ba mod p Compute K = Ab mod p Ab mod p = (ga)b mod p = (gb)a mod p = Ba mod p

Diffie-Hellman Key Exchange

slide-10
SLIDE 10

CR CR

RSA

Shamir, Rivest, Adleman (1977)

10

slide-11
SLIDE 11

CR CR

More Number Theory

MathemaAcal Background

11

slide-12
SLIDE 12

CR CR

RSA : Key Genera<on

12

Bob first creates a pair of keys (one public the other private)

) , , ( ' ) , ( ' )) ( mod( Compute . 4 1 )) ( , gcd( and )) ( 1 ( random a Choose . 3 ) 1 )( 1 ( ) ( and Compute . 2 ) ( , primes large two Generate . 1

1

a q p is key private s Bob b n is key public s Bob n b a n b n b b q p n q p n q p q p φ φ φ φ

= = < < − − = × = ≠

Given the private key it is easy to compute the public key Given the public key it is difficult to derive the private key

slide-13
SLIDE 13

CR CR

RSA Encryp<on & Decryp<on

13

Encryption

n b K

Z x where n x y x e ∈ = = mod ) (

Decryption

n y x d

a K

mod ) ( =

slide-14
SLIDE 14

CR CR

RSA Example

14

12345 572681 mod 536754 x : decryption 536754 572681 mod 12345 : 12345 571152 mod 13 395413 key Private . 4 1 ) 571152 , 13 gcd( that note ; 13 b key public Choose 3. 571152 876 652 (n) 572681; 877 653 . 2 877 and 653 p primes two Take 1.

395413 13 1

= ≡ = = = = = = = × = = × = = = y encryption x Message a n q φ

slide-15
SLIDE 15

CR CR

Correctness

15

Encryption

n b K

Z x where n x y x e ∈ = = mod ) (

Decryption

n y x d

a K

mod ) ( =

x n x x n x n x n x y

n t n t ab a b a

≡ ≡ ≡ ≡ ≡

+

mod ) ( mod ) ( mod ) ( mod ) (

) ( 1 ) ( φ φ

1 ) , gcd( = ∈ n x and Z x when

n

1 ) ( ) ( 1 ) ( mod 1 + = = − ≡ n t ab n t ab n ab ϕ ϕ ϕ

From Fermat’s theorem

slide-16
SLIDE 16

CR CR

Correctness

16

1 ) , gcd( ≠ ∈ n x and Z x when

n

q n x

  • r

p n x pq n Since = = = ) , gcd( ) , gcd( ,

) ( mod mod mod CRT by n x x q x x p x x If

ab ab ab

≡ = ≡ ≡ ▹

mod : mod mod : | ) , gcd( ≡ ≡ ≡ = = = = p x RHS p pk p x LHS x pk x p p x n Assume

ab

▹ ▹ x q x q x x q x q x q x x q implies it p x p

p t p t q q p t n t ab

≡ ⋅ ≡ ⋅ ≡ ≡ ≡ = =

+ +

mod ) 1 ( mod ) ( mod mod mod 1 ) , gcd( ) , gcd(

) ( ) ( ) ( 1 ) ( ) ( 1 ) ( ϕ ϕ φ φ φ φ

slide-17
SLIDE 17

CR CR

RSA Implementa<on

17

n x y

c mod

=

c = 23 = (10111)2

i ei z 4 1 12* x = x 3 x2 2 1 x4 * x = x5 1 1 X10 * x = x11 1 x22 * x = x23

slide-18
SLIDE 18

CR CR

RSA Implementa<on in SoSware (Mul<-precision Arithme<c)

  • RSA requires arithmeAc in 1024 or 2048 bit numbers
  • Modern processors have ALUs that are 8, 16, 32, 64 bit

– Typically can perform arithmeAc on 8/16/32/64 bit numbers

  • soluAon: mulA-precision arithmeAc

(gmp library)

18

base : 2b, where b = 64/32/16/8 bits 1024 bits

slide-19
SLIDE 19

CR CR

Mul<-precision Addi<on

  • ADD : a = 9876543210

b = 1357902468 base = 8 bit (256)

19

= (2, 76, 176, 22, 234)256 = (80, 239, 242, 132)256 i ai bi cin ai+bi+cin(mod 256) Carry? cout 234 132 110 (110 < 234)? 1 1 22 242 1 9 (9 < 22)? 1 2 176 239 1 160 (160 ≤ 176)? 1 3 76 80 1 157 (157 ≤ 76)? 4 2 2 (2 ≤ 2)?

a + b = (2, 157, 160, 9, 110)256 = 11234445678

“ComputaAonal Number Theory”, Abhijit Das, CRC Press

slide-20
SLIDE 20

CR CR

Mul<-Precision Addi<on Algorithm

20

slide-21
SLIDE 21

CR CR

Mul<-precision Subtrac<on

21

  • SUB : a = 9876543210

b = 1357902468 base = 256 (8 bit)

= (2, 76, 176, 22, 234)256 = (80, 239, 242, 132)256 i ai bi

Cin Borrow?

Cout ai-bi-cin(mod 256) 234 132 (234 < 132)? 102 1 22 242 (22 < 242)? 1

  • 220 = 36

2 176 239 1 (176 < 239)? 1

  • 64=192

3 76 80 1 (76 < 80)? 1

  • 5=251

4 2 1 (2 < 0)? 1

a - b = (1, 251, 192, 36, 102)256 = 8658640742

slide-22
SLIDE 22

CR CR

Mul<-Precision Subtrac<on Algorithm

22

slide-23
SLIDE 23

CR CR

Mul<-Precision Mul<plica<on

C = A x B mod N (without Modular operaAon)

  • Classical (School book) algorithm
  • Karatusba algorithm
  • Toom-3 algorithm
  • FFT

23

slide-24
SLIDE 24

CR CR

Mul<-precision Mul<plica<on (Classical Mul<plica<on)

24

  • MUL : a = 1234567

b = 76543210 base = 8 bit (256)

= (18, 214, 135)256 = (4, 143, 244, 234)256

a * b = (0 85 241 247 25 195 102)256 = 99447721140070

slide-25
SLIDE 25

CR CR

Mul<-precision Mul<plica<on (Karatsuba Mul<plica<on)

25

( )

l l h l l h h h l h l h l l m l h l h l l h h m h h l l m h l l h m h h l m h l m h

b a b a b a b a b b a a b a B b b a a b a b a B b a b a B b a b a B b a b a b B b b a B a a n m Let n b a + − − = − − + − − + + + = + + + = × + = + = = − ) )( ( using ) )( ( ) ( ) ( ) ( 2 / . words ary B with integers sion multipreci two be , Let

2 2

Karatsuba multiplication converts n bit multiplications into 3 multiplications of n/2 bits The penalty is an increased number of additions

slide-26
SLIDE 26

CR CR

Mul<-precision Mul<plica<on (Karatsuba Mul<plica<on)

26 B = 256; a = 123456789 = (7, 91, 205, 21)256 b = 987654321 = (58, 222, 104, 177)256

n=4; m=2 ah = (7, 91); al = (205, 21) a = (7, 91)2562 + (205, 21) bh = (58, 222); bl = (104, 177) b = (58, 222)2562 + (104, 177)

ahbh = (1, 176, 254, 234)256 albl = (83, 222, 83, 133)256 ah - bh = -(197, 186)256 al - bl = -(45, 211)256 (ah - bh) (al - bl) = (35, 100, 170, 78)256 ahbl + albh = ahbh+ albl - (ah - bh) (al - bl) = (50, 42, 168, 33)256 1 176 254 234 50 42 168 33 83 222 83 133 1 177 49 20 251 255 83 133

slide-27
SLIDE 27

CR CR

Performing Modular Reduc<on

  • Divide and get remainder

(repeated subtracAon) AlternaAvely, we could use Montgomery mulAplicaAon that will not require modular reducAon.

27

slide-28
SLIDE 28

CR CR

Montgomery Mul<plica<on

28

c = a x b mod m No specific benefits this way

Select R = 2x, gcd(R, m) =1, R slightlygreater than m Use ExtendedEuclideanAlgorithm to find R−1 and m' s.t R⋅ R−1 − m⋅ m' =1 Convert multiplicands to Montgomery domain a = aRmodm b = bRmodm Note that c = a⋅ b⋅ R−2 modm The Montgomery multiplier computes c = a⋅ b⋅ R−1 modm

slide-29
SLIDE 29

CR CR

Montgomery’s Trick

29

Montgomery's trick 1) t = a⋅ b 2) u= (t +((t mod R)⋅ m'mod R)⋅ m) / R 3) if (u ≥ m) return u − m; else return u.

slide-30
SLIDE 30

CR CR

Montgomery’s Trick (why it works)

30

Montgomery's trick 1) t = a⋅ b 2) u= (t +((t mod R)⋅ m'mod R)⋅ m) / R 3) if (u ≥ m) return u − m; else return u.

  • First note that R | t
  • Then R | (t ⋅ m'⋅ mmod R)

....this follows because RR−1 − m'm =1; then takemod R

  • Therefore R | (t + t ⋅ m'⋅ mmod R)

....the division in step 2 is valid

  • u⋅ R = t + t ⋅ m'⋅ mmod R

= t + t ⋅ m'⋅ m = t + k ⋅ m = t modm

slide-31
SLIDE 31

CR CR

Montgomery Mul<plier in the Montgomery Ladder

31

Input: c, y Output: yc mod N exp(c,y){ R0 = 1 * R mod N R1 = y * R mod N for i=n-1 to 0 do if ci = 0 then R1 = R0 * R1 R0 = R0 * R0 else R0 = R0 * R1 R1 = R1 * R1 return (R0 * R-1) } Convert to Montgomery domain. Multiplications in Montgomery domain.

  • Note. Each result is also in Montgomery

domain. Return to Original domain

slide-32
SLIDE 32

CR CR

Speeding RSA decryp<on with CRT

  • DecrypAon is done as follows :

x = ya mod n

  • Bob can also decrypt by using CRT

x = ya mod p x = ya mod q (since he knows the factors of n, i.e. p,q)

  • CRT turns out to be much faster since the size (in

bits) of p and q is about ½ that of n

32

slide-33
SLIDE 33

CR CR

Mul<-precision libraries

  • GMP : GNU MulA-precision library
  • Make use of Intel’s SSE/AVX instrucAons

– These are SIMD instrucAons that have large registers (128, 256, 512 bit)

  • Crypto libraries

– OpenSSL, PolarSSL, NaCL, etc.

33

slide-34
SLIDE 34

CR CR

RSA Speeds

34

slide-35
SLIDE 35

CR CR

RSA Speeds

35

32 Bit ARM Cortex 16 Bit TI Micro-controller

slide-36
SLIDE 36

CR CR

Finding Primes

36

slide-37
SLIDE 37

CR CR

Test for Primes

  • How to generate large primes?

– Select a random large number – Test whether or not the number is prime

  • What is the probability that the chosen number is a

prime?

– Let π(N) be the number of primes < N – From number theory, π(N) ≈ N/ln N – Therefore probability of a random number (< N) being a prime is 1/ln N

  • As N increases, it becomes increasingly difficult to find large

primes

37

slide-38
SLIDE 38

CR CR

GIMPS

  • There are infinite prime numbers (proved by Euclid)
  • Finding them becomes increasingly difficult as N

increases

  • GIMPS : Great Internet Mersenne Prime Search

– Mersenne Prime has the form 2n – 1 – Largest known prime (found in Dec 2017) has 23 million digits 277,232,917 − 1

  • $3000 to beat this J

38

hPps://en.wikipedia.org/wiki/Largest_known_prime_number

slide-39
SLIDE 39

CR CR

Primality Tests with Trial Division

  • School book methods (trial division)

– Find if N divides any number from 2 to N-1 – find if N divides any number from 2 to N1/2 – Find if N divides any prime number from 2 to N1/2 – Too slow!!!

  • Need to divide by N-1 numbers
  • Need to divide by N1/2 numbers
  • Need to divide by (N/lnN)1/2 primes

– For example, if n is approx 21024, then need to check around 2507 numbers

  • Need something bePer for large primes

– Randomized algorithms

39

slide-40
SLIDE 40

CR CR

Randomized Algorithms for Primality Tes<ng

  • Monte-carlo Randomized Algorithms

– Always runs in polynomial Ame – May produce incorrect results with bounded probability – Yes-based Monte-carlo method

  • Answer YES is always correct, but answer NO may be wrong

– No-based Monte-carlo method

  • Answer NO is always correct, but answer YES may be wrong

40

slide-41
SLIDE 41

CR CR Finding Large Primes (using Fermat’s Theorem)

41

is_composite(n){ pick a ← Zn if (an−1 ≡1modn) returnFALSE else returnTRUE }

If n is prime, then is true for any ‘a’. Therefore the algorithm would always return FALSE. If n is composite is false but may be true for some choices of a. In this case, the algorithm may return TRUE sometime and FALSE other times. For example: n = 221 (13*17) and a = 38 then 38220 mod 221 ≡ 1. (FALSE returned) We need to increase our confidence with more values of a

n an mod 1

1 ≡ −

n an mod 1

1 ≡ −

slide-42
SLIDE 42

CR CR

Fermat’s Primality Test

  • Increasing confidence with mulAple bases

42

primality_test(n){ c = 0 for(i = 0;i <1000;++i){ if (is_composite(n)==TRUE) returnCOMPOSITE } return probablyPRIME }

slide-43
SLIDE 43

CR CR

Carmichael Number

43

Some composites act as primes. Irrespective of the ‘a’ chosen, the test passes. for example Carmichael numbers are composite numbers which satisfy Fermat’s little theorem irrespective of the value of a.

  • Eg. 561 = 3 x 11 x 17

n an mod 1

1 ≡ −

slide-44
SLIDE 44

CR CR

Strong probable-primality test

  • If n is prime, the square root of an-1 is either +1
  • r -1

44

b2 ≡1modn b2 −1≡ modn (b+1)(b−1) ≡ 0modn either(b+1) ≡ 0modn or(b−1) ≡ 0modn

let a

n−1 2 = b

slide-45
SLIDE 45

CR CR

Miller-Rabin Primality Test

  • Yes-base primality test for composites
  • Does not suffer due to Carmichael numbers
  • Write n-1 = 2sd

– where d is odd and s is non-negaAve – n is a composite if

45

ad ≠1modn and (ad)2r ≠ −1modn forallnumbersrlessthans

slide-46
SLIDE 46

CR CR

Proof of Miller-Rabin test

  • Write n-1 = 2sd
  • Proof: We prove the contra-posiAve. We will assume n to be
  • prime. Thus,

46

s than less r number all for n a and n a

r

d d

mod 1 ) ( mod 1

2

− ≠ ≠ s than less r number some for n a

  • r

n a

r

d d

mod 1 ) ( mod 1

2

− ≡ ≡

slide-47
SLIDE 47

CR CR

Proof of Miller-Rabin test

Proof: We prove the contra-posiAve. We will assume n to be

  • prime. Thus we prove,
  • Consider the sequence :

– The roots of x2 = 1 mod n is either +1 or -1 – In the sequence, if ad is 1, then all elements in the sequence will be 1 – If ad is not 1, then there should be some element in the sequence which is -1, in order to have the final element as 1

47

s than less r number some for n a

  • r

n a

r

d d

mod 1 ) ( mod 1

2

− ≡ ≡

ad,a21d,a22 d,a23d,!!,a2s−1d,a2s d

1 (Fermat ‘s and we assume n is prime)

slide-48
SLIDE 48

CR CR

Miller-Rabin Algorithm (test for composites)

48

' composite is ' Otherwise . 5 ' prime is ' , 1 mod b c calculate , 1 , , 1 For . 4 ' prime is ' , 1 mod Compute . 3 nonzero a random at Select . 2 2 1 that such integer

  • dd

an Find . 1

i

2

n return T n return c If n r i T n return b If n a b T Z a T d n d T

d n s

− = ≡ − = ± = = ∈ = −

  • Input n
slide-49
SLIDE 49

CR CR

Quadra<c Residues

  • Example : m=13, square elements in Z13.

1,4,9, 3, 12, 10, 10, 12, 3, 9, 4, 1 The quadraAc residues Z13 are therefore {1, 4, 3, 9, 10, 12}

49

If an element is not a quadratic residue, then it is a quadratic non-residue quadratic non-residues in Z13 are {2, 5, 6, 7, 8, 11} a cannot be 0

slide-50
SLIDE 50

CR CR

Legendre Symbol

50

⎪ ⎩ ⎪ ⎨ ⎧ − = ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ p QNR a is a if p QR a is a if a p if p a mod 1 mod 1 |

Given p is an odd prime

slide-51
SLIDE 51

CR CR

Euler’s Criteria

51

1 mod mod mod . . , when

1 2 ) 1 ( 2 2 1 2

≡ ≡ ≡ = ≡ ∈ ∃

− − −

p x p x a p x a t s Z x QR a is a

p p p p

p a p a

p

mod

2 1 −

≡ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛

A result from Euler

p a a p

p

mod | when

2 1

slide-52
SLIDE 52

CR CR

when Quadra<c Non Residue

52

p a Thus p a p a Thus p a so p a squaring prime

  • dd

an is p if even is p note p a consider p x a t s exists Z x such no QNR a is a

p p p p p p p

mod 1 QR a not is a since , mod 1 mod 1 , mod 1 , 1 mod : ) , 1 ( mod : mod . . , when

2 1 2 1 2 1 2 2 1 1 2 1 2

− ≡ ≠ ± ≡ ≡ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ ≡ − ≡ ∈

− − − − − −

slide-53
SLIDE 53

CR CR

Examples

53

p a p a

p

mod

2 1 −

≡ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛

1 13 mod 12 13 mod 5 13 mod 5 1 13 mod 4 13 mod 4 13 mod 4

6 6 2 1 13

− ≡ ≡ ≡ ≡

QNR a is QR a is 2 15 mod 7 15 mod 7

7 2 1 15

− ≡ ≡

1 15 mod 14 15 mod 14

7 2 1 15

− ≡ ≡

Euler’s Witness Euler’s Liar Congruence always holds when n is an odd prime Congruence may

  • r may not hold

when n is not prime

slide-54
SLIDE 54

CR CR

Solovay Strassen Primality Test

54

} ) mod ( mod ) ( compute 1 1 that such integer random a choose ){ (

2 1

COMPOSITE return else PRIME possibly return n y x if n a y compute COMPOSITE return x if n a x n- a a n ASSEN SOLOVAYSTR

n

≡ = = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ = ≤ ≤

error probability is at most ½ How to compute Legendre’s symbol

slide-55
SLIDE 55

CR CR

Jacobi Symbol

  • Jacobi Symbol is a generalizaAon of the Legendre symbol
  • Let n be any posiAve odd integer and a>=0 any integer. The

Jacobi symbol is defined as:

55

... p p p p n ion factorizat prime with integer positive

  • dd

an is Suppose

4 3 2 1

e 4 e 3 e 2 e 1

× × × = n

  • ×

⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ × ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ × ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ × ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛

4 3 2 1

4 3 2 1 e e e e

p a p a p a p a n a

Then,

T

slide-56
SLIDE 56

CR CR

Jacobi Proper<es

56

⎪ ⎪ ⎩ ⎪ ⎪ ⎨ ⎧ ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ ≡ ≡ ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ − = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ ⎩ ⎨ ⎧ ± ≡ − ± ≡ = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ ≡

  • therwise

a n a n if a n n a

  • dd

is a if n t n n a t a even is a if n b n a n ab n if n if n n b n a then n b a If

k k

4 mod 3 , . 5 P 2 , 2 , . 4 P . 3 P 8 mod 3 1 8 mod 1 1 2 . 2 P mod . 1 P

slide-57
SLIDE 57

CR CR

Compu<ng Jacobi

57

From the theorem P5, P1, then P2 P5, P1, P5, P1, P3, P2 P5, P1 and 1 is a QR mod 13

slide-58
SLIDE 58

CR CR

Factoring Algorithms

58

slide-59
SLIDE 59

CR CR

Factoriza<on to get the private key

  • Public informaAon (n, b)
  • If Mallory can factorize n into p and q then,
  • She can compute φ(n) = (p-1)(q-1)
  • She can then computethe private key by finding a ≡ b-1 mod φ(n)

59

How to factorize n?

slide-60
SLIDE 60

CR CR

Trial Division

Fundamental theorem of arithmeAc Any integer number (greater than 1) is either prime or a product of prime powers

60 k

e k e e e

p p p p n

  • 3

2 1

3 2 1

=

prime generation algorithm

Prime factors of n cannot be greater than

⎣ ⎦

n

n = n / p : remove this factor from n

Running Time of algorithm order of π(n1/2)

slide-61
SLIDE 61

CR CR

Pollard p-1 Factoriza<on

61

q p n × =

choose arandom integer a(1< a < n). If gcd(a,n) ≠1,then a is a prime factor. However, this is most likely not the case.

1

Supposeweselectsome Land compute d=gcd(aL-1,n) if 1< d < n then we have factored n d | n and d |(aL −1) d has to be the prime p or the prime q

2

If gcd(aL −1,n) = n This is possible only when p | n and p | aL −1 (or q | n and q | aL −1) and aL −1> n

3

How to choose L? No easy way, trial and error!! Factorials have a lot of

  • divisors. So that is a nice

way. So, take L as a factorial of some number r.

why aL-1? since d is prime and d |(aL −1) aL ≡1modd ϕ(d)| L => (d −1)k=L Thus we need to find L which is some factor of (d −1).

slide-62
SLIDE 62

CR CR

Pollard p-1 Factoriza<on

62

done! are we ;

  • f

factor prime the is 3 repeat and increment , 1

  • f

next value with 1 from again start , 1 gcd compute 3 done. are we n,

  • f

factor prime a is gcd then this , 1 gcd if 2 2 1 n else d S r d if else a S n d if , n)

  • (a

d . S (a, n) > . S a . S

r!

= = ← ←

Pollard p-1 factorization for n. r = 2,3, 4, …..

  • 1. Will the algorithm terminate?
  • 2. When will we choose the next value of a? (will we get an infinite loop?)

When r = d-1 then L = r! = (d-1)! = d-1(d-2)! = (d-1)k (d-1) | L à we will get the gcd(ak(d-1), n) = n or its prime factor.

slide-63
SLIDE 63

CR CR

Pollard Rho Algorithm

  • Form a sequence S1 by selecAng randomly (all different) from

the set Zn

  • Also assume we magically find a

new sequence S2 comprising of

  • If we keep adding elements to

S1, we will eventually find an xi and xj (i≠j) such that When this happens,

63

  • ,

, , , , 1

4 3 2 1

x x x x x S =

  • ,

, , , , 2

4 3 2 1

x x x x x S =

p x x p x x p x x p x x p x x mod mod mod mod mod

4 4 3 3 2 2 1 1

≡ ≡ ≡ ≡ ≡

where

j i

x x =

! ! . ) ), gcd(( , | ) ( | n

  • f

factor a found We p is n x x also n p x x p

j i j i

− − ∵

slide-64
SLIDE 64

CR CR

Doing without magic

  • Form a sequence S1 by selecAng randomly (with

replacement) from the set Zn

  • For every pair i,j in the sequence compute
  • If d > 1 then it is a factor of n

64

  • ,

, , , , 1

4 3 2 1

x x x x x S =

) , gcd(( n x x d

j i −

slide-65
SLIDE 65

CR CR

Selec<ng elements of S1

To choose the next element of S1, Pollard suggests using a funcAon with requirement that the output looks random.

65

n n

Z Z f → :

Example :

n x x f mod 1 ) (

2 +

=

⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ ⎩ ⎨ ⎧ = > =

− )

( 1

1 i i i n

x f x and i x Z from randomly chosen is x where x S

slide-66
SLIDE 66

CR CR

Example

  • N= 82123, x0 = 631, f(x) = x2 + 1

66

41 ) 82123 , 63222 gcd( ) , gcd(

10 3

= = − N x x

A factor of N

Drawback… Large number of GCD

  • Computations. 55 gcd

computations in this case Can we reduce the number

  • f gcd computations?

This column is just for understanding. In reality we will not know this Given xi mod N, we compute gcds of every pair until we find a gcd greater than 1

slide-67
SLIDE 67

CR CR

The Rho in Pollard-Rho

  • N= 82123, x0 = 631, f(x) = x2 + 1

67

p x x

l t t

mod

+

=

  • The smallest value of t and l, for which the above congruence holds is t=3, l=7
  • For l=7, all values of t > 3 satisfy the congruence
  • This leads to a cycle as shown in the figure

(and a shape like the Greek letter rho)

16 11 40 2 5 26 21 32 1

3 mod ≥ =

+

t p x x

l j j

slide-68
SLIDE 68

CR CR

Reducing gcd computa<ons

  • GCD computaAons can be expensive.
  • Use Floyd’s cycle detecAon algorithm to reduce the number
  • f GCD computaAons.

68

)) ( ( ) (

1 2 1 − −

= = = ∈ =

i i i i i n

y f f x y x f x Z y x random a choose

16 11 40 2 5 26 21 32 1

claim : The first time xi = yi mod p occurs when i ≤ t + l

d return N y x d If

i i

, ) , gcd( > − =

loop This means that we get a collision before x completing an entire circle

slide-69
SLIDE 69

CR CR

The first <me xi = yi mod p occurs is when i ≤ t + l l

  • l is the number of points in the cycle
  • t is the smallest value of i such that

69

xi ≡ yi mod p xi ≡ yi mod N xi ≡ x2i mod N l |(2i −i) l |i =▹ l(k +1) = i

xi and yi meet at the same point in the cycle Therefore, yi must have traversed (some) cycles more

consider i =(k +1)l = t +(−t modl) ≤t +l

(−t modl)

slide-70
SLIDE 70

CR CR

Expected number of opera<ons before a collision

  • Can be obtained from Birthday paradox

to be

70

p

slide-71
SLIDE 71

CR CR

Congruences of Squares

  • Given N=p x q, we need to find p and q
  • Suppose we find an x and y such that
  • Then,
  • This implies,

71

N y x mod

2 2 ≡

) )( ( | ) ( |

2 2

y x y x N y x N + − = − ▹

gcd(N,(x − y)) and gcd(N,(x + y)) factors N

slide-72
SLIDE 72

CR CR

Example

  • Consider N = 91

72

) 13 7 ( | 91 ) 3 10 )( 3 10 ( | 91 91 mod 3 10

2 2

× + − ≡ 7 ) 42 , 91 gcd( 13 ) 26 , 91 gcd( 26 42 | 91 ) 8 34 )( 8 34 ( | 91 91 mod 8 34

2 2

= = × − + ≡

7 ) 7 , 91 gcd( 13 ) 13 , 91 gcd( = =

So… we can use x and y to factorize N.

N y x mod

2 2 ≡

But how do we find such pairs?

slide-73
SLIDE 73

CR CR

Another Example

  • N = 1649

73

1649 mod 80 1649 mod ) 200 32 ( ) 43 41 (

2 2

≡ × ≡ ×

32 and 200 are not perfect squares. However (32x200 = 6400) = 802 is a perfect square

1649 mod 200 43 1649 mod 32 41

2 2

≡ ≡

Thus, it is possible to combine non-squares to form a prefect square

the examples are borrowed from Mark Stamp (http://cs.sjsu.edu/faculty/stamp/)

slide-74
SLIDE 74

CR CR

Forming Perfect Squares

74

Recall, Fundamental theorem of arithmeAc Any integer number (greater than 1) is either prime or a product of prime powers

k

e k e e e

p p p p n

  • 3

2 1

3 2 1

=

Thus, a number is a perfect square if it prime factors have even powers.

even is e e e ,... , ,

3 2 1

Thus, 32 = 2550 not a perfect square 200 = 2352 not a perfect square (32x200) = 2550 x 2352 = 2852 = (2451)2 is a prefect square

slide-75
SLIDE 75

CR CR

Dixon’s Random Squares Algorithm

  • 1. Choose a set B comprising of ‘b’ smallest primes. Add -1 to

this set.

(A number is said to be b-smooth, if its factors are in this set)

  • 2. Select an r at random

– Compute – Test if y factors completely in the set B. – If NO, then discard. ELSE save (y, r) (these are called B-smooth numbers)

  • 3. Repeat step 2, unAl we have b+1 such (y,r) pairs
  • 4. Solve the system of linear congruencies

75

N r y mod

2

=

slide-76
SLIDE 76

CR CR

Example

  • N = 1829
  • b = 6 B = {-1, 2,3,5,7,11,13}
  • Choose random values of r, square and factorize

76

All numbers are 6-smooth except 60 and 75. Leave these and consider all others

slide-77
SLIDE 77

CR CR

Check Exponents

  • 1

2 3 5 7 11 13

  • 65

1 1 1 20 2 1 63 2 1

  • 11

1 1

  • 91

1 1 1 80 4 1

77

slide-78
SLIDE 78

CR CR

Check Exponents

  • 1

2 3 5 7 11 13

  • 65

1 1 1 20 2 1 63 2 1

  • 11

1 1

  • 91

1 1 1 80 4 1

78

Find rows where exponents sum is even

  • 65, 20, 63, -91

sum 2 2 2 2 2 2

1829 mod 901 1459 1829 mod ) 13 7 5 3 2 1 ( ) 85 61 43 42 (

2 2 2 2

≡ × × × × × − ≡ × × ×

slide-79
SLIDE 79

CR CR

Final Steps

79

1829 mod 901 1459 1829 mod ) 13 7 5 3 2 1 ( ) 85 61 43 42 (

2 2 2 2

≡ × × × × × − ≡ × × × 31 59 1829 31 ) 558 , 1829 gcd( 558 | 1829 59 ) 2360 , 1829 gcd( 2360 | 1829 ) 901 1459 )( 901 1459 ( | 1829 × = = = = = − + Thus ▹ ▹

slide-80
SLIDE 80

CR CR

State of the Art Factoriza<on Techniques

  • QuadraAc Sieve

– Fastest for less than 100 digits

  • General Number field Sieve

– Fastest technique known so far for greater than 100 digits – Open source code (google GGNFS)

  • RSA factoring challenge

– Best so far is 768 bit factorizaAon – Current challenges 896 bits (reward $75,000), 1024 bit ($100,000)

80

https://en.wikipedia.org/wiki/RSA_Factoring_Challenge

slide-81
SLIDE 81

CR CR

RSA Adacks adacks that don’t require factoriza<on algorithms

81

slide-82
SLIDE 82

CR CR

Φ(n) leaks

  • If an aPacker gets Φ(n) then n can be

factored

82

) 1 ) ( ( 1 ) ( ) ( 1 ) ( ) 1 )( 1 ( ) ( /

2

= + + − − + + − = + + − = − − = = = n p n n p p n p n n q p pq q p n p n q pq n φ φ φ

Solve to get p (a factor of n)

slide-83
SLIDE 83

CR CR

square roots of 1 mod n

There are two trivial and two non-trivial soluAons for The trivial soluAons are +1 and -1

83

n y mod 1

2 ≡

⎩ ⎨ ⎧ ≡ ≡ 〈=〉 ≡ q y p y n y mod 1 mod 1 mod 1

2 2 2

By CRT, these congruences are equivalent

⎩ ⎨ ⎧ − ≡ ≡ p y p y mod 1 mod 1 ⎩ ⎨ ⎧ − ≡ ≡ q y q y mod 1 mod 1 q y p y mod 1 mod 1 − ≡ + ≡ q y p y mod 1 mod 1 + ≡ − ≡

To get the non-trivial solutions solve using CRT

slide-84
SLIDE 84

CR CR

Example

  • n=403 = 13 x 31
  • To get the non-trivial soluAons of solve using CRT

84

q y p y mod 1 mod 1 − ≡ + ≡ q y p y mod 1 mod 1 + ≡ − ≡

(31⋅31−1 mod13−13⋅13−1 mod31)mod403 (31⋅8−13⋅12)mod403≡ 92 403− 92 = 311

403 mod 1 311 92 :

2 2

≡ ≡ Note

n y mod 1

2 ≡

The non-trivial solutions are 92 and 311 What happens when we solve

q y p y mod 1 mod 1 + ≡ + ≡

slide-85
SLIDE 85

CR CR

Decryp<on exponent leaks

  • If the decrypAon exponent ‘a’ leaks, then n can be factored
  • The aPacker can then compute
  • Now, for any message x ≠ 0

85

) 1 ( ) ( ) ( mod 1 − = ≡ ab n k n ab φ φ n xab mod 1

1 ≡ −

  • APack Plan, take square root :

i.e.,

n x y

ab

mod

2 1 −

) 1 )( 1 ( | ) 1 ( | mod 1

2 2

+ − = − = ≡ y y n y n n y ▹ ▹

n

  • f

factor a is y n ) 1 , gcd( −

However we need to have a non- trivial result

1 ± ≠ y ab

slide-86
SLIDE 86

CR CR

The Adack (basic idea)

86

" " 4 step ; 2 / ) even is ( . 7 ; " d is n

  • f

factor a " , 1 . 6 ) , 1 gcd( compute . 5 mod put . 4 message any choose . 3 2 1 Represent . 2 1 compute given . 1 failure return else goto t t t if exit return d if n y d n x y x ab t ab a

t

= ≠ − ← = − = −

) 1 )( 1 ( | mod ) 1 ( , mod 1

2 1 2 1 1

− + ≡ − ≡ =

y y n n y thus n x y

ab

1 ) ( ) ( mod 1 − = ≡ ab n k n ab φ φ we assume we know the private key a This will only work if y ≠±1 mod n. If y = ±1 mod n. then goto step 7

Probability of success of the attack is at-least 1/2

slide-87
SLIDE 87

CR CR

Example

  • N=403, b=23, a=47

87

) ( 31 ) 403 , 310 gcd( 311 403 mod 2 403 mod 270 2 540 : 2 1 403 mod 2 403 mod 540 2 1080 : 1 2 1080 1

270 540

n

  • f

factor a x y t loop x y t loop x ab t

t t

= ≡ = ≡ = = ≡ = ≡ = = = = − = 1 403 mod 9 403 mod 135 2 270 : 3 1 403 mod 9 403 mod 270 2 540 : 2 1 403 mod 9 403 mod 540 2 1080 : 1 9 1080 1

135 270 540

≡ = ≡ = = ≡ = ≡ = = ≡ = ≡ = = = = − =

t t t

x y t loop x y t loop x y t loop x ab t can’t divide 135 further. failure

slide-88
SLIDE 88

CR CR

Small Encryp<on Exponent

  • In order to improve efficiency of encrypAon, a small

encrypAon exponent is preferred

  • However, this can lead to a vulnerability

88

slide-89
SLIDE 89

CR CR

Small Encryp<on Exponent

89

Alice m3mod N1 m m3mod N2 m3mod N2

  • Consider, Alice sending the same message x to 3 different people.
  • Each having a different N (say N1, N2, N3)
  • But same public key b (say 3)

Insecure channel c1 c2 c3

slide-90
SLIDE 90

CR CR

Small Encryp<on Exponent

90

Alice m3mod N1 m m3mod N2 m3mod N2

  • Consider, Alice sending the same message x to 3 different people.
  • Each having a different N (say N1, N2, N3)
  • But same public key b (say 3)
  • This allows Mallory to snoop in and get 3 ciphertexts

Insecure channel c1 c2 c3

3 3 3 2 3 2 1 3 1

mod mod mod N m c N m c N m c ≡ ≡ ≡

slide-91
SLIDE 91

CR CR

Small Encryp<on Exponent

  • Thus, Mallory can compute X
  • Since m < N1, m<N2, m<N3 => n < ( N1 x N2 x N3)
  • Thus, X1/3=m

– i.e. The message can be decrypted

91

) mod( mod mod mod

3 2 1 3 3 3 3 2 3 2 1 3 1

N N N m X N m c N m c N m c ⋅ ⋅ ≡ 〈=〉 ⎪ ⎩ ⎪ ⎨ ⎧ ≡ ≡ ≡

By CRT It is tempAng to have small private and public keys, so that encrypAon or decrypAon may be carried out efficiently. However you would do this at the cost of security!!

slide-92
SLIDE 92

CR CR

Low Decryp<on Exponent

  • The aPack applies when the private key a is

small,

  • In such a case ‘a’ can be computed efficiently

92

3

4 n

a <

slide-93
SLIDE 93

CR CR

Par<al Informa<on of Plaintexts

CompuAng Jacobi of the plaintext

93

  • dd

be must therefore , even is ) 1 )( 1 ( 1 1 1 gcd Thus, 1 )) ( gcd( and key public the is message the ; ciphertext the is mod b q p )) )(q- (b, (p- n b, φ b x y n x y

b

− − = = ≡

  • dd

is since 1 b n x n x n y n y Jacobi consider

b

⎟ ⎠ ⎞ ⎜ ⎝ ⎛ = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ ± = ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ thus, RSA encrypAon leaks the value of the Jacobi symbol ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ n x

slide-94
SLIDE 94

CR CR

Par<al Informa<on of Plaintexts first half or second half?

  • given y = xbmod n,

– is it possible to determine if (0 ≤ x < n/2) or (n/2 ≤ x < n-1)

94

  • We prove that RSA does not leak this informaAon
  • If there exists an efficient algorithm that can

determine if x is in the first or second half then, the enAre plaintext can be obtained

first half second half

slide-95
SLIDE 95

CR CR

Find x

95

x = 3mod13 HALF(1) = 0 2x ≡ 6mod13 HALF(2) = 0 4x ≡12mod13 HALF(4) =1 8x ≡11mod13 HALF(8) =1 16x ≡ 9mod13 HALF(16) =1 HALF(m) = if 0 ≤ mxmodn < n 2 1 if n 2 ≤ mxmodn < n −1 ⎧ ⎨ ⎪ ⎪ ⎩ ⎪ ⎪

Consider this function example [0-6.5) [6.5,13) [0,13) [0,3.25) [0,1.625) [1.625,3.25) 1 3

slide-96
SLIDE 96

CR CR

Par<al Informa<on of Plaintexts

(first or second half proof)

  • Assume a hypotheAcal oracle called HALF as follows

96

HALF(n,b, y) = if 0 ≤ x < n 2 1 if n 2 ≤ x < n −1 ⎧ ⎨ ⎪ ⎪ ⎩ ⎪ ⎪

n x y n x y n x y n x y n x y

b b b b b b b b b

mod ) 16 ( 16 mod ) 8 ( 8 mod ) 4 ( 4 mod ) 2 ( 2 mod ≡ ⋅ ≡ ⋅ ≡ ⋅ ≡ ⋅ ≡

) [

2 , ) ( n x y HALF ∈ = = ▹

) [

2 , 4 1 ) 2 ( n n x y HALF

b

∈ = = ▹

) [

4 , ) 2 ( n x y HALF

b

∈ = = ▹

) [

8 , ) 2 (

2

n x y HALF

b

∈ = = ▹

) [

4 , 8 ) 2 (

2

n n x y HALF

b

∈ = = ▹

slide-97
SLIDE 97

CR CR

Example

97

1 1 1 1 1 1 1

Thus, if we have an efficient function HALF, we can recover the plaintext message. hi n=1457, b=779, y=722

slide-98
SLIDE 98

CR CR

Man in the Middle Adack

  • The process of encrypAon with a public key

cipher

98

Bob sends his public key Alice encrypts with Bob’s public key Bob decrypts with his private key

slide-99
SLIDE 99

CR CR

Man in the Middle Adack

  • The process of encrypAon with a public key

cipher

99

Bob sends his public key Alice encrypts with Mallory’s public key Bob decrypts with his private key Man in the middle Intercepts messages Mallory sends her public key Mallory decrypts with her private key and re- encrypts with Bob’s public key

slide-100
SLIDE 100

CR CR

Searching the Message Space

100

Bob sends his public key A l i c e e n c r y p t s w i t h B

  • b

’ s p u b l i c k e y Bob decrypts with his private key

  • Suppose message space is small,

– Mallory can try all possible messages, encrypt them (since she knows Bob’s public key) and check if it matches Alice’s ciphertext

slide-101
SLIDE 101

CR CR

Bad Prime Genera<on Algorithms

  • Suppose the prime generaAon was faulty

– So that, primes generated were always from a small subset – Then, RSA can be broken

  • Pairwise GCD of over a million RSA modulii

collected from the Internet showed that

– 2 in 1000 have a common prime factor

101

Ron was Wrong, Whit is right, 2012

slide-102
SLIDE 102

CR CR Discrete Log Problem, ElGamal, and Diffie Hellman

102

STINSON : chapter 6

slide-103
SLIDE 103

CR CR

Primi<ve Elements of a Group

103

G in elements all generates 1}

  • n

i : { en element th primitive a is If .

  • rder

has it if a as termed is 1 = such that integer smallest the is

  • f
  • rder

The G, Let .

  • rder
  • f

group a be Let

i m

≤ ≤ = ∈ ⋅ α α α α α α α n element primitive m n ) (G, } 1 , 2 , 4 , 8 , 3 , 6 , 12 , 11 , 9 , 5 , 10 , 7 { 7 , 7 Let 12

  • rder
  • f

group a forms ) , ( } 12 , , 3 , 2 , 1 {

* 13 * 13 *

13

= ∈ ⋅ = Z Z Z Consider

  • <7> has order 12

and generates all elements in Z. Thus, 7 is a primitive element

slide-104
SLIDE 104

CR CR

Discrete Log Problem

104

} 1 : { set the Define

  • rder

with group the in element primitive a be ) , ( − ≤ ≤ = ∈ ⋅ n i n G Let group a be G Let

i

α α α

β β β α

α

  • f

logarithm discrete the as log Denote let ), 1 ( integer unique any For = = − ≤ ≤ a n a a

a

Given α and a, it is easy to compute β Given α and β it is computationally difficult to determine what a was

slide-105
SLIDE 105

CR CR

ElGamal Public Key Cryptosystem

105

  • Fix a prime p (and group Zp)
  • Let be a primiAve element
  • Choose a secret ‘a’ and compute

p

Z ∈ α

p

a mod

α β ≡

Private key : Public keys :

p , ,β α

a

Encryption

p x y p y where y y x e Z k ret random a choose

k k k p

mod , mod ) , ( ) ( ) (sec

2 1 2 1

β α ⋅ = = = ←

Decryption

x p x p x p y y x d

ka ka ka k a k

≡ ⋅ = ⋅ = =

− − −

mod ) ( mod ) ( mod ) ( ) (

1 1 1 1 2

α α α β

slide-106
SLIDE 106

CR CR

ElGamal Example

  • p = 2579, α = 2 (α is a primiAve element mod p)
  • Choose a random a = 765
  • Compute β ≡ 2765 mod 2579

106

Encryp<on of message x = 1299 choose a random key k = 853 y1 = 2853 mod 2579 = 435 y2 = 1299 x 949853 = 2396 Decryp<on of cipher (435, 2396)

2396 x (435765)-1 mod p

= 1299

slide-107
SLIDE 107

CR CR

Finding the Log

  • Brute force (compute intensive)

compute this would definitely work, but not pracAcal if p is large complexity O(p), space complexity O(1)

  • Memory Intensive

precompute (all values). Sort and store. For any given β look up the table of stored values. complexity O(1) but space complexity O(n)

107

p

a mod

α β ≡

Given α and β it is computationally difficult to determine what a was

...... , , ,

4 3 2

α α α α

(until you reach β)

...... , , ,

4 3 2

α α α α

slide-108
SLIDE 108

CR CR

Shank’s Algorithm

(also known as Baby-step Giant-step)

108

p

a mod

α β ≡

⎡ ⎤

p m where Rewrite = + = r mq a as a

( )

p p

r q m r mq

mod mod α α β α α β ≡ ≡

We neither know q nor r, so we need to try out several values for q and r until we find a collision

slide-109
SLIDE 109

CR CR

Shank’s Algorithm (example)

  • p= 31 and α=3. Suppose β=6.
  • What is a?

109

31 mod 26 3 19 31 mod 19 81 27 9 3

5 4 3 2

≡ ⋅ = ≡ = ≡ ≡ ≡ α α α α α

⎡ ⎤

6 31 = = m 2 31 mod ) 3 (

6 1

=

31 mod 3 2 6 ) ( 31 mod 17 2 6 ) ( 24 2 6 ) ( 12 2 6 ) ( 6 2 6 ) (

4 4 6 3 3 6 2 2 6 1 1 6 6

≡ ⋅ = ≡ ⋅ = = ⋅ = = ⋅ = = ⋅ =

− − − − −

α β α β α β α β α β

collision Thus, m=6, q=4, r=1, a= mq+r = 25 List 1 List 2

slide-110
SLIDE 110

CR CR

Shank’s Algorithm

110

Create List 1 Create List 2 Find collision

slide-111
SLIDE 111

CR CR

Complexity of Shank’s Algorithm

111

O(m) O(mlog m) O(m) O(mlog m) O(log m) O(mlogm) ~ O(m) = O(p1/2)

slide-112
SLIDE 112

CR CR

Other Discrete Log Algorithms

  • Pollard-Hellman Algorithm

used when n is a composite

  • Pollard-Rho Algorithm

about the same runAme as the Shank’s algorithm, but has much less memory requirements

112

n

a mod

α β ≡

slide-113
SLIDE 113

CR CR

Diffie Hellman Problem

113

} 1 : { set the Define

  • rder

with group the in element primitive a be ) , ( − ≤ ≤ = ∈ ⋅ n i n G Let group a be G Let

i

α α α

ab b a

find and given α α α ,

Computational DH (CDH)

n ab c and given

c b a

mod if determine , , ≡ α α α

Decision DH (DDH)

slide-114
SLIDE 114

CR CR

Recall… Diffie Hellman Key Exchange

114

Alice and Bob agree upon a prime p and a generator g. This is public information choose a secret a compute A = ga mod p choose a secret b compute B = gb mod p B A Compute K = Ba mod p Compute K = Ab mod p Ab mod p = (ga)b mod p = (gb)a mod p = Ba mod p