Skip to content

feat(wallet): B1.3 mir wallet commands + prf-rooted CLI identity#39

Merged
frahlg merged 1 commit into
mainfrom
b1.3-wallet-cli
Jun 12, 2026
Merged

feat(wallet): B1.3 mir wallet commands + prf-rooted CLI identity#39
frahlg merged 1 commit into
mainfrom
b1.3-wallet-cli

Conversation

@frahlg

@frahlg frahlg commented Jun 12, 2026

Copy link
Copy Markdown
Member

Summary

Makes the CLI identity wallet-capable. The client previously stored a directly-generated X25519 owner key with no prf root, so there was nothing to derive a wallet from. Per the decided model (option A):

  • New identities are prf-rootedowner.json gains a 32-byte secret that derives both the X25519 transport key (DeriveOwnerKey) and the Solana wallet (DeriveWallet). One root, two keys.
  • Legacy identities (no secret) keep working for transport; mir wallet reports they have no wallet, and mir keygen --wallet re-keys into a prf-rooted identity (new owner_id → re-pair, matching Fork 2's "re-pair to upgrade"). No forced migration.

What's added

  • bip39: MnemonicToEntropy (Go and JS), checksum-validated — the import path; round-trips entropyToMnemonic.
  • identity: DeriveWalletAccount (m/44'/501'/i'/0') for HD sub-accounts.
  • client/store: prf-rooted Identity (secret / wallet_address), SetFromSecret, SaveIdentity, Rekey, Wallet/HasWallet/Secret. owner.json stays 0600.
  • cli: mir wallet address|accounts|export-phrase|import-phrase + mir keygen --wallet. Reveal (export-phrase) and replace (import-phrase) gate on --yes with explicit warnings.

The gate

A CLI test ties import-phrase to the external anchor: importing the known phrase restores wallet C2XYPf… and owner_id 269863f7… — the same prf derives both keys, verified end-to-end through the real command. Real-binary smoke confirmed (wallet address on a fresh dir creates a prf-rooted identity; accounts lists sub-accounts; export-phrase refuses without --yes).

Notes / not in this PR

  • This is the prf-rooted identity migration the spec flagged (Fork 2). It changes owner.json schema additively; legacy identities are untouched until re-keyed.
  • B1.4 (wire base58 owner_id through relay routing + agent pinning + registration proof, accepting both forms; wallet auth sig on pair/attach) is the next slice and is live-infra adjacent — checkpoint before deploy.

Test Plan

  • go test ./... green; gofmt + vet clean
  • npm test83/83 (+1 mnemonicToEntropy)
  • Real-binary smoke: address / accounts / export gate / import→anchor
  • PR test workflow green

🤖 Generated with Claude Code

Makes the CLI identity wallet-capable. Per the decided model: new identities are
prf-rooted — owner.json gains a 32-byte `secret` that derives BOTH the X25519
transport key (DeriveOwnerKey) and the Solana wallet (DeriveWallet). Legacy
identities (no secret) keep working for transport; re-key with `mir keygen
--wallet` to get a wallet (changes owner_id → re-pair, matching Fork 2).

- bip39: MnemonicToEntropy (Go+JS), checksum-validated — the import path.
- identity: DeriveWalletAccount (m/44'/501'/i'/0') for HD sub-accounts.
- client/store: prf-rooted Identity (secret/wallet_address), SetFromSecret,
  SaveIdentity, Rekey, Wallet/HasWallet/Secret. owner.json stays 0600.
- cli: `mir wallet address|accounts|export-phrase|import-phrase` and
  `mir keygen --wallet`. Reveal/restore gate on --yes with explicit warnings.

CLI test ties import-phrase to the external anchor: the known phrase restores
wallet C2XYPf… and owner_id 269863f7… (same prf derives both, end-to-end).

go test ./... green; web 83/83.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@frahlg frahlg merged commit 8d4a874 into main Jun 12, 2026
2 checks passed
@frahlg frahlg deleted the b1.3-wallet-cli branch June 12, 2026 08:53
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