Home‎ > ‎

Colorful Key Exchange

Objective

Explain how Diffe-Hellman Key Exchange works using jars of water and food coloring.

Diffie-Hellman Key Exchange Demonstration

Exercise is based on http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange#Description

Equipment

List below has enough equipment for 1 x group of six (multiply quantities for more groups)

  • 3 x small jars with lids

  • 1 x large jug of water (to fill/refill small jars)

  • 3 x sets of food coloring with droppers/pippette (more colors the better)

  • 2 x plastic tubs OR 2 x dividers (used to stop Eve seeing the mixing of colors)

  • 1 x roll of black/brown paper (if tubs used, used for covering outside of tubs)

  • 1 x test tube rack with test tubes + pippette (for Eve to experiment with colors)

  • Paper and markers/pens (for writing down secrets)



Exercise


1: Set the Scene


Alice and Bob want to share a secret. It’s the location to their friend Trent’s birthday party. The problem is that someone else they know, Eve, was not invited and she is listening to everything they are telling each other.


Is it possible to pass on a secret message to someone when you *know* that someone else is always listening?


Does anyone have any ideas how we could do it?


Answer questions, debunking the answers each time. Example Q&A:

  • Talk quietly → Eve is always listening.

  • Leave it in a secret location → Alice can’t tell Bob without Eve listening.

  • Come up with a code → Eve will hear the code and know what it is.

  • Use Diffie-Hellman-Merkle key exchange → Get out of the classroom.



After all the questions, say that there is a way that they can come up with a code or a “key” so that they both know a secret that Eve doesn’t know (even if Eve is listening the whole time and never goes to sleep!). They can use this secret to then write coded messages to each other.


2: Live demonstration


Ask for three people to come up the front and demonstrate in front of everyone.


At this stage, you want Alice and Bob on either side, and Eve in the middle. Alice and Bob have the plastic tubs with the food coloring in them. The opaque paper on the tubs stops Eve from looking inside and seeing how they are being mixed (or dividers if used - whiteboards on wheels are good for this so that the audience can see.


To demonstrate how we can come up with a secret with other people listening, let’s use these jars of water.


The first thing Alice and Bob need to do is to come up with a base color. Let’s choose a nice and bright color for Alice and Bob to use (Instructor note: ask the audience - bright colors are best as it’s easier to see the different colors when they mix - if too many dark colors are used, they all just look brown/black).


(Ask Alice to tell Bob her color choice aloud and how many drops e.g. Yellow - 3 drops).


Oh no! Eve also knows the color choice and she makes the same color!


But there is still a way to do this! Now, Alice and Bob come up with a secret recipe. Alice is going to choose a secret color and number of drops and not tell anyone about it. Bob is going to do the same.


(let them choose their colors. If they choose the same color, add in the following: Bob decides to be more complicated than that - he wants to use two different colors for his secret color!) - then Bob can add in a second color.


3. Exchanging Secrets


Now Alice and Bob swap jars. Eve in the middle can see both jars and (takes a sample / writes down the color**) as they go by.


** Depending on whether test tubes are used for the more advanced/fun version


  • Alice and Bob swap Jars

  • Eve takes a sample / writes down color


Alice has Bob’s Jar and Bob has Alice’s Jar. How are Alice and Bob going to get the same color as each other?


  • Alice adds her secret color to Bob’s Jar

  • Bob adds his secret color to Alice’s Jar


After they give their jars a good shake, Alice and Bob have the same color!


Now, if Eve sees the color when Alice and Bob talk to each other, can she figure out their secret colors?


  • Let Eve try for a while!


As you can see, this is very hard for Eve! If she worked very hard, she might be able to find out the exact same color and drops that were used, but hopefully by then, the birthday party is over and it won’t matter.


We only used [X] colors today  - imagine if we used 64 colors! or 512 colors! or 2048 colors!  It would be almost impossible for Eve to figure out the color without taking a long time or going crazy!



Now they can use this shared secret to make a code or a secret language that Eve can’t understand. Looks like Eve won’t be able to come to the birthday party, which means more cake for everyone (except for Eve)!


  • Break up into groups and try it themselves. Groups can either be 3 or 6.