Tag 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.

# http://www.faqs.org/docs/abs/HTML/textproc.html 
# 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!

Quantum Cryptography (a background)

In this article I hope to illustrate some of the ideas behind the strange topic of Quantum Cryptography, though I won’t be discussing cryptography itself, that comes later – just the necessary physics.

First we must consider the nature of light (this can be generalised to any particle once we get all quantum mechanical, but let’s stick with light for now).

Classically, light can be thought of as a wave. It’s a transverse wave meaning that the ‘oscillations’ of the thing doing the waving are at right angles to the direction that the wave is travelling in. Another example of transverse waves are waves on the surface of water.

Picture showing waves horizontally and vertically polarised
Picture showing waves horizontally and vertically polarised

These oscillations defined a ‘plane’ in which the waves are oscillating, and this plane can be oriented at any angle. Waves on the surface of water are vertically polarised. Though the plane of polarisation can be any angle, it is convenient to pick two planes which are at 90 degrees to each other. We can express any polarisation by talking about how much of each is present. Hence, we can talk of ‘vertical’ and ‘horizontal’ polarization. Here is an applet which demonstrates this.

You can see polaroid filters in action if you have a pair of polaroid glasses (often sold as ‘anti-glare’). Find a light shining on a surface such as a desk. You don’t want to be ‘square on’ to the surface, the light should be bouncing at an angle, 45 degrees is a good start. For the most obvious effect, don’t use a mirror.

Look at the surface through your polaroid glasses, then rotate them 90 degrees, and keep looking. You should see the glare change in brightness. You will find that polaroid glasses are best at reducing glare from horizontal reflections when held normally. (See: Brewsters’ Angle)

If you use your glasses for driving, you may find that you have trouble with the LCD screens on petrol pumps, this is because the LCD screen relies on polarising light!

If you take a polarised filter, this will ensure that all the light which passes through has the same polarisation. Classically, if a particular wave comes in with an amplitude of A, and a plane of polarisation at angle θ to the plane of polarisation, the amount of light which emerges has amplitude Acosθ.

Picture showing the effect of multiple polarising filters
Picture showing the effect of multiple polarising filters

Suppose that we have two polaroid filters. Unpolarised light hits the first and emerges polarised. It emerges with amplitude, A (on average). This light hits the second filter. The two filters have an angle θ between their planes of polarisation – the amount of light which emerges is Acosθ. So, if the filters are aligned, the second filter has no effect. If it is turned 90 degrees, no light emerges (note, if it is turned 180 degrees, it has no effect – the sign of the amplitude doesn’t matter, it’s not ‘negative light’!)

(Note that for real filters, there is a little scattering, so 90 degrees doesn’t give total black, and zero degrees does give some reduction in intensity)

Imagine we have two filters, aligned at 90 degrees. No light emerges. This is because the cosine of 90 degrees is zero.

Now, insert a filter at 45 degrees between the two. What happens? More ‘stuff’ can only make the amount of light getting through smaller, right? The cunning reader will have assumed that I wouldn’t ask the question if the answer were obvious. Some light emerges. In this circumstance, two filters allows through less light than three.

This counterintuitive result is easily explained. Imagine the second filter is at an angle of θ compared to the first.  The third is at 90 degrees. In other words, the angle from the second is (90-θ). From the first filter, we have light with amplitude Acosθ. This is then reduced by the third filter by cos(90-θ). The overall light intensity is now Acosθ.cos(90-θ) or Asinθcosθ, this reduces to A(sin2θ)/2. In other words, we get most light out when sin2θ=1, or when 2θ=90°, or when θ=45° 

The newly inserted second filter is changing the polarisation of the light.

Take your time on polarisation, it’s important that you understand the above if you’re to comprehend subsequent articles. We’ll put this aside for a while, though – the next step is to talk about photons.