Expand description
Anonymous device enrollment — stateless HMAC challenge and Ed25519 verification.
The challenge is HMAC-SHA256(challenge_key, pubkey). It is deterministic:
the same pubkey always produces the same challenge. Replay of a valid
(pubkey, signature) pair is idempotent — it re-enrolls the same device,
producing the same DeviceRecord upsert. This is analogous to PKCS#10 CSR
signing in standard PKI, where the CA validates possession, not freshness.
challenge_key is derived from the node signing key via HKDF so that:
- It never overlaps with the JWT signing path.
- It is safe to use as a challenge oracle (HMAC is secure under chosen-message attacks).
Functions§
- compute_
kid - Compute the
kidfor a cookie signing key (first 4 bytes of SHA-256 → 8 hex chars). - derive_
challenge_ key - Derive the challenge key from the node signing key seed.
- derive_
cookie_ key_ seed - Derive the cookie signing key from the node signing key seed.
- device_
challenge - Compute the challenge bytes the client must sign to prove device key possession.
- encode_
vault_ device_ cookie - Encode a
__Secure-VaultDevicecookie value. - verify_
device_ enrollment - Verify that
signatureis a valid Ed25519 signature overHMAC(challenge_key, pubkey). - verify_
vault_ device_ cookie - Verify a
__Secure-VaultDevicecookie and return the device pubkey on success.