Skip to main content

Module token

Module token 

Source
Expand description

The pairing token: the single string an operator carries from a client into a server.

Sendspin’s “Pairing Token” section defines a token as a fixed SP: prefix, one version character and a body:

token = "SP:" || version || body
body  = base32(payload), padding stripped, every `2` transliterated to `9`

The body is RFC 4648 §6 base32 with the = padding stripped. Transliterating 2 to 9 keeps the whole token inside the QR code alphanumeric set (0-9, A-Z, :), so a token survives a QR scan and a manual copy identically. Decoding reverses the transform and is lenient about how the operator supplied the string - surrounding whitespace, case and a missing SP: prefix - and strict about everything else.

Two versions exist:

  • version 0 carries client_key || pairing_psk, 64 payload bytes: a raw Curve25519 public key followed by the client’s pairing PSK. encode_v0 builds it.
  • version 1 carries the 24-byte dynamic pairing code of the qr_code emission format. encode_v1 builds it.

A token is a credential: anyone holding it can pair a server with the client. Nothing here is behind a feature gate - a token is text, not a PAKE - and neither Debug output nor an error message ever contains payload bytes; both report lengths instead.

The spec’s reference vectors are asserted in tests/pairing_token.rs.

Structs§

Token
A decoded pairing token.

Constants§

VERSION_1_PAYLOAD_LEN
Version 1’s payload length: the dynamic pairing code of the qr_code emission format.

Functions§

decode
Decodes a pairing token, or reports why the input is not one.
encode_v0
Encodes a version-0 pairing token: client_key || pairing_psk as base32.
encode_v1
Encodes a version-1 pairing token: the 24-byte dynamic pairing code as base32.