digraph { /* could shave a RTT by committing to the nameplate early, before finishing the rest of the code input. While the user is still typing/completing the code, we claim the nameplate, open the mailbox, and retrieve the peer's PAKE message. Then as soon as the user finishes entering the code, we build our own PAKE message, send PAKE, compute the key, send VERSION. Starting from the Return, this saves two round trips. OTOH it adds consequences to hitting Tab. */ start [label="Key\nMachine" style="dotted"] S0 [label="S0: know\nnothing"] S0 -> P0_build [label="got_code"] P0_build [shape="box" label="build_pake\nM.add_message(pake)"] P0_build -> S1 S1 [label="S1: know\ncode"] /* the Mailbox will deliver each message exactly once, but doesn't guarantee ordering: if Alice starts the process, then disconnects, then Bob starts (reading PAKE, sending both his PAKE and his VERSION phase), then Alice will see both PAKE and VERSION on her next connect, and might get the VERSION first. The Wormhole will queue inbound messages that it isn't ready for. The wormhole shim that lets applications do w.get(phase=) must do something similar, queueing inbound messages until it sees one for the phase it currently cares about.*/ S1 -> P_mood_scary [label="got_pake\npake bad"] P_mood_scary [shape="box" color="red" label="W.scared"] P_mood_scary -> S3 [color="red"] S3 [label="S3:\nscared" color="red"] S1 -> P1_compute [label="got_pake\npake good"] #S1 -> P_mood_lonely [label="close"] P1_compute [label="compute_key\nM.add_message(version)\nB.got_key\nB.got_verifier\nR.got_key" shape="box"] P1_compute -> S2 S2 [label="S2: know_key" color="green"] }