Category Archives: Cryptography


This is the second in a series of articles about Quantum Cryptography. The first article is here.

At the end of the 19th century, people thought that they had fully understood light. They had showed that it underwent diffraction and interference – classically wave-like phenomenon. Maxwell’s equations predicted electromagnetic waves that travelled at, you guessed it, the speed of light. This applet showing diffraction (the beams represent the directions of the maxima).

All was well in the the world of Physics.

However, there were a couple of problems. One was so-called ‘Black Body’ radiation, another was the photoelectric effect.

When examining ‘Black Body’ radiation, treating light as if it were a wave did not explain the spectrum of light emitted by a hot object. This was called the ‘ultra-violet catastrophe’ as the prediction was drastically incorrect at shorter wavelengths. The solution for this was to treat light as if it could only come in discrete little packets, which were called photons. This is much easier to see by thinking about the photoelectric effect. (Applet for the photoelectric effect)

How does this square with polarisation? If light comes in photons, each photon can either go through the filter or not.

For simplicity, let’s assume that a vertically polarised photon will go through a vertically polarised filter 100% of the time. This isn’t quite true as there will be some ‘ordinary’ photon loss due to passing through material, but let’s separate the effects.

The probability of the same photon passing through a horizontal filter is zero.

What about an intermediate angle?

Well, classically, a 45° filter will let through half of the power in the beam of light (or √2 of the amplitude). In terms of photons, this means that half of the photons are getting through. How is half related to 45°? Well cos 45° is 1/√2 – so…. the probability of a vertically polarised photon getting through the filter is cos2 θ where θ is the angle of the polaroid to the vertical.

There’s more than this. If a photon passes through a filter, the filter affects the polarisation, so that photon now has a 50/50 chance of getting through a vertical polaroid, and 50/50 chance of getting through a horizontal polaroid. With just a horizontal polaroid, no light would get through. This can mean that if we have two crossed polaroids blocking light, then inserting a third can let more light through. This was discussed in classical terms in the previous article in the series.

The key things here is that a photon has a probability of getting through a polaroid filter which depends upon the angle of the filter. Each filter ‘resets’ the polarisation of any photon which emerges from it, so it doesn’t matter how that photon ‘started’ as far as subsequent filters are concerned.

Chip and Pin is Broken

Chip and Pin, the protocol that protects your transactions in a shop, has been ‘fundamentally broken‘. It is subject to a ‘man in the middle’ attack. The original paper can be seen here, the attack was demonstrated on Newsnight last night (linked via sjm217) -see also their early thoughts on the issue as well as the more up to date post on the same site.

Some electronics (which can be miniaturised to fit onto the stolen card, hence making the attack more portable) is connected to the chip on the card. When a wrong pin is entered, it sends a signal to the chip making it think that a verification by signature was given, and the reader things the correct pin has been entered. With a crooked retailer, the electronics need not be miniaturised.

This allows the transaction to proceed and hence for the cardholder to be robbed.

With Chip and Pin, the bank assumes it is secure, and so will not refund losses due to cardholder negligence – so this is a big problem.

Mark Bowerman, spokesman for UK Payments Administration, acknowledged the Cambridge researchers’ paper, but rejected their conclusions.

“We are taking this paper very seriously, as maintaining excellent levels of card security is paramount,” he said. “However, we strongly refute the allegation that chip and PIN is broken.” (source)

Command Line Cryptography

For a while, I’ve been wanting to have some simple tools for encryption and decryption of simple ciphers such as monoalphabets such as Caesar, atbash, ROT13 and so on. I thought I would have to write them myself.

Fortunately I came across example 12-18 on this site and it’s problem solved.

# Will encrypt famous quotes in a simple monoalphabetic substitution.
#  The result is similar to the "Crypto Quote" puzzles
#+ seen in the Op Ed pages of the Sunday paper.

# The "key" is nothing more than a scrambled alphabet.
# Changing the "key" changes the encryption.

echo "If you have not specified a file, type your input, when done, enter ctrl-D"
echo ""

# The 'cat "$@"' construction gets input either from stdin or from files.
# If using stdin, terminate input with a Control-D.
# Otherwise, specify filename as command-line parameter.
cat "$@" | tr "a-z" "A-Z" | tr "A-Z" "$key"
#        |  to uppercase  |     encrypt       
# Will work on lowercase, uppercase, or mixed-case quotes.
# Passes non-alphabetic characters through unchanged.
# to decrypt 
# cat "$@" | tr "$key" "A-Z"
exit 0

I use OS X, so I saved this into a file called ‘ROT13′, and made it executable by going to the terminal and typing

chmod 755 ROT13

In the terminal, I can execute the file by going to the directory containing the file and typing ./ROT13 (I haven’t put my scripts directory in the path yet)

I type my input, hit return, then ctrl-D and return…. voila!

Changing ‘KEY’ will produce a different encryption. For example atbash uses this key: ZYXWVUTSRQPONMLKJIHGFEDCBA

Now, the next step is to write a script to create blocks of N characters (default, 5) – and a command line vigenere. Hmm, that’s harder!

Happy Birthday, Edgar Allen Poe

Edgar Allen Poe was born 200 years ago today. Poe is the author of ‘The Raven‘, which has been parodied in ‘The Simpsons‘.

Then this ebony bird beguiling my sad fancy into smiling,
By the grave and stern decorum of the countenance it wore,
`Though thy crest be shorn and shaven, thou,’ I said, `art sure no craven.
Ghastly grim and ancient raven wandering from the nightly shore -
Tell me what thy lordly name is on the Night’s Plutonian shore!’
Quoth the raven, `Nevermore.’

Poe also wrote ‘The Gold-Bug’ which involves some cryptography as an integral part of the plot.

(‡?34;48)4‡;161;:188;‡?; (source)

This is a monoalphabetic cipher, each character stands for one, and only one, letter of the alphabet. For instance, ‡ represents ‘o’.

Some of the works of Edgar Allen Poe can be found on Project Gutenberg.