(*public channel*)
free c.
(*private secure channel*)
private free s.

data ACK/0.

fun host/1.
private reduc getkey(host(x)) = x.

not ka.

query ev:end(x) ==> ev:begin(x).

let pA =
    event begin(A);
    out(c, A).

let pB =
    in(c, hostX);
    out(s, hostX);
    in(s, =ACK);
    event end(hostX).

let pS =
    in(s, hostY);
    if getkey(hostY) = ka then
        out(s, ACK).

process
    new ka;
    let A = host(ka) in
    (pA | pB | pS)
