Thursday, March 14, 2013

Discrete Math - Day 34

Today we continued exploring fundamental concepts in cryptography. Specifically, today was focused on differentiating ciphering from encoding and the introduction of functions as ciphers.

With the previous lesson, students had a foundation for the idea of a cipher. The use of a shift cipher allows students to understand the basic process of ciphering and deciphering without getting bogged down in any difficult mathematics or technical process issues.

The idea of encoding is introduced as the mechanism of converting plaintext to digital content. I briefly discuss the idea that machines are built of circuits and that a circuit can either be on or off. This means that computers can fundamentally only understand values of zero or one. I introduce the idea of a bit as being a single on/off value and a byte as containing 8 bits. Since most students are familiar with the terms kilobyte, megabyte and gigabyte, it is easy to make a connection to this idea and to then relate that a kilobyte is 1,000 bytes and a megabyte is 1,000,000 bytes.

With this foundation I introduce the process of

  1. creating plaintext, 
  2. encoding the plaintext to digital plaintext, and
  3. applying a cipher to create digital ciphertext. 

To reverse the process you would

  1. decipher the digital ciphertext to digital plaintext,
  2. decode the digital plaintext to plaintext, and
  3. read the plaintext.

We make use of a simple encoding scheme: a => 01, b => 02, c => 03, ..., y =>25, z => 26.

I have students use this scheme to encode and decode a couple of messages to be sure they understand the process. Students then started to apply a cipher to their digital plaintext. At this point, a couple of students asked what happens if your value goes over 26? A couple of other students said you should just wrap the values around and start over. I told students we would discuss this in just a few minutes.

First, I wanted to focus on the functional aspect of the cipher. It gets cumbersome to write something such as digital ciphertext = digital plaintext + 5. We introduce functional notation and let C(x) represent a cipher function. We can then write C(x) = x + 5, where x is the digital plaintext value. Students practiced encoding and ciphering a brief message using a cipher function.

The process of deciphering now becomes an application of an inverse function. The deciphering function D(x) needs to be the inverse of C(x) since we need D(C(x)) = x. This is, definitionally, an inverse function.

Now the process of ciphering and deciphering can be considered from a purely functional aspect. We use a function, C(x), to cipher digital data and then apply its inverse, D(x), to decipher the ciphered digital data.

One final issue needs to be addressed. If we use the encoding scheme of a => 01,...z=>26 and we try to simply subtract 26 from each value, we have z=>00 which is not a valid value. To accommodate an easier process, we use the encoding scheme of a=>00, b=>01,..., y=>24, z => 25. Now we have a complete cycle in sequence.

I let students work through this idea and practice using the new encoding scheme along with a cipher function.

This process sets the stage for introducing the idea of modular arithmetic, which we'll need as we move toward more advanced ideas in cryptography.

Class concluded with students summarizing thoughts about today's lesson in their notes.

Visit the class summary for a student's perspective and to view the lesson slides.

No comments:

Post a Comment