11.07.2015 Views

Cryptography - Sage

Cryptography - Sage

Cryptography - Sage

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

sage: X = pt.frequency_distribution()sage: m = 11sage: r = 0.75sage: match = [ [] for i in range(m) ]sage: for i in range(m):... Z = ct[i::m].frequency_distribution()... Y = DiscreteRandomVariable(X,Z.function())... for j in range(26):... K = S([ (j+k)%26 for i in range(26) ])... corr = X.translation_correlation(Y,E(K))... if corr > r:... match[i].append(j)Exercise 3.7 (Breaking substitution ciphers) Suppose that rather than an affinetranslation, you have reduced to an arbitrary simple substitution. We need to undo anarbitrary permutation of the alphabet. For this purpose we define maps into Euclideanspace:1. A → A 2 → R 2 defined byx ↦−→ xx ↦−→ ( P (x), P (xx) ) .2. A → A 2 → R 3 defined byx ↦−→ xy ↦−→ ( P (x), P (xy | y), P (yx | y) ) ,for some fixed character y.See the documenthttp://echidna.maths.usyd.edu.au/ kohel/tch/Crypto/digraph frequencies.pdffor standard vectors for the English language.Exercise 3.8 (Breaking transposition ciphers) In order to break transposition ciphersit is necessary to find the period m, of the cipher, and then to identify positionsi and j within each block 1 + km ≤ i, j ≤ (k + 1)m which were adjacent prior to the permutationof positions. Suppose we guess that m is the correct period. Then for a ciphertextsample C = c 1 c 2 . . . , and a choice of 1 ≤ i < j ≤ m, we can form the digraph decimationsequence c i c j , c i+m c j+m , c i+2m c j+2m , . . . .3.5. Statistical Measures 29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!