← Cryptographic Protocols (The Peruvian Coin Flip)
Sub plan
Cryptographic Protocols (The Peruvian Coin Flip)
Generated from the original open resource by CS Unplugged. Built only from the resource — nothing invented. Free, no login.
```markdown
Substitute Lesson Plan: The Peruvian Coin Flip — Cryptographic Protocols
Objective
Students will learn how two people who don't trust each other (and can't meet in person) can still flip a "fair coin" over the phone using a circuit made of AND-gates and OR-gates. Students will practice tracing binary inputs through logic circuits, understand the concept of parity (odd/even number of ones), and see an early example of how cryptographic protocols and one-way functions work.
Materials
- Copies of the reproducible circuit sheet (from the resource, page 183) — one per group
- About two dozen small buttons or counters in two different colors per group (e.g., red = 0, blue = 1)
- (Optional) crayons/markers if groups want to color in the AND/OR gate rules on the sheet
Warm-up (~5 min)
- Tell the story: "The women's soccer teams of Lima and Cuzco need to decide who gets to be the home team. Normally they'd flip a coin, but the two representatives — Alicia and Benito — are far apart and can only talk by phone."
- Ask the class: "If Alicia flips a coin and just tells Benito the result over the phone, what could go wrong?" (Guide them to see that Alicia could lie about the result, and Benito would have no way to check.)
- Explain: today's activity shows a clever trick using logic circuits so that neither person can cheat.
Main Activity (~25 min)
- Divide students into small groups. Give each group a circuit sheet and two colors of counters. Have groups mark on the sheet legend which color = 0 and which = 1.
- Explain the gates (use the rules printed at the bottom of the sheet):
- An AND-gate outputs 1 only if both inputs are 1; otherwise 0.
- An OR-gate outputs 1 if either input is 1; otherwise 0.
- Have students color in the gate rules on their sheet if time allows.
- Walk through one example together as a class: Place counters on the six inputs of the circuit to represent a chosen 6-digit binary number. Work step-by-step through the gates, placing counters at each node, until you reach the six outputs. Do this slowly and carefully — accuracy matters.
- Explain the coin-flip protocol:
- Alicia secretly picks 6 binary digits (using counters, hidden from Benito).
- She runs them through the circuit and tells Benito only the output (not the input).
- Benito must guess whether Alicia's input had an odd or even number of 1s (this is the "parity").
- Alicia then reveals her input. Benito checks (by re-running it through the circuit) that it truly produces the output she gave him.
- If Benito guessed the parity correctly, Benito wins (game goes to Cuzco); if not, Alicia wins (game goes to Lima).
- Have each group split in half — one half plays Alicia, one half plays Benito. Alicia's team secretly chooses an input, computes the output using counters, and tells Benito's team only the output. Benito's team guesses odd or even parity. Alicia's team reveals the input; Benito's team verifies it produces the correct output. Determine the winner.
- Discuss as a class: Ask groups whether Benito's guess felt truly random, or whether they could tell anything about the input just from the output. Point out (per the resource) that Benito could cheat only if he could always figure out the exact input from the output, and Alicia could cheat only if she could find two inputs of different parity that produce the same output.
Wrap-up / Exit Ticket (~10 min)
Have students answer the following on paper individually:
- In your own words, why can't Alicia just flip a real coin and tell Benito the result over the phone?
- What does it mean for Benito to "guess the parity" of Alicia's input?
- How does Benito check that Alicia didn't cheat after she reveals her input?
- What would make it easy for Alicia to cheat? (Hint: what if two different inputs — one odd, one even — gave the same output?)
Collect the exit tickets at the end of class.
If Time Remains
Challenge a group to try designing their own simple circuit (using fewer inputs, like 2 or 3 bits, with just AND and OR gates) and see if they can find a case where it's easy for Alicia to cheat (multiple inputs of different parity giving the same output) or easy for Benito to cheat (only one possible input for a given output). Have them share what they found with the class.
```
Original licensed under CC BY-NC-SA 4.0. This teaching material is provided free by OER.ai.