Daniel Van Allen

Crypt Colors

Explore public key cryptography by mixing paint to share a secret color!

Try it here: cryptcolors.com.

About

The website provides a simplified demonstration of how public-key cryptography works, aimed at novice users of middle-school age or older.

Originally I presented a version of this website with Alex Orlowski during a Google Serve volunteer opportunity. We went to Firestone Charter Academy in Denver, CO, and presented the demonstration to several groups of middle school kids.

The original website was just plain Javascript with a third-party color picker that I threw together in a few hours, but this updated version is a lightweight Next.js app with some nicer styling.

One of the main improvements in this version is the color mixing logic. Originally I had just picked values by averaging the RGB values of the pairs of colors, which works, but it tends to give greyish results which are not what you would expect from mixing paint in real life.

For example, if you mix bright blue with bright yellow, you would expect to get bright green out of it. But if you just average the RGB values, you get... gross yellow.

To solve this problem I went down a path of StackOverflow which led me to an article about an app called Paper which supports paint-color mixing by implementing the Kubelka-Munk mixing algorithm in RGB space.

After a bit of further searching I found that they had generously open-sourced a Mixbox library to perform this mixing logic in various languages.

Acknowledgements

This demonstration was inspired by the excellent blog post by Graeme Taylor at https://maths.straylight.co.uk/archives/108.

I would also like to thank Alex Orlowski for collaborating with me in planning and delivering a previous form of this exercise.