Skip to main content

Overview

Device Identity provides cryptographic authentication for WebSocket connections using Ed25519 digital signatures. Each browser generates a persistent key pair and signs server challenges during the gateway handshake, enabling secure device-level authentication beyond simple API tokens.
This implements OpenClaw gateway protocol v3 challenge-response. The system gracefully falls back to token-only auth if Ed25519 is unavailable (older browsers).

Architecture

The device identity system has three layers:
1

Key Generation

On first use, the browser generates an Ed25519 key pair and stores it in localStorage:
2

Challenge-Response

During WebSocket connect, the gateway sends a nonce. The client signs it:
3

Token Caching

On successful auth, the gateway returns a device token cached for reuse:

Implementation

The complete device identity module:

Base64url Encoding

The protocol uses base64url (RFC 4648) for binary data:

WebSocket Challenge-Response

The complete handshake flow:
1

Connect

Client initiates WebSocket connection to gateway:
2

Challenge

Gateway sends auth challenge with random nonce:
3

Sign

Client signs nonce with device private key:
4

Respond

Client sends auth response with signature:
5

Verify (Gateway)

Gateway verifies signature and responds:
6

Cache Token

Client caches device token for future connections:

Security Properties

  • Ed25519: State-of-the-art elliptic curve signature scheme
  • Non-extractable: Private key cannot be exported after import
  • localStorage: Keys persist across browser sessions
  • Device-specific: Each browser instance has unique identity

Graceful Degradation

The system falls back when Ed25519 is unavailable:
Browser Compatibility: Ed25519 requires Chrome 113+, Firefox 102+, Safari 17+. Older browsers fall back to token-only authentication.

Management Operations

Clear Device Identity

Force regeneration of device keys:

Inspect Device Identity

View current device ID:

Export for Gateway Registration

Some gateways require pre-registration:

Troubleshooting

1

Connection fails with 'Invalid signature'

  • Clear device identity and regenerate: clearDeviceIdentity()
  • Check browser console for Ed25519 support errors
  • Verify gateway is running protocol v3
  • Ensure system clock is synchronized (signature timestamp validation)
2

Keys corrupted or not loading

  • Check localStorage size limits (5-10MB per origin)
  • Verify no extensions clearing localStorage
  • Inspect Application > Local Storage in DevTools
  • Force regeneration with clearDeviceIdentity()
3

Fallback to token-only auth

  • Check browser version (Ed25519 requires modern browsers)
  • Verify crypto.subtle is available (requires HTTPS or localhost)
  • Review browser console for “NotSupportedError” messages

Best Practices

Production Deployments: Always use WSS (WebSocket Secure) in production. Ed25519 signatures don’t encrypt the payload—they only provide authentication.
  • Never export or share private keys
  • Document device IDs for audit trails
  • Use device tokens for session continuity
  • Rotate device identity on security events