CPSC 352 -- Artificial Intelligence
Notes: AI Algorithms & Approaches: Word-based Ga for Short Cryptograms

Introduction

This page is related to the paper Evolving Keys for Periodic Polyalphabetic Ciphers (PDF).

A genetic algorithm is used to find the keys of Type II periodic polyalphabetic ciphers with mixed primary alphabets. Because of the difficulty of the ciphertext only cryptanalysis for Type II ciphers, a multi-phased search strategy is used, each phase of which recovers a bigger portion of the key.

Background

A polyalphabetic cipher is one in which different alphabets are used to encrypt different letters in the plaintext.

Given d cipher alphabets C1, ..., Cd then gi: A → Ci is the mapping from the plaintext alphabet A to the ith cipher alphabet, Ci.

A plaintext message

M = m1...mdmd+1...m2d

would be decrypted to:

E(M) = g1(m1)...gd(md)gd+1(m+1d)g2d(m2d)

The ciphertext alphabets can take different forms:

One common form of classical cipher is to take a mixed primary alphabet and then derive additional alphabets from it by shifting the letters from 1 to 25 times.

Ciphertext only cryptanalysis of polyalphabetic cipher with a 26-letter alphabet and a period of length d requires search of a keyspace containing 26^ × 26d-1 possible keys -- approximately 1032 possible keys.

A Parallel GA for Breaking Type II Ciphers

Hands On

  • Download and untar the crypto-ga.tar.Z file using the commands:
    $ uncompress crypto-ga.tar.Z
    $ tar xvf crypto-ga.tar
    

    This should create the following directory structure:

    $ ls -l crypto-ga
    total 876
    -rw-r--r-- 1 ram ram  33130 2011-12-09 00:12 AlbertiGaAnalyzer.java
    -rw-r--r-- 1 ram ram  33130 2011-12-08 23:50 AlbertiGaAnalyzer.java~
    -rw-r--r-- 1 ram ram 771341 2011-12-07 21:51 book.txt
    -rw-r--r-- 1 ram ram   3537 2011-12-08 17:50 NgramGaAnalyzer.java
    drwxr-xr-x 2 ram ram   4096 2011-12-09 09:22 simplesub
    -rw-r--r-- 1 ram ram   2830 2011-12-07 21:51 TestCryptAnalyzer.class
    -rw-r--r-- 1 ram ram   4729 2011-12-07 21:51 TestCryptAnalyzer.java
    -rw-r--r-- 1 ram ram   2883 2011-12-07 21:51 TestGaAnalyzer.class
    -rw-r--r-- 1 ram ram   4692 2011-12-07 21:51 TestGaAnalyzer.java
    drwxr-xr-x 3 ram ram   4096 2011-12-09 09:22 typeI
    drwxr-xr-x 3 ram ram   4096 2011-12-09 09:22 typeII
    -rw-r--r-- 1 ram ram   1227 2011-12-08 17:49 WordBasedGaAnalyzer.java
    $
    

    Running Experiments

    Each of the diretories, simplesub, typeI, and typeII contain README.txt files that explain how to run a GA experiment.