110 likes | 292 Views
Heuristic Searches Intro to Cryptography Slides courtesy of Professor Sheridan Houghten. Week 7. 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 {
E N D
Heuristic Searches Intro to Cryptography Slides courtesy of Professor Sheridan Houghten Week 7
Generic Heuristic Search – see section 5.1, KS • c = 0; • select a feasible solution X; • Xbest = X; • while(c <= cmax) // c counts the number of iterations • { • Y = hN(X); //using chosen search strategy • if(Y != fail) • { • X = Y; • if(P(X) > P(Xbest)) • Xbest = X; • } • c++; • } • return Xbest;
Uniform Graph Partition (UGP) Example (see section 5.1.1, KS) X0 = 0257, X1 = 1346 Cost: 8 + 7 + 2 + 4 = 21
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; • }
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]); } }
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 } }
Simulated Annealing (UGP) T = T0; Select feasible solution X; Xbest = X; for(c = 0; c < cmax; c++, T *= a) { Y = hN(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(Xbest) Xbest = X; } else // not improved: may keep it { r = random(0,1); if(r < exp((P(Y) – P(X))/T) X = Y; } } } return Xbest;
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”
Substitution Cipher Example Possible permutation for encryption: Corresponding permutation for decryption: Plaintext: meetatnoon Ciphertext: THHMXMSFFS
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”
Stream Cipher ExampleLinear Feedback Register Let m = 4 and zi+4 = (zi + zi+1) mod 2