···4545 params: CreateAccountParams
4646): Promise<CreateAccountResult> =>
4747 invoke('create_account', params);
4848+4949+// ── Device Key types ──────────────────────────────────────────────────────────
5050+5151+/**
5252+ * Device public key returned by the `get_or_create_device_key` Rust command.
5353+ * Matches DevicePublicKey struct with #[serde(rename_all = "camelCase")].
5454+ */
5555+export type DevicePublicKey = {
5656+ /** 'z' + base58btc(33-byte compressed P-256 public key point). */
5757+ multibase: string;
5858+ /** Full did:key URI: 'did:key:z...' */
5959+ keyId: string;
6060+};
6161+6262+/**
6363+ * Error returned by device key commands.
6464+ *
6565+ * Serialized as `{ code: "KEY_GENERATION_FAILED" }` etc. by the Rust backend.
6666+ * `message` is present only for KEYCHAIN_ERROR.
6767+ */
6868+export type DeviceKeyError = {
6969+ code:
7070+ | 'KEY_GENERATION_FAILED'
7171+ | 'KEY_NOT_FOUND'
7272+ | 'SIGNING_FAILED'
7373+ | 'INVALID_SIGNATURE'
7474+ | 'KEYCHAIN_ERROR';
7575+ message?: string;
7676+};
7777+7878+// ── get_or_create_device_key ─────────────────────────────────────────────────
7979+8080+/**
8181+ * Get or create the device's SE-backed (or simulator-fallback) P-256 keypair.
8282+ *
8383+ * Idempotent — returns the same key on every call for a given device.
8484+ * On failure, the Promise rejects with a `DeviceKeyError`.
8585+ */
8686+export const getOrCreateDeviceKey = (): Promise<DevicePublicKey> =>
8787+ invoke('get_or_create_device_key');
8888+8989+// ── sign_with_device_key ─────────────────────────────────────────────────────
9090+9191+/**
9292+ * Sign arbitrary bytes using the device's SE-backed (or simulator-fallback) P-256 key.
9393+ *
9494+ * Returns the raw 64-byte ECDSA r||s signature as a Uint8Array.
9595+ *
9696+ * IMPORTANT: `data` is converted to `number[]` before passing to Tauri's IPC
9797+ * because Tauri v2's JSON deserializer cannot accept a `Uint8Array` nested inside
9898+ * an object property — it must be a plain number array. See tauri#10336.
9999+ *
100100+ * On failure, the Promise rejects with a `DeviceKeyError` (code: KEY_NOT_FOUND
101101+ * if `getOrCreateDeviceKey` has never been called for this device).
102102+ */
103103+export const signWithDeviceKey = (data: Uint8Array): Promise<Uint8Array> =>
104104+ (invoke('sign_with_device_key', { data: Array.from(data) }) as Promise<number[]>).then(
105105+ (bytes) => new Uint8Array(bytes),
106106+ );