Skip to main content

Module enrollment

Module enrollment 

Source
Expand description

The wire form of the cross-device add ceremony (SSoT: Device Enrollment § Cross-Device Add): what each device advertises, the payloads they relay, and the safety code over them.

The server leg (code issue/redeem, the relay channel, close) carries opaque strings; this module defines what goes inside them. The ceremony, in relay order:

  1. enrollee B → initiator A: EnrollmentPayload::Commitment to B’s EnrolleeKeys;
  2. A → B: EnrollmentPayload::InitiatorKeys, carrying a fresh nonce;
  3. B → A: EnrollmentPayload::EnrolleeKeys, which A checks against the commitment (EnrolleeKeys::matches_commitment);
  4. both display enrollment_safety_code over what they hold and the user compares them;
  5. A admits B with Workspace::cross_sign_device (capsule-library) and sends EnrollmentPayload::Directory, which B verifies under the user IK.

The commit-before-reveal order in steps 1–3, over inputs that each carry a fresh per-ceremony nonce, is what makes a twelve-digit code sound against a man in the middle (see the safety-code module, crypto::keys::safety_code). Each side therefore draws its bundle once per ceremony and keeps the one it sent: a second call draws a new nonce, and so a different code. The master-key transfer under a channel key (design step 5) is not here: the channel’s ephemeral key agreement is not yet defined.

§Wire form

A payload is canonical CBOR of { "v": 1, "payload": <tagged payload> }, written as lowercase hex — the relay’s field is a JSON string, and hex needs no new dependency. Decoding refuses anything that does not re-encode to the exact same string, so every payload has one spelling and a key set hashes to one safety code.

Structs§

EnrolleeKeys
What the enrollee (the new device B) advertises: the public halves of the device keys it generated, which A cross-signs into the directory.
InitiatorKeys
What the initiator (the enrolled device A) advertises: the account it is adding to, the identity key the directory it will send verifies under, and its own device signing key.

Enums§

EnrollmentPayload
One message relayed between the two devices.
EnrollmentPayloadError
Why a relayed payload could not be encoded or decoded.

Constants§

ENROLLMENT_NONCE_LEN
The length of each side’s per-ceremony nonce. Device keys are static — the initiator’s are already published — so without fresh randomness on both sides a man in the middle could predict one side’s input and grind the code offline.
ENROLLMENT_PAYLOAD_VERSION
The payload format version this build writes and the only one it reads.
MAX_ENROLLMENT_PAYLOAD_CHARS
The longest encoded payload this build writes or reads, in characters — the relay’s own per-payload ceiling, so a payload this side accepts is one the relay would have carried.

Functions§

enrollment_safety_code
The safety code both devices display, over the initiator’s and the enrollee’s advertised keys as each side received them.