Part of VAULT-141. Bradley wants Vault to be the place for crypto private keys, but it has no type for them.
Today
- There are four payloads:
otpCode, secureNote, encryptedItem and recoveryPhrase (VaultFeed/Models/VaultItem.swift:12-19).
- Recovery phrases cover BIP39, SLIP-39, Electrum, Monero and Other (1–48 words). They have checksums, an optional passphrase, and the G41/G88 protections:
- always encrypted and locked;
- masked until tapped;
- hidden in the background or while the screen is captured;
- never copied.
- No private key detection: nothing in the codebase recognises WIF, extended keys (xprv), hex keys, nsec, PGP or SSH keys. Someone with a single private key has to put it in a note, where it isn't validated and can be copied.
Change
A proposal. The decisions below come first.
- New kind "Private Key", stored only encrypted, as phrases are: the storage and backup encoders refuse it unencrypted.
- Formats, validated by checksum where there is one:
- WIF (Base58Check, with network and compressed flag);
- extended private keys (xprv/yprv/zprv/tprv and others, Base58Check);
- raw 32-byte hex, with or without
0x, checked to be in secp256k1's range;
- Nostr
nsec (bech32);
- "Other", which takes any text.
- Show the detected format, such as "WIF · mainnet · compressed". Derive nothing: no public keys or addresses. Deriving needs secp256k1 code that Vault doesn't have, and a CryptoKit-only rule applies to encryption (docs/export-compliance.md).
- Protections: the same as G41 on iOS and G88 on the Mac. That means always encrypted and locked, masked until tapped, hidden in the background and during capture, and never copied (
.editedTextCopying(.nothing)), with a Mac gate like VaultMacRecoveryPhraseDetailView's.
- Editor: a guided flow like the recovery phrase steps. Paste or type the key, and see whether it's valid. The QR scanner can read a key shown as a QR code.
- Everything else works as for phrases: search, hidden items, killphrases, PDF backups, QR transfer between devices, and restore.
- Both apps: iOS and the Mac, with an add-flow entry placed by VAULT-144's order.
- Docs: a new security-model row for each promise, with tests that pin it, and a help FAQ "About Private Keys". Check every promise against MANIFESTO.md.
Decisions for Bradley
- Copying: allow it, since importing a key into a wallet needs it, or block it as for phrases (G41)? The recommendation is to block it, as for phrases.
- Show as a QR code for importing into a wallet? It's handy, but a QR on screen can be photographed. The recommendation is not in the first version.
- Formats in scope: the crypto formats above only, or also armoured PGP and OpenSSH private keys? The recommendation is crypto formats now and PGP/SSH as a follow-up.
Done when
On iOS and the Mac, someone can add, view (masked), edit, search, hide, back up, transfer and restore a private key. Its protections are in docs/security-model.md with tests, and make validate passes.