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.

analysis of the each of the decimations with respect to their periods. A javascript programfrom the course web page can be used for this purpose.Exercise 3.5 (Correlations of sequence translations) Suppose that pt and ct areplaintext and ciphertext whose frequency distributions are to be compared. Assume wehave defined:sage: S = AlphabeticStrings()sage: E = SubstitutionCryptosystem(S)The following code finds the correlations between the affine translations of two sequences.sage: X = pt.frequency_distribution()sage: Z = ct.frequency_distribution()sage: Y = DiscreteRandomVariable(X,Z.function())sage: for j in range(26):... K = S([ (j+k)%26 for k in range(26) ])... print "%s: %s" % (j, X.translation_correlation(Y,E(K)))What does frequency distribution return, and what are the ciphers e constructed in thefor loop? What does translation correlation return? Note that Ymust be created as adiscrete random variable on the probability space Xin order to compute their correlations.Solution. Given two strings S 1 = pt and S 2 = ct with this computes their frequencydistributions, X 1 and X 2 (as discrete probability spaces). At each iteration of the forloop, an affine translation cipher (a cyclic shift by k characters) is constructed. Then forsuch cipher e, the correlation of X 1 with X 2 ◦ e is constructed. By comparing a standardplaintext pt against affine translations of decimations of ciphertext ct we are able to breakthe Vigenère enciphering in the exercise below.Exercise 3.6 (Breaking Vigenère ciphers) A Vigenère cipher is reduced to an translationcipher by the process of decimation. How does the above exercise solve the problemof finding the affine translation?Apply this exercise to the Vigenére ciphertext sample cipher01.txt from the course webpage, and the break the enciphering. Recall that you will have to use the decimation (byct[i::m]) and coincidence index to first reduce a Vigenère ciphertext to the output ofa monoalphabetic cipher.108 Appendix C. Solutions to Exercises

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

Saved successfully!

Ooh no, something went wrong!