Skip to main content

Module code

Module code 

Source
Expand description

The dynamic pairing code: its commitment and the derivation both sides repeat.

pairing.md binds a per-session code to the Noise handshake and to one nonce from each side:

commit_B = SHA-256("sendspin-pair-commit-v1" || nonce_B)
digest   = SHA-256("sendspin-pairing-code-derive-v1" || h || nonce_A || nonce_B)

commit_B travels in client/pair-init, before any value from the server is known, so the client is bound to the nonce_B it later reveals under the CPace output. The digest yields the code in one of two emission formats: the six ASCII digits of digits (also CPace’s PRS) or the first 24 bytes of the digest, carried as a version-1 token in qr_code.

§Secret handling

nonce_B is a secret until it is revealed, sealed, in client/pair-confirm; commitment takes it as bytes and neither function here formats any input. DynamicCode has no Debug implementation, so the code - which the operator is meant to see - cannot reach a log line by accident either: a caller emits it deliberately, through the client’s event stream.

The module is behind the pairing-code feature with pake and wrap: only the code flows derive a code.

Structs§

DynamicCode
The digest both sides derive the pairing code from.

Constants§

COMMIT_LABEL
The label that prefixes the commitment of nonce_B.
DERIVE_LABEL
The label that prefixes the code derivation.
DIGITS_LEN
Number of digits the digits emission format carries.
QR_CODE_LEN
Number of bytes the qr_code emission format carries.

Functions§

commitment
Computes commit_B = SHA-256(label || nonce_B).