ENIGMA CRYPTOGRAPHIC MACHINE

Discuss scenes and videos made with Algodoo.

ENIGMA CRYPTOGRAPHIC MACHINE

Postby Xray » Sun Sep 09, 2012 2:36 am

This is by far the most difficult and challenging Algodoo project that I've made so far. I decided to take on the challenge after I read an old post in the Phunbox forum. Someone suggested making an Enigma machine as a Phun contest project, and all of the people who responded in that thread commented how difficult and almost impossible it would be. Well, after reading that I decided that I had to attempt it! I did a lot of research and learned as much as I can about the Enigma machine. One thing I learned is that there were MANY different versions of the machine that were originally developed by the Germans, and then later by other countries.

My version of the Enigma is about as basic as it can get. It has only three rotors (many versions had 4 or 5 rotors) and a non-configurable "reflector". I won't go into detail how the Enigma works because it would take up too much space, and there are plenty of websites that are dedicated to this amazing machine.

Very briefly and simply, the Engima scrambles a message by substituting other letters for the letters in the message. It's not a simple static substitution, which could easily be broken, but a substitution that changes with each keypress. This is done with rotors, which are electro-mechanical switches. Each one of the 26 contacts represents a letter of the alphabet. The substitution is done by running wires between the different letters. For example, the contact for letter A might be wired to the contact for the letter M. So, when the letter A is pressed on the keyboard, it becomes an M on the output of the rotor. But then the output of that rotor is connected to the input of another rotor which makes another letter substitution. The flow goes through three rotors, and then gets substituted and turned around by a device called the "Reflector" which is basically a fixed rotor that does not rotate. The flow then continues back through the rotors in the oposite direction, finally to the display lamps. There are 26 lamps, one for each letter.

The really cool thing about the Enigma is the fact that a message can be encoded and decoded on the same machine without making any changes at all. For example, if you enter a Q on the keyboard, and the letter E lights up on the display, you can reset the machine to its initial state and enter the letter E, and the letter Q will light up!

There is only one initial configuration that must be done before a message can be encoded or decoded. The sender and receiver must first agree on a 3-letter "key". The key is entered by rotating the three rotors so that the letters of the key show in the rotor windows. This becomes the starting positions for each message.

An important notes about this scene:
Because of the long path through which each letter flows, and also because of calculations that are done with each letter, there is considerable "lag". I was hoping to make the rotors turn faster than they do, but the lag is too great, and errors start to creep in as I try to increase the speed. Because of the lag, you must press and HOLD each keyboard key until a letter on the lamp display lights up. This may take anywhere from a couple of seconds to many seconds, depending on how fast your computer is.

Let me know if anyone has questions about this scene, and I'll do my best to answer them, but if you have questions about the real Enigma machines, please refer to the Web.

Here is a simple encoded message for you to decode. The 3-letter key is MCK. That is, move rotor 1 until M shows in the window. Move rotor 2 until C shows, then move rotor 3 until K shows. You "jog" each rotor with the number 1, 2, and 3 keys. My simple message (a single word) for you to decode is: QMJIDO
Attachments
ENIGMA CRYPTOGRAPHIC MACHINE.phz
(939.53 KiB) Downloaded 144 times
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: ENIGMA CRYPTOGRAPHIC MACHINE

Postby Ivan » Sun Sep 09, 2012 11:17 am

Great scene! :thumbup:
Your message says ENIGMA, I suppose. I didn't menage to decode it to the end. The machine works correctly, but it is so laggy on my PC that I forget what I am doing before coming to the end of the message. :)
Image
User avatar
Ivan
 
Posts: 202
Joined: Tue Oct 06, 2009 2:01 pm
Location: Croatia

Re: ENIGMA CRYPTOGRAPHIC MACHINE

Postby Xray » Sun Sep 09, 2012 5:37 pm

Ivan wrote:Great scene! :thumbup:
Your message says ENIGMA, I suppose. I didn't menage to decode it to the end. The machine works correctly, but it is so laggy on my PC that I forget what I am doing before coming to the end of the message. :)


Yep, that's the correct message. Just for your information, I found a bug in the first version that I uploaded, and so I fixed the bug and uploaded the corrected version. On Algobox both versions are shown because there is no way to delete a scene that I know of. The correct one I called "ENIGMA CRYPOGRAPHIC MACHINE v2". The one currently in this forum thread is the correct version.

I am aware of the horrible lag problem. It's not too bad on my computer which is fairly fast with a very good 3D graphics card, but on slow computers it must be terribly annoying. There's a lot that goes on in this scene (mostly Thyme scripts), and so I don't know if there's much that I can do to speed it up.

I tried to change the sim.frequency. That did speed things up a bit but it messed up the timing of the rotors, which caused errors. Everything in this scene is critically timed and adjusted, so if anything changes even by a small degree, then errors will start showing up. If someone wants to tinker with this scene to improve it, please be my guest. There are a few very smart and clever people who use Algodoo, so maybe one of those guys could improve it.


EDIT: I did figure out how to delete the older, buggy scene on algobox.
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA

Re: ENIGMA CRYPTOGRAPHIC MACHINE

Postby Conundrumer » Wed Sep 12, 2012 7:06 am

I vaguely remember someone making one using a bunch of levers, and another person using a system of...trail rails.
Nonetheless, nice work, though I'm a bit baffled by how it works (don't feel like looking into the code).
User avatar
Conundrumer
 
Posts: 344
Joined: Mon Aug 31, 2009 5:55 pm
Location: NYC

Re: ENIGMA CRYPTOGRAPHIC MACHINE

Postby Xray » Wed Sep 12, 2012 5:01 pm

Conundrumer wrote:I vaguely remember someone making one using a bunch of levers, and another person using a system of...trail rails.
Nonetheless, nice work, though I'm a bit baffled by how it works (don't feel like looking into the code).


Hi Conundrumer -- I was wondering if an Enigma machine could be made with Algodoo using only mechanical components. I'm sure it's possible but the lag time would probably be so bad that you could press a key, and then go grab some lunch because the output lamp would not be lit for a very long time. Anyhow, the signal path is long and complex but the actual theory of how the Enigma works is deceptively simple. In a real machine it's simply a battery, 26 lightbulbs, and a bunch of rotary switches. When a keyboard key is pressed, that closes a switch which sends the battery voltage through the rotors, then through the reflector, which then routes the voltage back through the rotors again, and finally to a particular lamp which indicates the encoded or decoded letter.

In my Algodoo Enigma, the path goes from a keyboard key (which turns on one of 26 lasers on rotor-3), then from rotor-3 to rotor-2, to rotor-1, to the reflector, then back to rotor-1 (through a different path), then to rotor-2, then to rotor-3, then finally to the display lamps. Each rotor has two sets of lasers. One set is for the "forward" path, and the other set is for the "return" path. When you press, for example, keyboard key "a", the forward laser in the "a" position (which is located behind the "window" frame, so you can't see it) turns on. The keypress action makes the right (rotor-1) rotor index one position and then stop. The yellow box that lines up with the "a" laser has a simple Thyme script that tells which laser in rotor-2 will turn on. The script, for example, says, "turn on the laser in rotor-2 which is at the position which is 17 places over from the current position of this laser in rotor-3. Then that laser in rotor-2 turns on, which points to another box with another script that tells which laser in rotor-1 that should turn on. Then the yellow box in rotor-1 determines which laser of the reflector gets turned on. Then the box that the laser hits in the reflector has a script in it that determines which "Reverse" laser for rotor-1 gets turned on. Then the same thing happens for rotor-2 reverse laser, and rotor-3 reverse laser. Then finally, the box in rotor-3 that gets hit by the proper reverse laser, determines which letter of the display gets lit. Down at the bottom of the scene, there a a few devices that decode the keyboard, and also create delays for certain actions that need to be timed. Rotor-3 will index with each and every keypress, but rotors 1 and 2 will only index when the grey colored box is in the window position of rotor 3 or rotor 2 (Note that all boxes in the rotors are yellow, but one of the 26 forward boxes is grey. That box has a laser under it that tells the next rotor to index). It works sort of like the odometer in your car, but there are some slight differences which you could learn about if you do some research on the Enigma machine.

Originally, I used circles with motors to decode the keyboard because I needed to know not only which keyboard key got pressed, but I needed to know when the user released the key. This is not a simple task! The motor-driven circles worked, but I wanted something that was a little more elegant, and Kilinich came to the rescue (Thank you, Kilinich!). He created a keyboard key handler using two lasers and a box. There are 26 such devices in my scene.

So, that's basically how the beast works. I since found ways to reduce the lag time, and after I have completed optimizing it, I'll update the current version.
User avatar
Xray
 
Posts: 500
Joined: Sun Jun 17, 2012 6:12 am
Location: USA


Return to Scenes

Who is online

Users browsing this forum: No registered users and 1 guest