This video has a nice visual analogy for how the whole process works. It’s a little slow to get started, but well worth watching.
The video uses a paint and color based explanation, which I think works rather well.
- When you mix two colors of paint, you get a new color. However, it is pretty much impossible to start with the new color and work backwards to figure out what two colors made it.
- You start by both agreeing publicly that today’s color is yellow. This is done publicly and anyone can find out that today’s color is yellow.
- The two parties that want to share a secret mix yellow with their own private color. In the video, one party mixes yellow with red, the other mixes yellow with blue.
- The two parties exchange their newly mixed colors. One sends an orange-y color (yellow + red). The other sends a greenish color (yellow + blue).
- Each party mixes the color they received with their own private color. That means one party now has yellow + blue + red. The other has yellow + red + blue. In other words, they both end up with the same final color, in this case a greenish red.
What is great about this process is that anyone trying to listen in on the conversation does not have all of the information. They may know about yellow. They might even know about orange and green. But they cannot deduce the final color.
And that, in essence, is how public key cryptography works. You agree on something public, you mix it with something private, exchange it with a third party and mix it again. The end result is that the two parties exchanging information can unscramble it, but a third party cannot.