Skip to content

feat: migrate to v3 vault files - #288

Open
ahmed-tarek-salem wants to merge 3 commits into
devfrom
feat/read-v3-vaults
Open

ahmed-tarek-salem wants to merge 3 commits into
devfrom
feat/read-v3-vaults

Conversation

@ahmed-tarek-salem

Copy link
Copy Markdown
Contributor

Adds support for v3 vault files (Argon2id, via the new @qubic.org/vault@1.2.1 dependency) to import, both unlock flows, and export. Reading detects v1 or v3 automatically, so existing v1 files keep working exactly as before. Export now writes v3: spendable seeds are decrypted with the session key and written into the vault, watch-only accounts are written without seed material (the flag is authoritative), and export is refused if a spendable account has no valid seed rather than producing a backup that cannot restore it. Since a v3 file carries the accounts rather than an RSA keypair, importing one creates a fresh session keypair and re-encrypts every seed under it.

ng test failed before running a single spec: the CLI's virtual test
entry is rejected by the TS-inclusion check in this setup, and recent
Chrome never captures under the old headless mode. Use an explicit
src/test.ts main, force --headless=new, and raise karma timeouts so
Argon2id unlocks (64 MB, t=3, main-thread) survive the ping window.
Detect the vault file version (legacy v1 JSON vs v3 binary Argon2id
envelope, via @qubic.org/vault) in one helper and route isVaultFile,
importVault and unlockVault through it. A v3 file carries the accounts
themselves rather than an RSA keypair, so importing one creates a fresh
session keypair and re-encrypts every seed under it; unlocking with a
v3 file is a full import (the file is the source of truth). Export
still writes v1 until every wallet ships a v3 reader.

Safety rules carried over from the ts-library-wrapper migration: the
watch-only flag is authoritative, recovered seeds must match
^[a-z]{55}$, and a vault missing seed material is refused as
INVALID VAULT FILE.
exportVault now decrypts every spendable seed with the session key and
writes a v3 (Argon2id) vault through @qubic.org/vault instead of the
legacy v1 file. The watch-only flag is authoritative: such accounts are
written without seed material even when an encrypted seed is still
stored for them. Export is refused if a spendable account has no valid
seed, rather than producing a backup that cannot restore it.

The v1 writer (encryptVault and its base64 helper) is removed as dead
code; reading v1 files is unchanged. The read and write paths share one
IVaultSeed type. Four specs cover the write path: create-then-unlock
round-trip, watch-only never carries a seed, refusal without a valid
seed, and rejection under a wrong password.
@ahmed-tarek-salem ahmed-tarek-salem changed the title feat: support v3 vault files feat: migrate to v3 vault files Sep 12, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant