# 1 Week 7 Heuristic Searches Intro to Cryptography Slides courtesy of Professor Sheridan Houghten.

## Presentation on theme: "1 Week 7 Heuristic Searches Intro to Cryptography Slides courtesy of Professor Sheridan Houghten."— Presentation transcript:

1 Week 7 Heuristic Searches Intro to Cryptography Slides courtesy of Professor Sheridan Houghten

2 Generic Heuristic Search – see section 5.1, KS c = 0; select a feasible solution X; X best = X; while(c <= c max ) // c counts the number of iterations { Y = h N (X); //using chosen search strategy if(Y != fail) { X = Y; if(P(X) > P(X best )) X best = X; } c++; } return X best ;

3 Uniform Graph Partition (UGP) Example (see section 5.1.1, KS) uv[Y0,Y1]GainCost 011257, 0346-2748 032357, 0146-2445 042457, 0136-3455 062567, 0134-3253 210157, 2346-1637 230357, 1246+318 X 0 = 0257, X 1 = 1346 Cost: 8 + 7 + 2 + 4 = 21

4 Uniform Graph Partition – UGP Algorithm to find initial solution: SelectPartition() { r = random(0, (2n choose n) – 1); X0 = KSubsetLexUnrank(r, n, 2n); //note change from book X1 = V – X0; }

5 UGP Neighbourhood Search Ascend([X0, X1]) { g = 0;// gain for each i in X0 { for each j in X1 {t = gain([X0, X1], i, j); if(t > g)// current best { x = i; y = j; g = t; } if g > 0// improved { Y0 = (X0 U {y}) – {x}; Y1 = (X1 U {x}) – {y}; fail = false; return ([Y0, Y1]); } else// no improvement { fail = true; return ([X0, X1]); }

6 Hill Climbing for UGP UGP(cmax) { [X0, X1] = SelectPartition(); for(c = 0; c < cmax; c++) { [Y0, Y1] = Ascend([X0, X1]); if(!fail) // use new partition and try again { X0 = Y0; X1 = Y1; } else return; // couldn’t improve }

7 Simulated Annealing (UGP) T = T0; Select feasible solution X; X best = X; for(c = 0; c < cmax; c++, T *= a) { Y = h N (X); // random feas. soln from neigh. search // UGP: find random values of i and j to swap if(Y != fail) { if(P(Y) >= P(X))// improved: always keep it { X = Y; if(P(X) > P(X best ) X best = X; } else // not improved: may keep it { r = random(0,1); if(r < exp((P(Y) – P(X))/T) X = Y; } return X best ;

8 Shift Cipher Example K = 11, Plaintext:“meetatmidnight” Translation: 12 4 4 19 0 19 12 8 3 13 8 6 7 19 Encryption: 23 15 15 4 11 4 23 19 14 24 19 17 18 4 Corresponding ciphertext: “XPPELEXTOYTRSE” Translation: 23 15 15 4 11 4 23 19 14 24 19 17 18 4 Decryption: 12 4 4 19 0 19 12 8 3 13 8 6 7 19 Corresponding plaintext: “meetatmidnight”

9 Substitution Cipher Example Possible permutation for encryption: Corresponding permutation for decryption: Plaintext: meetatnoon Ciphertext: THHMXMSFFS

10 Vigenere Cipher Example Keyword: BROCK → key = (1,17,14,2,10) Plaintext:“meetatmidnight” Translation: 12 4 4 19 0 19 12 8 3 13 8 6 7 19 Encryption: 13 21 18 21 10 20 3 22 5 23 9 23 21 21 Corresponding ciphertext: “NVSVKUDWFXJXVV” Translation: 13 21 18 21 10 20 3 22 5 23 9 23 21 21 Decryption: 12 4 4 19 0 19 12 8 3 13 8 6 7 19 Corresponding plaintext: “meetatmidnight”

11 Stream Cipher Example Linear Feedback Register Let m = 4 and z i+4 = (z i + z i+1 ) mod 2

Download ppt "1 Week 7 Heuristic Searches Intro to Cryptography Slides courtesy of Professor Sheridan Houghten."

Similar presentations