import prelude;
public sending : Word;
public to : Word;
public acknowledging : Word;
public receipt : Word;
public of : Word;
pattern Msg (a:Host)
= ( b:Host, text:Public ) [ !begun(a sending text to b) ];
tag msg (Msg(a)) : Auth<a:Host>;
pattern Ack (b:Host)
= ( a:Un, {| hash( msg(_,text:Un) ) |}_^-1 )
[ !begun(b acknowledging to a receipt of text) ];
tag ack (Ack(b)) : Auth<b:Host>;
fun lkupAuthKey (p:Any) : AuthKey(p);
client Initiator (a:Host, b:Host, sA:SignKey(a), sB:AuthKey(b)) at a is
{
establish Receiver at b is (socket : Socket);
new (text : Public);
begin! (a sending text to b);
output socket is (a, text, {| hash( msg(b,text) ) |}sA);
input socket is {| ack (a, {| hash( msg(b,text) ) |}sA) |}sB^-1
[ !begun (b acknowledging to a receipt of text) ];
end (b acknowledging to a receipt of text);
}
server Receiver (b:Host, sB:SignKey(b)) at b is (socket : Socket)
{
input socket is (a:Un, text:Un, ctext:Un);
let sA:AuthKey(a) = lkupAuthKey(a);
match ctext is {| hash( msg(b,text) ) |}sA^-1
[ !begun (a sending text to b) ];
end (a sending text to b);
begin! (b acknowledging to a receipt of text);
output socket is {| ack(a,ctext) |}sB;
}
|