XX Pattern
Noise_XX_25519_ChaChaPoly_BLAKE2s is a three-message handshake in which neither side knows the other’s static key in advance, and both prove their keys before it ends. TrueSeal uses it for the Receive Session, the long-lived connection a device keeps open to take messages from its Inbox.
In TrueSeal
The device is the initiator and the relay the responder. After the handshake:
- the device checks that the relay’s static key matches the key in its Relay Address, and closes the connection if it doesn’t;
- the relay learns the device’s static X25519 key and serves the Inbox addressed to that key.
The relay therefore knows which device is online and when. That is the price of delivering messages to a device without it polling, and it is listed on How it works.
API
// Initiator
let session = session_xx::dial(conn, keypair)?;
let relay_key = session.remote_public_key();
// Responder
let session = session_xx::accept(conn, keypair)?;
let device_key = session.remote_public_key();
// Both sides
session.send(b"hello")?;
let msg = session.receive()?;
session.close()?;
remote_public_key() returns the other side’s static key, which XX always proves. trueseal-noise doesn’t decide whether to trust that key. trueseal-sync compares it with the Relay Address, and the relay uses it to pick the Inbox.
The pattern itself is defined in the Noise specification, and trueseal-noise’s tests check this cipher suite against one XX vector from the cacophony set.