Ed25519 Device Authentication
OpenClaw uses Ed25519 public-key cryptography for device authentication across Gateway, Control UI, and Native Apps.
Key Files
src/infra/device-identity.ts(183 lines): Core identity managementsrc/shared/device-auth.ts(31 lines): Auth data structuressrc/pairing/pairing-store.ts(621 lines): Pairing flow implementation
Authentication Flow
Key Generation and Derivation
Device Identity
Key Format Constant
This prefix is used to extract the raw 32-byte Ed25519 public key from the SPKI format.
Pairing Flow
Pairing Code Generation
- Code length: 8 characters
- Alphabet:
ABCDEFGHJKLMNPQRSTUVWXYZ23456789(excludes 0, O, 1, I to avoid confusion) - TTL: 60 minutes (3600000 ms)
- Max pending: 3 codes per channel/account
From src/pairing/pairing-store.ts:
Pairing Process
-
Request Pairing:
- Device calls
upsertChannelPairingRequest({ channel, id, accountId, meta }) - System generates unique 8-character code
- Code stored with 60-minute expiration
- Device calls
-
User Approval:
- User enters code via control UI
- System calls
approveChannelPairingCode({ channel, code, accountId }) - On match: adds device to allowlist, removes code from pending
-
Token Issuance:
- Gateway issues token with role and scopes
- Token stored in device auth store
Challenge-Response Signing
Signing
Verification
Security Properties
- Device identity is deterministic:
deviceId = SHA256(publicKey)ensures same device always has same ID - Private key never leaves device: Only signatures are transmitted
- Challenge-response prevents replay: Each authentication uses a fresh challenge
- Time-limited pairing: Codes expire after 60 minutes
- Limited pending codes: Max 3 pending codes per channel/account prevents abuse