signed
diapason.mesh.signed
¶
What a paired device must prove to be heard, whatever it is saying.
Three surfaces are open to devices that hold no API key — the presence beacon, the command poll, and the result acknowledgement — and all three answer the same question first: is this really that device, saying this, now? The answer is one Ed25519 signature and seven checks, and they live here so there is exactly one copy of them to get right.
What each surface signs stays its own business: every caller passes the explicit tuple of fields covered by the signature. Listing them rather than signing "everything but the signature" means adding a field later is a deliberate act with a version bump, not an accident that silently changes what is protected.
SignedRejected
¶
Bases: Exception
Refused, with a reason already written for the user in French.
sign_payload(payload, fields)
¶
Return payload with this device's signature over fields attached.
signable(payload, fields)
¶
The exact subset the signature covers, in a stable order.
verify_payload(raw, *, fields, version, registry, local_owner_id, local_device_id, now_ms, stamp_field='sentAtMs', subject='requête')
¶
Run the seven checks every device-signed request must pass.
Order matches verify_command: the cheap structural checks first, so a
malformed or misaddressed payload never reaches the cryptography.
subject names the thing being refused, so somebody debugging why their
phone will not pair reads « Cette relève est trop ancienne » rather than a
generic noun. It must be a FEMININE French noun — the sentences below
agree with it (« Cette … n'est pas signée »).
@returns the verified sending device id.