Enigma

Jed Rembold & Fred Agbo

November 13, 2023

Announcements

  • Problem Sets 5 grading is posted
    • I will be grading the midterm 2 this week
  • Project 4 Guidelines is posted in canvas
    • Due on Tuesday 21st Nov. before Thanksgiving
    • Obtain the template from Jed's repo and submit to same as usual
  • I will be away for a conference on Friday Novermber 17!
    • Prof Jed will take the class as normal!
  • Polling: https://www.polleverywhere.com/agbofred203

Review Question

What is the printed value of the below code?

A = [
    {'name': 'Jill',  'weight':125, 'height':62},
    {'name': 'Sam',   'height':68},
    {'name': 'Bobby', 'height':72},
]
A.append({'weight':204, 'height':70, 'name':'Jim'})
B = A[1]
B['weight'] = 167
A.append(B)
print([d['weight'] for d in A if 'weight' in d])
  1. [125,70,167]
  2. [125,167,204,167]
  1. [125,204,167]
  2. This would error

Cryptography

  • The science of encoding messages to keep their contents secret–and the symmetric problem of decoding those messages–is called cryptography.
  • First recorded cryptographic algorithm attributed to Julius Caesar. The Roman historian Suitonius writes that:

If [Caesar] had anything confidential to say, he wrote it in cipher, that is, by so changing the order of the letters of the alphabet, that not a word could be made out.

  • In a Caesar Cipher, each letter is advanced a fixed distance in the alphabet, wrapping around to the start if necessary
    • A +3 Caesar cipher would make the following mappings

Letter Substitution Ciphers

  • A letter-substitution cipher (informally called a cryptogram) is a code in which each letter in the original text is replaced with some other letter.
    • The substitution pattern remains the same throughout the message
    • Any letter can be mapped to any other unused letter, no order is necessary
  • One of the more famous cryptograms was written by Edgar Allen Poe in his short story “The Gold Bug”
    • Described in his story how the message could be decoded by mapping the most common letters in the message to the most commonly used letters in the English language

World War II

Alan Turing

  • One of the most important contributors to computer science is Alan Turing, who made critical contributions in the theory of computation, hardware design, and artificial intelligence
  • During WW2, Turing headed the mathematics division at Bletchley Park in England, which broke the German Enigma code
  • Tragically, Turing committed suicide in 1954 after being convicted on a charge of “gross indecency” as a homosexual
    • Prime Minister Gordon Brown issued a public apology in 2009
Alan Turing (1912-1954)

The Enigma Machine

Actual Enigma Machine
Enigma Diagram

Enigma Rotors

StepInButton ResetButton

The Enigma Internals

 

Operation of the Enigma Machine

  • Whenever a letter is typed, the following happens:
    1. The force of the key press advances the fast rotor one position. If the rotor wraps from Z to A, this advances the next rotor by one increment as well.
    2. An electric signal is fed into the wire corresponding to the key, which then flows through seven letter-substitution steps
      • Through the fast rotor from right to left
      • Through the medium rotor from right to left
      • Through the slow rotor from right to left
      • Through the reflector, which turns the signal around
      • Through the slow rotor from left to right
      • Through the medium rotor from left to right
      • Through the fast rotor from left to right and on to the lamp

Encoding “A”

 

Encoding “A” Again

 

Project 4 Milestones

  • Project 4 has slightly more milestones than past projects, but each is still meant to give you a testable aspect of the program that you can bite off one piece at a time
    • Milestone 1: Activate the keyboard when pressed
    • Milestone 2: Connect the keys directly to the lamps
    • Milestone 3: Design and implement rotors
    • Milestone 4: Implement one stage in the encryption
    • Milestone 5: Implement the full encryption path
    • Milestone 6: Make the rotors advance properly each key press
  • Web examples exist for helping you test each step of the process, linked here and in the guide.

Model-Controller-View

  • The Enigma project is designed using the common model, controller, view paradigm
  • Breaks an interactive program up into 3 pieces:
    • The controller: the piece that deals with user input
    • The view: the piece that handles graphical output
    • The model: the piece that controls what should be happening at any given time

Modeling

  • In the Enigma project, the view and the controller are handled for you
    • Both are actually handled in the same module
    • Both export various methods that you can use to get input or interact with them from within the model
  • You are responsible for writing the code that comprises the model
  • There is also a constants module, where all of the various constants that you may need are stored
// reveal.js plugins