Guide

Agent to Agent

The minimum viable two-agent setup. Alice sends Bob a Sessioned envelope over any transport; Bob decrypts and replies; Alice decrypts the reply. Both sides already know each other's identity Name.

Prerequisites

Step 1 — Alice initiates

using HexaEight.Bridge;

var alice    = new Client();
string bob   = "bob.example.com";
string sid   = Guid.NewGuid().ToString();
long   kgt   = CurrentKgt();

// Alice fetches her half of the ASK pair for Bob
string ask = await alice.FetchAskAsync(bob, kgt);
alice.PinAskForSession(sid, ask);

string envelope = await alice.EncryptEnvelopeAsync(
    recipient: bob,
    body:      "ping",
    sessionId: sid);

// Hand `envelope` and `sid` to Bob over any transport.
await SendOverWire(bob, envelope, sid);

Step 2 — Bob receives and replies

using HexaEight.Bridge;

var bob      = new Client();
string alice = "alice.example.com";
(string envelope, string sid) = await ReceiveFromWire();

// Bob fetches HIS half of the ASK pair for Alice
string ask = await bob.FetchAskAsync(alice, CurrentKgt());
bob.PinAskForSession(sid, ask);

DecryptedEnvelope msg = await bob.DecryptEnvelopeAsync(envelope);

Console.WriteLine($"From: {msg.Sender}  Body: {msg.Body}");
// From: alice.example.com  Body: ping

// Reply on the same session
string reply = await bob.EncryptEnvelopeAsync(
    recipient: alice,
    body:      "pong",
    sessionId: sid);
await SendOverWire(alice, reply, sid);

Step 3 — Alice reads the reply

(string envelope2, _) = await ReceiveFromWire();
var reply = await alice.DecryptEnvelopeAsync(envelope2);
Console.WriteLine(reply.Body);   // "pong"

Why this works

Once the session is established

Subsequent messages in either direction skip the ASK fetch — the cache hit makes each encrypt/decrypt sub-200ms.

// No more FetchAskAsync needed on either side — the session-pinned ASK is reused
var env = await alice.EncryptEnvelopeAsync(bob, "another message", sessionId: sid);
var msg = await alice.DecryptEnvelopeAsync(replyFromBob);

See also