magic-wormhole/docs/state-machines/receive.dot
Brian Warner 83e55f1f3e add w.when_key(), fix w.when_verified() to fire later
Previously, w.when_verified() was documented to fire only after a valid
encrypted message was received, but in fact it fired as soon as the shared
key was derived (before any encrypted messages are seen, so no actual
"verification" could occur yet).

This fixes that, and also adds a new w.when_key() API call which fires at the
earlier point. Having something which fires early is useful for the CLI
commands that want to print a pacifier message when the peer is responding
slowly. In particular it helps detect the case where 'wormhole send' has quit
early (after depositing the PAKE message on the server, but before the
receiver has started). In this case, the receiver will compute the shared
key, but then wait forever hoping for a VERSION that will never come. By
starting a timer when w.when_key() fires, and cancelling it when
w.when_verified() fires, we have a good place to tell the user that something
is taking longer than it should have.

This shifts responsibility for notifying Boss.got_verifier, out of Key and
into Receive, since Receive is what notices the first valid encrypted
message. It also shifts the Boss's ordering expectations: it now receives
B.happy() before B.got_verifier(), and consequently got_verifier ought to
arrive in the S2_happy state rather than S1_lonely.
2017-04-06 18:27:41 -07:00

40 lines
1.6 KiB
Plaintext

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="Receive\nMachine" style="dotted"]
S0 [label="S0:\nunknown key" color="orange"]
S0 -> P0_got_key [label="got_key" color="orange"]
P0_got_key [shape="box" label="record key" color="orange"]
P0_got_key -> S1 [color="orange"]
S1 [label="S1:\nunverified key" color="orange"]
S1 -> P_mood_scary [label="got_message\n(bad)"]
S1 -> P1_accept_msg [label="got_message\n(good)" color="orange"]
P1_accept_msg [shape="box" label="S.got_verified_key\nB.happy\nB.got_verifier\nB.got_message"
color="orange"]
P1_accept_msg -> S2 [color="orange"]
S2 [label="S2:\nverified key" color="green"]
S2 -> P2_accept_msg [label="got_message\n(good)" color="orange"]
S2 -> P_mood_scary [label="got_message(bad)"]
P2_accept_msg [label="B.got_message" shape="box" color="orange"]
P2_accept_msg -> S2 [color="orange"]
P_mood_scary [shape="box" label="B.scared" color="red"]
P_mood_scary -> S3 [color="red"]
S3 [label="S3:\nscared" color="red"]
S3 -> S3 [label="got_message"]
}