trackslash
VAULT-143 P2 For an agent

Add a Private Key item type, protected like recovery phrases

0
Sub-issue of VAULT-141 P2 Reposition Vault as a vault for crypto keys and secrets, with 2FA codes as a supporting feature

Description

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

  1. 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.
  2. 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.
  3. 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.

GitHub

0

No branches or pull requests linked.

Comments

1
Bradley

Done in https://github.com/badbundle/vault-app/pull/752 (merged as 8d32945d), with Bradley's decisions: like phrases (masked, never copied, no QR display), plus PGP and SSH keys.

  • Formats: WIF, extended private keys (xprv, yprv, zprv, tprv and the other SLIP-132 versions), raw hex secp256k1 keys, Nostr nsec, OpenPGP, OpenSSH and PEM private keys, and Other.
  • Checks: checksums are checked where a format has one, and a public key entered by mistake gets a warning. Nothing is derived from the key.
  • Promises: G102–G105 in docs/security-model.md, with tests.
  • Help: a new "About Private Keys" page.
  • Not included: scanning a key from a QR code. It was suggested in this ticket but isn't among the decisions.
  • Validation: validated with the Mac UI tests skipped, at Bradley's request; a full run on main follows the queue.