Secret Colors - Bonus Appendix Material
⚠ This section contains spoilers, and is meant for people who have already read Secret Colors.
We could only fit so much in the appendix. Here's some additional info you may be interested in.
How can we do this with numbers instead of paints?
Let’s say the starting color corresponds to the number 3, and Emi and Mana each have a secret number between 1 and 6. Say Emi’s secret is 2, and Mana’s secret is 5. If you’ve got a number and want to mix your secret into it, you do this: take the number times 3 (the starting color); if the result is 7 or greater, subtract 7 until you get a number between 0 and 6; repeat these steps as many times as your secret number says.
When Emi wants to mix her secret (2) into the starting color (3), she does this 2 times:
- 3 × 3 = 9, subtract 7 to get 2
- 2 × 3 = 6, no need to subtract 7
so the result is 6, and Emi sends this number 6 to Mana.
When Mana wants to mix her secret (5) into the starting color (3), she does this 5 times:
- 3 × 3 = 9, subtract 7 to get 2
- 2 × 3 = 6, no need to subtract 7
- 6 × 3 = 18, subtract 7 to get 11, subtract 7 again to get 4
- 4 × 3 = 12, subtract 7 to get 5
- 5 × 3 = 15, subtract 7 to get 8, subtract 7 again to get 1
so the result is 1, and Mana sends this number 1 to Emi.
When Emi receives the number 1 from Mana, she mixes her secret (2) into that number by doing two repetitions:
- 1 × 3 = 3, no need to subtract 7
- 3 × 3 = 9, subtract 7 to get 2
so the result is 2.
When Mana receives the number 6 from Emi, she mixes her secret (5) into that number by doing five repetitions:
- 6 × 3 = 18, subtract 7 to get 11, subtract 7 again to get 4
- 4 × 3 = 12, subtract 7 to get 5
- 5 × 3 = 15, subtract 7 to get 8, subtract 7 again to get 1
- 1 × 3 = 3, no need to subtract 7
- 3 × 3 = 9, subtract 7 to get 2
so the result is 2. Emi and Mana both ended up with the same number 2 at the end! This is their secret key, which they can use to encrypt their message.
This example is not very secure, because Emi and Mana’s secrets and the results are all between 1 and 6, and so a nosy bunny could just try all six possibilities. But instead of the number 7 you can use a much bigger number (hundreds of digits long!), as long as it’s a prime number. Also use much bigger numbers for Emi and Mana’s secrets, and then you (pretty much) get the real Diffie-Hellman Key Exchange! Such big numbers would be tedious to calculate by hand, but computers and phones can do these calculations very quickly.