Keystore
Threat model
Encryption helps at rest; XSS, malware, and weak PINs remain critical risks.
Overview
Keystore reduces casual disk snooping; it does not make a compromised device or XSS-safe web app safe for hot wallets.
In scope (mitigated)
- At-rest secrets on disk when
encryption: trueand PIN is strong - Accidental plaintext secret rows in SQLite / KV
- The Gray3 Cloud API never receives seed phrases
Out of scope / residual risk
- XSS on pages that can call keystore APIs or read
localStorageafter unlock - Device malware / rooted phones that scrape process memory while unlocked
- Weak PINs — scrypt helps; short numeric PINs remain brute-forceable offline against a stolen DB
- Plaintext metadata — addresses, labels, Monero sync cache reveal activity even when secrets are sealed
- encryption: false — secrets stored plaintext (dev only)
Recommendations
| Field | Required | Description |
|---|---|---|
| Node / desktop | No | SQLite + strong password; OS file permissions on the DB path |
| Mobile | No | expo-sqlite plus a strong PIN, or encryptionKey kept in Keychain / Keystore behind biometrics |
| Web | No | SQLite web backend; lock on sign-out; strict CSP; keep keys out of extension content scripts |
| Monero | No | gray.monero.syncConnection() carries your project secret key: use it only on your server, never in a browser or mobile app |
Error codes
| Field | Required | Description |
|---|---|---|
| unauthorized | No | Locked keystore or bad PIN — do not distinguish beyond UX needs |
| internal | No | Corrupt master key / envelope — treat store as damaged |
js
import { isGrayError } from "@gray3/core";
if (isGrayError(err) && err.code === "unauthorized") { /* re-prompt PIN */ }