Onion routing: class demonstration
In June 2020, I published a post on this blog that discusses onion routing, a method in computer networking whereby computers can send anonymous messages to one another. If I were an instructor at a school or university teaching about onion routing in some computer science class, I would demonstrate it to the class in the following way.
Items needed
- Post-it notes or sheets of paper, one for every student in the class
- Envelopes, four for every student in the class
- The more students in the class, the better, but at minimum there needs to be five students.
Goal
Procedure
Preparation
- (Optional) Have every student in the class draw a name from a hat that has every student's name in it. The name they draw will be the person they write a note to. (If they draw their own name from the hat, have them draw again.) Do not have them replace the names after they draw them: the intent of this optional step is to make sure everybody receives an anonymous note from someone at the end of the day. The students should not reveal the name they drew to anyone.
- Have every student in the class write an anonymous note addressed to the person they drew from the hat (alternatively, to anyone in the class they want). Do not have them sign the note or write their own names on it in any way. Optionally, if you are worried about harassment or bullying, as the instructor you can walk around and vet each note to make sure the contents are not objectionable.
- Each student will then place this note into one of their four envelopes. On the back of the envelope, they will write the name of the intended recipient of their note. Seal the envelope.
- Each student will then take this envelope that has the note and place it into another one of their four envelopes, such that one envelope contains the other envelope that contains the note. On the back of this envelope, they will write the name of somebody else in the room. It can be anyone besides themselves or the intended recipient. Seal the envelope.
- Each student will then repeat step 4, taking this two-layered envelope and placing it into a third envelope. On the back of this last envelope (which will contain another envelope containing another envelope containing the note), they will write the name of yet another person in the class. It can be anyone in the class except themselves, the intended recipient, and the name they wrote on the envelope in step 4. Again, seal the envelope.
- Finally, each student will repeat step 4 one last time with the last envelope at their disposal, taking the multi-layered envelope that has the note and placing it into the fourth and final envelope. On the back of this last envelope, they will again write the name of another person in the class. Once again, it can be anyone except themselves and someone they've already written on the back of an envelope. For the last time, seal the envelope.
The final result is an envelope containing another envelope containing another envelope containing another envelope containing a note. We will call this the "onion" (because of its many layers of shells).
Message delivery
- Have each student deliver their envelope to the person listed on the outermost envelope (the outermost shell of the onion).
- Once this is finished, some students may have more envelopes than others (some students may have no envelopes). That's okay. Each student that got at least one envelope will open only the outermost shell of each one, revealing the envelope that was sealed within. Do not have them open the inner envelope: students must only open envelopes addressed to them.
- Repeat step 1 with this inner envelope, having each student that got an envelope beginning another round of message delivery.
- Once the second round of message delivery is finished, once again some students may have more envelopes than others. Repeat step 2.
- Repeat step 1 again, having each student with an envelope delivering the next inner envelope.
- Once this third round of message delivery is finished, once again some students may have more envelopes than others. The envelope should be the last shell—the one that contains the note inside, rather than another envelope.
- Repeat step 1 one last time, having each student with an envelope delivering this fourth and final envelope to the intended recipient of the note inside.
- If we drew names out of a hat, at this point everyone should have an envelope. They can now open the envelope to read the note inside.
Conclusion
Once everybody has received their notes, they should have no idea who wrote them the note. Furthermore, only the sender of each note should be aware of their own intended recipient. The first relay in the chain (the "entry relay" or the "guard node") only knows that an envelope was being sent from the sender to the middle relay. The middle relay only knows that an envelope was sent from the first relay to the exit relay, and the exit relay only knows that an envelope was sent from the middle relay to the intended recipient.