Saturday, January 16, 2021

It Really Is an Enigma

 

A vintage German Army Enigma Machine
For years now I've been fascinated with the enciphering machine used by the Germans during WWII called the Enigma.  I'm not sure why I'm so fascinated.  Maybe it is the elegance in its design.  Its system of patch cables, rotating cross-wired rotors, and complex configuration options lead to the ability to generate a very strong cipher, but at its heart, it is simply an electrical circuit designed to light a single light bulb.  An electronic circuit so basic that any basic electrical engineering class would cover it in their very first lab session.

Regardless of the reasons why, I have developed a significant interest, some might even call it an obsession with this quirky little device.  This post will be the first in a series of posts that one of my coworkers has encouraged me to to make describing my explorations of the Enigma.

Like many engineers, I tend to want to understand not only how a device is used, but how it works.  I've never owned a computer for example that I've not completely disassembled in an effort to fully appreciate and understand its workings.  Unfortunately Enigma machines are quite rare.  The few that remain are in museums and private collections, and they typically do not tolerate curious engineers putting their oily hands on their priceless artifacts.  So, how did I get my hands dirty with the Enigma?

Simulation

Searching around on the Internet, I found lots of sites providing detailed explanations of how the Enigma works.  Some good places to start are:

As I mentioned above, the design of the Enigma is quite elegant, and easy to operate, but that design hides some significant complexity under the hood and inside the components.  Visualizing its operation was hard for me from descriptions and photographs alone.  I needed more.

I first sought out online simulators that emulated the use of an Enigma machine.  Here are some of the best I found:

Those were very helpful in understanding how the machines were used, but were of little or no value in learning how the machines worked.  And without that basic understanding, I had trouble understanding why the Germans used it the way they did, or why it was so challenging to defeat.  I was looking in the wrong place.  What I needed was a way to visualize the inner workings.  I needed a model.

Modeling

Fortunately, the Internet could provide me with just what I needed.  The first one I found helped a lot.  It was the Paper Enigma Machine put together by a gentleman named Michael Koss.  This simple paper-based simulator did a great job of helping me visualize the inner wiring of the rotors, and how they moved based on the physical setup of the machine.  It was good, but it could only take me so far.  It didn't model a plug board, or a way to adjust the ring setting, which I was also having difficulty visualizing.

That led me to the Pringles Can Enigma Machine.  This one is actually a complete, fully functioning, three rotor enigma with ring settings and a plug board if you so desire.  If you'd like to see it in action, and a guide for constructing one of your own, see the video linked above, posted by Videos by Kevin on YouTube.  If you'd prefer to just build it yourself without help, you can download the template here.  One word of caution, the template is formatted for A4 paper.  It is important that you not allow Adobe Acrobat to scale the PDF when it is printed.  You must print it actual size for it to fit properly on your Pringles can.

My Pringles Can Enigma

I hope you can see why this model helped me so much.  It enabled me to follow the traces of the circuit, and to visualize how the movement of the rotors caused the mapping of the letters to shift.  Finally, if you pardon the pun, the connections were made and the light came on for me, so to speak.

Next Steps

This understanding opened a world to me.  Rather than sating my desire to learn more about the Enigma, learning how it worked drove me deeper into its world.  I began reading, and now understanding, more about the device's use during the war.  How the code breakers at Bletchley Park, like Alan Turning were forced to innovate with mechanical computing devices to defeat this simple little electrical circuit.  I was even inspired to create my own versions of the Enigma machine, first based solely on software, but now I'm branching out into hardware replicas as well.  Future articles will go into more detail on those.

I hope this explanation of my early journey to understanding the inner workings of the Enigma has made it less of an enigma to you.

Tuesday, January 12, 2021

Well, it's just Life

In October of 1970, a columnist writing for Scientific American named Martin Gardner published a letter he received the previous March from John Conway, a mathematician at the University of Cambridge titled "The Game of Life."  Life was created 50 years ago.  Who knew?  Seriously, you can read all of Martin Gardner's articles on "The Game of Life" in his book Wheels, Life and other Mathematical Amusements.  The articles on Life can also be found collected in this PDF.

If you studied math or computer science in college, you may have come across Conway's Game of Life.  Its rules are very simple, and thus easy for beginning computer programmers to get their heads around.  So, it often got co-opted by professors as a coding project.  I'm not sure I ever crossed paths with it myself during my education, but I found myself fascinated by it over the 2020 Christmas break after reading the article "The Lasting Lessons of John Conway's Game of Life" in my local paper, sited here where it was originally published in the New York Times.

I wanted to learn to "play" Life the way it was intended to be played before I dove right in and played it software assisted.  So, I started with a spreadsheet, and the rules in the articles above.  I formatted it into a grid of squares and started working through the various Tetrominoes, the famous square patterns used in the game of Tetris.  The T-Tetromino was the most interesting of these in the Game of Life, as you can see from my spreadsheet pictured below.

The Game of Life - Manual Edition

As you can see, the T-Tetromino results is a repeating pattern after 9 generations.  Things get much more interesting and complicated once you get beyond 4 block patterns, so I found myself in search of software.  The most commonly used open source project for the game of life is Golly.  It is a very mature, and extremely powerful implementation of the Game of Life for all modern desktop operating systems.

Golly with the R-Pentomino

Just adding a single block to the T-Tetromino creates the R-Pentomino.  It will generate life that goes well past 1000 generations, including most of the well-known stable forms, including ones that move in stable ways like the glider.

As powerful as Golly is, I found myself wanting something less robust, something that I could use to step through one generation at a time so I could see things unfolding much more slowly.  So I decided to code my own implementation.  I've been doing a lot of work in my lab in Python of late, more on that soon, so I chose Python as my language of choice.  This seemed like a great way to learn how to write cross-platform GUI applications in Python.  I've some experience with Tk/TCL, which the tkinter library supports, but I wanted to learn something new.  So, I decided on wxPython, which is an interface to the wxWidgets library.  It did the job nicely.

My Game of Life Implementation on Generation 84 of the R-Pentomino

In my version, you can either step through one generation at a time, or you can play it forward, but only at a speed of one generation per second, so you can see life unfold a a more relaxed pace.  This was a fun project.  Feel free to explore my source code if you are interested.  It can be found here.  Please be kind.  I'm pretty new to Python programming in general, and this was my first wxPython project.  Still, it was a pretty easy.  I'll likely do more wxPython work in the future as the need arises here in the lab.

If you want to learn more about the Game of Life, you can lose yourself for longer than the lifespan of the R-Pentomino at LifeWiki.  It is essentially the sum of all human knowledge about the Game of Life.  I guess the name "Bible" was already taken.


Saturday, January 2, 2021

Every NUC and Cranny

Like many fans of Apple, I've been impressed with the stories I've read and videos I've watched about the new M1 chip, and the performance of the new Macs that include them, especially the new Mac Mini.  My lust for one of these to play with was pretty strong.  Given my time off for the holidays, I fully expected to end up with one of these on my lab table, but it didn't happen.  I did end up purchasing a mini desktop computer, but not the one I expected.

While getting lost in a sea of YouTube videos about the new Mac Mini one of my favorite YouTube channels, the Drone Bot Workshop posted a new video titled Build a Developer's Linux Workstation - Complete Guide.  First of all, Drone Bot Workshop is a great channel if you are interested in electronics, micro-controller programming, micro computers like the Raspberry Pi, etc.  This video introduced me to the Intel NUC line of bare-bones computers.  They are essentially the same processor and chip sets included in laptops but packaged in a mini desktop configuration.  This seemed much more up my alley.

In the video, Bill built a nearly maxed out version of a NUC 10.  I'll not go into detail.  The video does a much better job explaining it than I ever could.  I could have built exactly what he did, but that would have set me back over $1000.00.  For my needs, I felt I could get by with less memory, less hard disk space, and even less powerful processors.  I ended up with these components.

My fully-assembled NUC - items included for scale

This modest configuration is still massively more powerful than any other computer in my household, including my work laptop and my own personal Macbook Pro!  The NUC 8 is based on the 8th generation Core i5 processor.  Mine has a single, quad-core processor running at 2.3 GHz.  I maxed out the RAM with 32GB, but went with a moderately sized HDD at only 500 GB, but it screaming fast!  It has the Mesa Intel® Iris(R) Plus Graphics 655 integrated video engine.  It is having no issue driving crystal clear 4k video on my 42" 4K Samsung panel as you can see.  And all this for just over $500.00!

NUC on my lab table, driving 4K output

Like Bill, I'm running Ubuntu Desktop Linux 20.04 LTS on my little NUC.  I've had zero issues with it so far.  I'm more than pleased with the results of my little project.  I'd encourage anyone who is considering a small desktop computer to give these little gems from Intel a hard look.

Enigma in Software

  My Software Enigma Machine Simulator In a previous post, I shared my long-held fascination with the Enigma cipher machine used by the Germ...