wallet: optional seed-offset passphrase on import #156

Merged
sirius merged 1 commit from onionwire/t_dc9b74a6-onionwire-wallet-optional-seed-offset-pa into main 2026-09-25 22:22:57 +00:00
Owner

What

Monero's optional seed-offset passphrase at wallet import. restore_deterministic_wallet's seed_offset is a second spend secret mixed into the 25 words at restore time, so the same words plus a different offset open a different wallet.

It is not the wallet-file passphrase: it is never sealed, never stored, never logged and never on an argv, and it travels only in the JSON-RPC body. A wrong offset is not an error - the RPC succeeds and the wallet is simply a different one, and the UI says so.

Core

  • Wallet::restore_wallet(filename, password, seed, seed_offset: Option<&str>) - None/empty/whitespace-only leaves seed_offset out of the JSON entirely (never seed_offset: ""); otherwise the ends trim and it is sent beside the existing fields, interior spaces kept. Existing local refusals (filename, file passphrase, seed) are unchanged.
  • Node::wallet_restore(password, seed, seed_offset) passes it through and still seals only the file passphrase. In-tree test caller passes None.

SDK (additive)

  • import_wallet(password, seed) keeps its signature and calls wallet_restore(..., None) - Android on main still compiles.
  • New import_wallet_with_offset(password, seed, seed_offset). Blank/whitespace is the same as import_wallet (passes None).
  • Generated Kotlin name confirmed with uniffi-bindgen on the built cdylib: importWalletWithOffset(password, seed, seedOffset), with importWallet(password, seed) unchanged.

TUI

ImportSeed -> ImportOffset -> ImportPass, reusing PassphraseEntry (the offset is never drawn).

  • First prompt body: optional. not the wallet file passphrase. blank Enter skips. a wrong offset opens a different wallet and does not error. Footer blank Enter skips Esc cancel ? help.
  • Blank Enter (buf empty or whitespace-only) skips to ImportPass with no offset and no confirm. A non-empty one goes through PassphraseEntry::with_first; confirm footer Enter submit Esc cancel ? help.
  • Mismatch: entry.close(), seed zeroized, alert offset passphrases do not match, back to Main, no RPC.
  • Esc: entry closed, seed zeroized, back to Main.
  • ImportPass carries the offset through both passphrase prompts, including the mismatch path (seed and offset zeroized).
  • Offset used -> new ImportOffsetSeen wall (offset not saved / type SEEN ? help) instead of opening the wallet. The wallet file already exists, so Esc is a no-op there (that variant is excluded from the outer Esc arm) and only SEEN opens the wallet with status note wallet imported. Nothing is stored or deleted.

Docs

docs/WALLET.md (import paragraph), docs/THREAT_MODEL.md (spend section: second spend secret, never sealed, a wrong offset is silent, not a second gate on an imported wallet), docs/TUI.md WalletSetup row, one added README.md sentence around the F6 then i copy. The README does not claim the phone screen has the field - that is the child card.

Tests

tests/wallet.rs (request bytes are the proof this card owns):

  • existing restore call now passes None and asserts the recorded body does not contain seed_offset
  • harbor-offset is sent as "seed_offset":"harbor-offset" with the seed still in the body
  • whitespace-only omits the field; " harbor offset " is sent as "harbor offset" (ends trim only)
  • a failed RPC error string contains neither the offset nor the seed

src/tui.rs adds wallet_offset_tests (7 tests): the seed step reaches the offset step with the locked footer, blank Enter skips without confirming, a non-empty offset is confirmed, a mismatch returns to Main with the locked alert and never reaches the node, the offset is not drawn, Esc does not leave ImportOffsetSeen, and only SEEN proceeds.

Locked strings kept verbatim: paste seed Enter Esc ? help, wallet imported, seed required to import a wallet, offset passphrases do not match, blank Enter skips Esc cancel ? help, offset not saved, type SEEN ? help.

Verify

Root crate (TMPDIR=/home/lancelot/.hermes/tmp/offset-pass):

cargo test --locked --target x86_64-unknown-linux-gnu   -> 102 + 10 + 9 + 8 + 14 + 14 + 12 + 11 + 12 + 3 + 11 + 18 + 5 + 5 + 5 + 2 + 9 + 9 + 8 + 32 + 1 + 18 + 12 + 12 + 16 + 37 + 60 + 9 + 8 passed, 0 failed
cargo clippy --locked --all-targets --target x86_64-unknown-linux-gnu -- -D warnings   -> clean

SDK workspace (own CARGO_TARGET_DIR under $TMPDIR):

cargo test --locked --target x86_64-unknown-linux-gnu   -> 52 + 1 + 1 passed, 0 failed
cargo clippy --locked --all-targets --target x86_64-unknown-linux-gnu -- -D warnings   -> clean

Not verified against a live monero-wallet-rpc (none on PATH, none downloaded). No new crates; Cargo.toml/Cargo.lock untouched.

Scope note

src/tui.rs gained a #[cfg(test)] mod wallet_offset_tests; tests/wallet.rs and docs/* are as listed. No android/ change.

## What Monero's optional **seed-offset passphrase** at wallet import. `restore_deterministic_wallet`'s `seed_offset` is a second spend secret mixed into the 25 words at restore time, so the same words plus a different offset open a different wallet. It is **not** the wallet-file passphrase: it is never sealed, never stored, never logged and never on an argv, and it travels only in the JSON-RPC body. A wrong offset is **not** an error - the RPC succeeds and the wallet is simply a different one, and the UI says so. ## Core - `Wallet::restore_wallet(filename, password, seed, seed_offset: Option<&str>)` - `None`/empty/whitespace-only leaves `seed_offset` out of the JSON entirely (never `seed_offset: ""`); otherwise the ends trim and it is sent beside the existing fields, interior spaces kept. Existing local refusals (filename, file passphrase, seed) are unchanged. - `Node::wallet_restore(password, seed, seed_offset)` passes it through and still seals only the file passphrase. In-tree test caller passes `None`. ## SDK (additive) - `import_wallet(password, seed)` keeps its signature and calls `wallet_restore(..., None)` - Android on `main` still compiles. - New `import_wallet_with_offset(password, seed, seed_offset)`. Blank/whitespace is the same as `import_wallet` (passes `None`). - Generated Kotlin name confirmed with `uniffi-bindgen` on the built cdylib: `importWalletWithOffset(password, seed, seedOffset)`, with `importWallet(password, seed)` unchanged. ## TUI `ImportSeed -> ImportOffset -> ImportPass`, reusing `PassphraseEntry` (the offset is never drawn). - First prompt body: `optional. not the wallet file passphrase. blank Enter skips. a wrong offset opens a different wallet and does not error.` Footer `blank Enter skips Esc cancel ? help`. - Blank Enter (buf empty or whitespace-only) skips to `ImportPass` with no offset and no confirm. A non-empty one goes through `PassphraseEntry::with_first`; confirm footer `Enter submit Esc cancel ? help`. - Mismatch: `entry.close()`, seed zeroized, alert `offset passphrases do not match`, back to Main, **no RPC**. - Esc: entry closed, seed zeroized, back to Main. - `ImportPass` carries the offset through both passphrase prompts, including the mismatch path (seed **and** offset zeroized). - Offset used -> new `ImportOffsetSeen` wall (`offset not saved` / `type SEEN ? help`) instead of opening the wallet. The wallet file already exists, so Esc is a **no-op** there (that variant is excluded from the outer Esc arm) and only `SEEN` opens the wallet with status note `wallet imported`. Nothing is stored or deleted. ## Docs `docs/WALLET.md` (import paragraph), `docs/THREAT_MODEL.md` (spend section: second spend secret, never sealed, a wrong offset is silent, not a second gate on an imported wallet), `docs/TUI.md` `WalletSetup` row, one added `README.md` sentence around the `F6` then `i` copy. The README does not claim the phone screen has the field - that is the child card. ## Tests `tests/wallet.rs` (request bytes are the proof this card owns): - existing restore call now passes `None` and asserts the recorded body does **not** contain `seed_offset` - `harbor-offset` is sent as `"seed_offset":"harbor-offset"` with the seed still in the body - whitespace-only omits the field; `" harbor offset "` is sent as `"harbor offset"` (ends trim only) - a failed RPC error string contains neither the offset nor the seed `src/tui.rs` adds `wallet_offset_tests` (7 tests): the seed step reaches the offset step with the locked footer, blank Enter skips without confirming, a non-empty offset is confirmed, a mismatch returns to Main with the locked alert and never reaches the node, the offset is not drawn, Esc does not leave `ImportOffsetSeen`, and only `SEEN` proceeds. Locked strings kept verbatim: `paste seed Enter Esc ? help`, `wallet imported`, `seed required to import a wallet`, `offset passphrases do not match`, `blank Enter skips Esc cancel ? help`, `offset not saved`, `type SEEN ? help`. ## Verify Root crate (`TMPDIR=/home/lancelot/.hermes/tmp/offset-pass`): ``` cargo test --locked --target x86_64-unknown-linux-gnu -> 102 + 10 + 9 + 8 + 14 + 14 + 12 + 11 + 12 + 3 + 11 + 18 + 5 + 5 + 5 + 2 + 9 + 9 + 8 + 32 + 1 + 18 + 12 + 12 + 16 + 37 + 60 + 9 + 8 passed, 0 failed cargo clippy --locked --all-targets --target x86_64-unknown-linux-gnu -- -D warnings -> clean ``` SDK workspace (own `CARGO_TARGET_DIR` under `$TMPDIR`): ``` cargo test --locked --target x86_64-unknown-linux-gnu -> 52 + 1 + 1 passed, 0 failed cargo clippy --locked --all-targets --target x86_64-unknown-linux-gnu -- -D warnings -> clean ``` Not verified against a live `monero-wallet-rpc` (none on PATH, none downloaded). No new crates; `Cargo.toml`/`Cargo.lock` untouched. ## Scope note `src/tui.rs` gained a `#[cfg(test)] mod wallet_offset_tests`; `tests/wallet.rs` and `docs/*` are as listed. No `android/` change.
wallet: optional seed-offset passphrase on import
All checks were successful
ci / test (pull_request) Successful in 6m21s
ci / sdk (pull_request) Successful in 1m28s
android-ci / android (pull_request) Successful in 12m54s
ci / fuzz (pull_request) Successful in 18m31s
f6a7daf892
Monero's `restore_deterministic_wallet` takes a `seed_offset`: a second
spend secret mixed into the 25 words at restore time, so the same words
with a different offset open a different wallet. It is not the wallet-file
passphrase and must never be sealed, stored, logged or put on an argv.

- `Wallet::restore_wallet` gains `seed_offset: Option<&str>`: None, empty
  or whitespace-only leaves the field out of the JSON entirely; otherwise
  the ends are trimmed and it is sent beside the seed.
- `Node::wallet_restore` passes it through and still seals only the file
  passphrase.
- SDK: `import_wallet` keeps its signature (None) and
  `import_wallet_with_offset` is added (Kotlin `importWalletWithOffset`).
- TUI: a new `ImportOffset` step between the seed and the file passphrase
  (blank Enter skips, a real one is confirmed, a mismatch never dials), and
  `ImportOffsetSeen` after a successful import that used one -- Esc cannot
  leave it, only SEEN, and the offset is not drawn anywhere.
- Docs: WALLET.md, THREAT_MODEL.md, TUI.md, one README sentence.
sirius merged commit a1f5c878d3 into main 2026-09-25 22:22:57 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!156
No description provided.