Skip to main content

Module app_keys

Module app_keys 

Source
Expand description

f3129 app keys S2+S3: binding the app’s no-prompt signing keys to an instance inside the device flow (docs/contracts/app-key-bind-v1.md).

  • S2, POST /v1/device/code: the engine announces the keys (AppKeyAnnouncementV1, app_keys) only to a Cloud whose code answer lists FEATURE_DEVICE_APP_KEYS. The approval page names each key with its fingerprint (key_id) before the person allows the connection.
  • S3, POST /v1/device/token: the instance key signs app_key_bind_signing_input (app_keys_bind_signature) over the one-time device_code, its own public key and the announced keys. The offered keys (chat_key, task_propose_key, optin_key) must equal the announced set.

Every signature here is verified strictly (verify_strict: canonical 64-byte signature, no small-order key or R).

Encoding (unlike the crate-wide standard base64): app public keys and all signatures here are base64url without padding; key_id is hex(sha256(raw public key))[..16]; instance_public_key enters every statement exactly as the token request carries it (standard base64).

Structs§

AppKeyAnnouncementV1
One entry of DeviceCodeRequestV1.app_keys (S2).
AppKeyOfferV1
chat_key / task_propose_key / optin_key of the device-token request.

Enums§

AppKeyKind
Which app key. Ordered by wire name, the order the lists are sorted in.

Constants§

APP_KEY_ALG
The one algorithm of an app key.
APP_KEY_BIND_DOMAIN
Domain of the instance key’s bind signature (S3).
APP_KEY_ERROR_CODE
Error code of every app-key refusal (HTTP 400).
APP_KEY_ID_LEN
Length of key_id in hex characters.
FEATURE_DEVICE_APP_KEYS
DeviceCodeV1.features entry of a Cloud that takes app_keys (S2) and app_keys_bind_signature (S3). Without it the engine announces, offers and binds no app key.
MAX_APP_KEYS
At most one key per kind.
PAIRING_FAILED_TEXT
What the engine and the app show for either reason.
REASON_APP_KEY_BIND_INVALID
reason: app_keys_bind_signature is missing or does not verify.
REASON_APP_KEY_NOT_ANNOUNCED
reason: the offered keys are not exactly the announced ones.

Functions§

app_key_bind_signing_input
The bytes the instance key signs for S3 (app_keys_bind_signature): APP_KEY_BIND_DOMAIN ‖ canonical_json({device_code_sha256, instance_public_key, keys: [{alg, kind, key_id, public_key}] sorted by kind}). keys are the announced keys; the caller validated them.
app_key_bind_statement
The JSON value under app_key_bind_signing_input.
app_key_id
hex(sha256(public key bytes))[..16].
app_key_offer_bind_input
The bytes an app key signs for its own offer (bind_signature): the kind’s bind domain ‖ canonical_json({alg, instance_public_key, key_id, public_key, scope}), as !622/!627/!628 define them.
app_key_refusal_text
The text the engine shows for an app-key refusal, None for any other reason.
decode_b64url_exact
Decode canonical base64url without padding of exactly len bytes.
offered_equals_announced
Announced-set equality (check 4 of the Cloud’s order): every announced key is offered with identical alg, key_id and public_key, nothing else is offered, and no kind is offered twice. Err names the first differing (or repeated) request member; the Cloud answers 400 invalid_field, reason REASON_APP_KEY_NOT_ANNOUNCED, with that field.
validate_app_keys
DeviceCodeRequestV1.app_keys: each entry valid, sorted by kind, at most one per kind (so at most MAX_APP_KEYS). The Cloud answers any failure with 400 invalid_field, field: "app_keys".