2026-09-10 02:49:42 -04:00
# OnionWire threat model (v1)
OnionWire is a two-party chat over Tor onion services. There is no chat server.
2026-09-20 00:31:07 -04:00
Identity is an ed25519 pubkey; the onion is a locator only (`F4` rotates the
locator, nothing else). Wire format: [PROTOCOL.md ](PROTOCOL.md ). Wallet:
[WALLET.md ](WALLET.md ). In-house review notes: [SECURITY_AUDIT.md ](SECURITY_AUDIT.md )
— **not ** a public third-party audit. Do not cite that file as “audited.”
2026-09-10 02:49:42 -04:00
## Tor relays are not a chat server
Each install hosts its own v3 onion and dials friends’ onions through in-process Arti. Relays move cells; they never see plaintext, never store messages, and never hold a roster. Compromising a relay is not compromising OnionWire’ s message store. The store is the sqlite file on the endpoint.
## Location updates are not a missing-person finder
2026-09-10 16:53:03 -04:00
A signed `loc` frame (`onion` , `ts` , `sig` ) rewrites a friend’ s locator **only if ** that friend is already in the roster, the signature verifies against the pinned pubkey, and `ts` is newer. There is no directory, DHT, or introduction server. If you rotated while they were offline, they cannot find you until they F3-paste your new invite. OnionWire will not hunt for a missing person.
2026-09-10 02:49:42 -04:00
## Rotating the onion does not revoke a friend
2026-09-10 16:53:03 -04:00
`F4` changes the locator only. The identity key is unchanged. Anyone who already has your pubkey can still prove they are talking to you, and a later invite paste with the same `k` updates their row. To become a new person, `/wipe-all` (new identity key). There is no in-band unfriend/revoke in v1.
2026-09-10 02:49:42 -04:00
2026-09-17 20:48:10 -04:00
## Rotating the prekey is a hard cut, and it is wider than F4
transport: ML-KEM-768 hybrid prelude and onionwire:v2 invites
Adds an ML-KEM-768 install key beside the ed25519 identity and x25519
prekey. A friend added from a v2 invite always gets a version-2 PQ
prelude before Noise msg 1, and both sides bind (ct, ss_kem) into the
Noise prologue (onionwire-v2 \0 ct \0 ss_kem). The row decides: a
kem_pk friend without a prelude is rejected with 'prelude required',
a prelude for a classical row with 'unexpected prelude'.
Invites are now onionwire:v2 with kem=<base64url pk>; decode still
accepts v1 (no kem) and yields a classical friend. F8 rotates the
KEM key with the prekey and hard-cuts stored ratchet state. The TUI
labels a legacy friend 'classical'.
Docs: PROTOCOL (keys, framing, prologues, no-downgrade, invite v2),
THREAT_MODEL (what PQ transport does and does not buy; epoch 0 stays
classical), README (invite size, F8, legacy caveat). SDK exposes pq on
InviteInfo/FriendInfo and gains a v2 decode round-trip test.
2026-10-20 11:15:46 -04:00
`F8` rotates the long-lived signed prekey **and the ML-KEM-768 install key ** . The identity key and the onion are unchanged, but the prekey is our Noise static **and ** the seed of the bootstrap ratchet epoch, and the KEM key is what peers encapsulate to, so once either moves nothing is reachable any more: a friend's dial uses the prekey and `kem=` they pinned from your invite, and their stored epoch is derived from the old prekey. There is no push path for either key — they only travel inside a signed invite — so every friend, online or offline, has to F3-paste the new invite before chat works in either direction again. F8 therefore also drops the local ratchet state for every friend, exactly as a peer's own prekey change does. Rotating the prekey shrinks the forward-secrecy window of the long-lived static; it is not a revocation (the old invite holder still learns nothing new, but they also cannot talk to you).
## Post-quantum transport does not make messaging post-quantum
Every Noise session to a v2 friend carries an ML-KEM-768 secret. The
initiator sends a `version = 2` prelude with `ct = Encapsulate(friend.kem_pk)`
before Noise msg 1, and both sides mix `(ct, ss_kem)` into the Noise prologue
(`"onionwire-v2" || 0x00 || ct || 0x00 || ss_kem` ). A recorded handshake
therefore exposes an X25519 DH and an ML-KEM-768 encapsulation; a future
cryptographically relevant quantum adversary has to break ML-KEM-768 as well as
X25519 to recover the Noise transport keys. That removes the
harvest-now-decrypt-later exposure of the **one-shot transport ** .
What this does **not ** buy:
- **The chat ratchet stays classical.** Chat messages are `rat ` frames
(Double Ratchet, `docs/PROTOCOL.md` ). The **bootstrap epoch is derived only
from the two long-lived X25519 prekeys** (HKDF over their DH, with the
identity pubkeys mixed in), so an adversary who records a `rat ` chain and
later obtains both prekeys can reconstruct epoch 0 even though the Noise
session that carried it was hybrid. Later epoch chains use fresh X25519 DH
steps, which are equally quantum-vulnerable. PQ ratchet steps are a separate
follow-up, not part of this transport work.
- **Identity and invite signatures are ed25519**, still classical. The KEM key
is authenticated by a v1-style ed25519 invite signature; an adversary who can
forge it can also swap `kem=` . Hybrid transport protects confidentiality, not
the long-term authentication root.
- **Legacy friends get nothing.** A friend added from an `onionwire:v1` invite
has no `kem_pk` ; sessions to them are the old classical `onionwire-v1`
prologue, and the UI labels that friend as lacking PQ protection. The choice
is derived from the roster row, never from the wire: a `kem_pk` friend
rejects a prelude-less session with `prelude required` before any application
frame, so an active attacker cannot downgrade it.
- **Mixed-version fleets break.** A v1-only build cannot open a session with a
v2 friend; that is accepted rather than adding a fallback path.
2026-09-17 20:48:10 -04:00
2026-09-12 13:00:18 -04:00
## Your store is encrypted
The sqlite store is SQLCipher (`rusqlite` feature `bundled-sqlcipher-vendored-openssl` ).
A 32-byte key is derived from the store passphrase with Argon2id (same params as
identity backup) over a per-install 16-byte salt in `store_salt` , and handed to
SQLCipher as a **raw ** key (`PRAGMA key = "x'…'"` ) — no second KDF pass over it.
The key is the first statement after open, so the file header, schema, identity
docs: ratchet wire spec + forward-secrecy/PCS threat-model claims
PROTOCOL.md gains a 'Ratchet (v1 chat layer)' section written so a second
implementation can interoperate from the text alone: byte-exact frame layout
(rat , 0x01, dh_pub||N||PN as header and AAD, 12-byte nonce,
ChaCha20-Poly1305), the KDF_RK/KDF_CK constructions and the role-separated
epoch rule, the derived bootstrap epoch, the receive and DH-step rules, the
MAX_SKIP/MAX_SKIPPED_KEYS bounds with the replay rule, the SQLCipher
ratchet_sessions row, and what stays unratcheted.
THREAT_MODEL.md gains the corresponding gains (per-chain forward secrecy, PCS
after a DH step, header not on the wire) and honest limits (skipped-key
window, the prekey-bound bootstrap epoch, no deniability, no one-time
prekeys, compromised endpoint out of scope, no metadata gain, the no-server-
outbox lock untouched) plus the amended transport wording.
README.md documents the operator-visible consequence: no reset command yet,
prekey change / invite re-paste is the only recovery, /wipe keeps the state,
and a desync is currently stderr-only.
2026-09-16 19:40:40 -04:00
secret key, friend public keys, locators, profiles, payment rows and the
per-friend ratchet session blobs (`ratchet_sessions` ) are all ciphertext on
disk. There is no `identity_sk` -on-disk problem to work around
2026-09-12 13:00:18 -04:00
because `identity_sk` is inside the encrypted file. A wrong or empty passphrase
fails closed before any write; an encrypted store whose `store_salt` is missing
refuses to open instead of guessing.
v0.2.1 installs have a plaintext db. The first open with the right passphrase
upgrades it in place (`ATTACH … KEY` + `sqlcipher_export` after a WAL
checkpoint), and swaps the file in only after the new file opens, passes
`integrity_check` and unwraps `store_meta` . A wrong passphrase leaves the
plaintext file untouched. The `store_salt` file is not secret (a salt never is).
Chat bodies carry a second, row-bound layer: ChaCha20-Poly1305 (`nonce ||
ciphertext` in ` messages.plaintext`) with AAD ` owmsg1 || friend_id_le64 || dir ||
0x00 || row_id_le64`, plus a random 32-byte data key wrapped with Argon2id from
the same passphrase (`store_meta` ). Whole-db encryption does not stop someone who
can write the file from moving one row's ciphertext into another row; the AAD
does, and it stays. Unlock is fail-closed: wrong or empty passphrase does not
open chat. Empty-AAD v0.2 blobs are rewrapped once on unlock; `list_messages`
never falls back to empty AAD.
At-rest encryption is not a defense against a live compromise: while OnionWire
runs, the passphrase, the db key and decrypted bodies are in process memory, and
SQLCipher's page cache holds decrypted pages. It also does not stop an attacker
who has your passphrase. `/wipe` deletes chat and payments history (overwrite
message bodies, `VACUUM` , WAL checkpoint); roster and identity stay. It is not a
forensic erase — SSD wear-leveling can keep copies. `/wipe-all` deletes the data
dir (new identity); same disk caveat.
2026-09-10 02:49:42 -04:00
## Fail closed
feat(outbox): local retry queue for chat sends
Queue a chat send locally when the peer's v3 onion is unreachable and retry
it with exponential backoff (30s doubling, capped at 30 min, 8 attempts then
terminal Failed). Still peer-to-peer: no server, no store-and-forward relay,
no new frame prefix — every attempt is a fresh Noise IK handshake.
- src/outbox.rs: Outbox + Deliverer + ArtiDeliverer, pure backoff_secs(),
is_permanent_send_error(), background worker (15s scan).
- store: `outbox` table (no body column — the body is read from the joined
messages row, under that row's existing AEAD + AAD), append_message_id(),
queue/due/pending/mark_* helpers, reset_sending_outbox(), wipe.
- Node::send() returns Result<OutboxStatus, String> (Sent/Queued) instead of
Err on transport failure; protocol errors still fail immediately and are
never queued.
- Retry triggers: timer, unlock/foreground (spawn_flush_all), and "that peer
was just seen" (handshake or connect_onion -> spawn_flush_friend).
- File transfer and payment/rcp frames stay fail-closed.
- docs/PROTOCOL.md + docs/THREAT_MODEL.md: replace the no-queue statements;
add the seizure/cadence delta to the threat model.
src/tui.rs gets one forced arm change (Ok(()) -> Ok(_)); UI surfacing is
child card t_d9a5b065.
2026-09-12 13:35:10 -04:00
Peer onion down → a **chat ** send is queued locally and retried (see “Local outbox (chat retry queue)”); file transfer and payment frames still fail immediately. Fingerprint mismatch vs the pinned key → hard fail, no send, never queued. Arti HS experimental: if it cannot publish, OnionWire stops; it does not fall back to C-tor.
## Local outbox (chat retry queue) is local, and it re-dials on a schedule
A chat send to an unreachable onion is written to an `outbox` row next to its `messages` row and retried in the background. There is no server-side queue: a queued message is never handed to a third party, and it dies with the device. Two consequences are real and are accepted:
- **Device seizure.** A pending (never-delivered) message sits in the same SQLCipher store as the rest of the history, under the same per-row AEAD and the same passphrase-derived key — no weaker, but also no shorter-lived. Seizure * with * the passphrase reveals messages that were never actually sent, including ones the sender may have moved on from; seizure without it reveals nothing in this store. `/wipe` clears outbox rows with the rest of chat history; `/wipe-all` removes them with the data dir. Neither is a forensic erase.
- **Retry cadence is a local traffic-analysis surface.** A queued send re-dials the peer's onion on a backoff schedule while the app runs. An observer of your Tor client (or the network in front of it) sees a repeating connection attempt to one onion on a predictable cadence — it does not learn the plaintext or the recipient identity, but it can infer that you have an undelivered message for someone, and roughly when you composed it. The backoff is per-row, capped at one attempt per 30 min per message, and stops after 8 attempts or on a terminal failure.
The queue is bounded in scope: chat only. File transfer and `rcp` frames are one-shot, so a failed payment claim does not sit in the store being retried forever.
2026-09-10 02:49:42 -04:00
2026-09-17 20:44:28 -04:00
## Reachability: there is no sealed mailbox, and no mutual-online indicator
**No sealed mailbox.** OnionWire does not implement a server-side message store, a sealed mailbox, or any store-and-forward drop. There is no address a peer can write a message to when you are offline, and nothing that holds a message on your behalf after your device is gone. A mailbox of that kind needs a persistent process that accepts and later replays ciphertext for an absent recipient — exactly the hosted store-and-forward server this threat model rules out (“Tor relays are not a chat server”, “Out of v1”). A sealed box whose key never leaves the user's device is still a server holding the traffic pattern and the ciphertext, and it is still a third party that can be compelled, logged, or silently serve a stale box. That is the design decision, and it is not planned as a follow-up.
**The chat outbox is local-device retry only.** A message to an unreachable peer is written to the local `outbox` row and re-dialed from this device. It dies with the device: no relay, no friend, no other install ever holds it. Nothing in the outbox is a delivery guarantee.
**No mutual-online indicator.** OnionWire has no presence, no "peer is online" dot, and no shared online state. Every send is a one-shot Noise IK session to the peer's onion and is closed after one application frame; the peer's availability is only learned from whether * this * dial succeeded. A roster row we have not reached is marked `stale` (from the last connect attempt, `last_connect_ok` ) and the footer states the consequence instead of implying presence: `peer unreachable, queued (n/8, retry …)` while an outbox row is outstanding. "They are offline right now" and "they have never been online since my last attempt" are indistinguishable to OnionWire, and the UI does not pretend otherwise.
**What this costs, stated plainly.** Two devices that are never online at the same time cannot talk, and there is no queue that changes that — the sender's own device is the only queue. Anyone who needs offline delivery must run their own always-on OnionWire install (their own identity, their own onion) to hold the messages, which is a hosted server * they * own and operate, not a service OnionWire provides.
docs: ratchet wire spec + forward-secrecy/PCS threat-model claims
PROTOCOL.md gains a 'Ratchet (v1 chat layer)' section written so a second
implementation can interoperate from the text alone: byte-exact frame layout
(rat , 0x01, dh_pub||N||PN as header and AAD, 12-byte nonce,
ChaCha20-Poly1305), the KDF_RK/KDF_CK constructions and the role-separated
epoch rule, the derived bootstrap epoch, the receive and DH-step rules, the
MAX_SKIP/MAX_SKIPPED_KEYS bounds with the replay rule, the SQLCipher
ratchet_sessions row, and what stays unratcheted.
THREAT_MODEL.md gains the corresponding gains (per-chain forward secrecy, PCS
after a DH step, header not on the wire) and honest limits (skipped-key
window, the prekey-bound bootstrap epoch, no deniability, no one-time
prekeys, compromised endpoint out of scope, no metadata gain, the no-server-
outbox lock untouched) plus the amended transport wording.
README.md documents the operator-visible consequence: no reset command yet,
prekey change / invite re-paste is the only recovery, /wipe keeps the state,
and a desync is currently stderr-only.
2026-09-16 19:40:40 -04:00
## Chat is ratcheted on top of the one-shot Noise session
The Noise IK session is still the transport: handshake, **one ** application
frame, close, one circuit per message. Chat stacks a Double Ratchet * inside *
that frame (`rat ` , [PROTOCOL.md ](PROTOCOL.md )), with per-friend state persisted
in the encrypted store (`ratchet_sessions` ). The ratchet changes what a stolen
chat line is worth; it does not re-open any lock: no relay, no server-side
queue, one frame per Noise session, and the ratchet state never leaves the
device.
**Gains.**
- *Per-chain forward secrecy.* Every message key is `HMAC-SHA256(chain_key,
0x01)` over a chain key that is replaced by ` HMAC-SHA256(chain_key, 0x02)`
after each message, so state recovered after a chain has moved on does not
decrypt the messages already sent on it — outside the skipped-key window
below.
- *Post-compromise security after a DH ratchet step.* An attacker holding a
snapshot of one side's state cannot read the conversation past the next DH
ratchet step: that step feeds a fresh X25519 output into the root, and the
snapshot stops producing chain keys. The window is not zero — it lasts until
the next step — but no attacker can prevent it closing.
- *The ratchet header is not on the wire.* `dh_pub` , `N` and `PN` ride inside
the Noise ciphertext (authenticated as AEAD associated data), so message
counts and ratchet-key changes are not observable, and a tampered header fails
closed.
**Honest limits.**
- *Skipped-key window.* Up to `MAX_SKIP` (2000) message keys of one chain, or up
to `MAX_SKIPPED_KEYS` (2000) entries across a friend, stay decryptable to
whoever holds the state until they are used (deleted on use) or evicted
oldest-first. A snapshot also carries the current sending and receiving chain
keys, which read the current chain until it advances. This is the price of
out-of-order delivery, and it is per friend.
- *The bootstrap epoch is prekey-bound.* The initial root and both initial
ratchet secrets are HKDF outputs of the X25519 DH between the two long-lived
signed prekeys, and the identity pubkeys that separate them are public. An
attacker who has both peers' prekey statics can therefore reconstruct the
**first ** epoch. What that does not buy is a recorded message: every `rat `
frame travels inside a one-shot Noise session whose ephemerals are not derived
from the prekeys, so the prekeys alone do not open stored traffic. From the
first DH ratchet step on, fresh X25519 secrets enter and the prekeys derive
nothing — the bootstrap epoch is the exception, not the rule, and it is the
reason the state is dropped when a peer's prekey changes.
- *No deniability and no non-repudiation claim.* Chat frames are not signed and
both parties derive the same chain keys, so nothing here would let a third
party decide which of the two authored a chat line. Identity is proven per
Noise session (the 96-byte proof), not per message.
- *No one-time prekeys.* The bootstrap epoch uses the long-lived signed prekey
only, so there is no per-session prekey consumption. A peer prekey change
drops the state locally and the next chat frame re-bootstraps; there is no
2026-09-17 20:48:10 -04:00
in-band reset and no key confirmation. The same is true of your **own **
prekey: `F8` rotates it, drops every stored state, and each friend has to
re-paste your invite, because a new prekey is never pushed.
docs: ratchet wire spec + forward-secrecy/PCS threat-model claims
PROTOCOL.md gains a 'Ratchet (v1 chat layer)' section written so a second
implementation can interoperate from the text alone: byte-exact frame layout
(rat , 0x01, dh_pub||N||PN as header and AAD, 12-byte nonce,
ChaCha20-Poly1305), the KDF_RK/KDF_CK constructions and the role-separated
epoch rule, the derived bootstrap epoch, the receive and DH-step rules, the
MAX_SKIP/MAX_SKIPPED_KEYS bounds with the replay rule, the SQLCipher
ratchet_sessions row, and what stays unratcheted.
THREAT_MODEL.md gains the corresponding gains (per-chain forward secrecy, PCS
after a DH step, header not on the wire) and honest limits (skipped-key
window, the prekey-bound bootstrap epoch, no deniability, no one-time
prekeys, compromised endpoint out of scope, no metadata gain, the no-server-
outbox lock untouched) plus the amended transport wording.
README.md documents the operator-visible consequence: no reset command yet,
prekey change / invite re-paste is the only recovery, /wipe keeps the state,
and a desync is currently stderr-only.
2026-09-16 19:40:40 -04:00
- *A compromised endpoint is out of scope.* The ratchet state lives in the same
SQLCipher file as the chat log, under the same passphrase. Anyone who opens
the store holds the roots, both chain keys, the skipped keys and the plaintext
history. `/wipe` clears chat, payments and outbox rows but **keeps ** the
ratchet state (roster and identity stay), so chat resumes on the same epoch;
`/wipe-all` removes the data dir with it.
- *No metadata protection beyond Noise.* One Noise session per message, no
padding: sizes and timing are what they were before the ratchet.
- *The ratchet does not re-open the "no server-side outbox" lock.* The state is
device-local, one row per friend in the encrypted store, and nothing about it
is transmitted. The local retry queue's two accepted consequences (device
seizure, retry cadence) are unchanged.
2026-09-10 14:50:01 -04:00
## Profile is friend-visible, not a directory
A signed `prf` frame is shown to people who already have a session with you. Apply only for existing friends. There is still no name lookup, DHT, or public profile server. Anyone who already has a Noise session can see the profile you send them; that is not confidentiality against that friend.
2026-09-13 23:25:25 -04:00
## Payments are opt-in; spend is a local authority
Chat does not need a wallet. Payment frames (`inv` , `rcp` , `tip` ) are signed
claims over Noise: a signature proves which friend sent the claim, not that
money moved. `verified=1` only after a conjunctive match — one `get_transfers`
row with the same non-empty `txid` , `amount` , and `address` . RPC down, error, or
no exact row → stay `verified=0` . Subaddress reuse is the user’ s wallet policy.
**Default: no spend.** No seed and no spend key on the device. Receive can use
the profile `xmr_addr` , or a view-only wallet (`create_address` /
`get_transfers` only). `/tip` is off (`ONIONWIRE_WALLET_NO_SPEND` , or a
watch-only wallet detected over RPC via `query_key spend_key` → `-29` ).
**Spend is opt-in**, at wallet create or restore, not a hidden default. A
seed-backed spend-capable wallet makes OnionWire a **local spend authority **
for that file: anyone with the wallet passphrase or the wallet-RPC credentials
can move the balance, and `/tip` is a supported way for a chat peer to get paid.
wallet: actually open the wallet file, and remember its passphrase
`monero-wallet-rpc` starts with no wallet open and keeps one only for the
life of its process, so a restart, a Lock/unlock or a wallet re-point left
a live child answering `-13 No wallet file` to every read while the file
sat on disk. The app now opens the configured catalogue file itself
(`Wallet::open_wallet`, over RPC — never `--wallet-file`/`--password` on
argv, which `ps` exposes) after the child is up, and keeps the passphrase
that does it, sealed with the store data key beside the RPC creds under
its own AAD.
- core: `Wallet::open_wallet`, `WalletConfig::wallet_passphrase`
(+ `with_wallet_passphrase`, redacted Debug, kept out of the endpoint
config), `Error::is_unreachable` for the one retryable class (the port
binds a moment after spawn; a timeout is not a start in progress).
- store: `wallet_config.sealed_passphrase` column (additive, AAD
`onionwire-store-v1:wallet-passphrase`), read-modify-written so the
endpoint/login survive; `wallet_save_config` keeps the stored one.
- node: `start_wallet_child` opens the file, `open_wallet_with_passphrase`
opens a file with a passphrase the user just typed and seals it only
once a live daemon accepted it, `wallet_status` grows `wallet_open` and
`needs_passphrase`. A child the RPC refuses is stopped rather than left
inert; an install with no stored passphrase still starts, and says so.
- tui: one-shot prompt (`WalletSetup::UnlockPass`) on a wallet that needs
it, reachable from the saved-wallet picker and from `s`.
- sdk: `openWalletWithPassphrase`, the two status fields, README flow.
- docs: WALLET/THREAT_MODEL/README — the passphrase is kept, and the
consequence (the store passphrase is sufficient to spend) is stated
rather than implied.
Tests: 4 new node tests drive a real child lifecycle against a loopback
wallet RPC (open on restart, no open without a passphrase, refused
passphrase, sealed-on-success), a `tests/wallet.rs` test asserts the bytes
sent (`open_wallet` + filename + password), and `tests/store.rs` covers
the sealed column and the plaintext->encrypted upgrade with it set.
Mutation-checked: stubbing the two open paths fails all four.
2026-09-22 12:52:08 -04:00
Those credentials are sealed with the store data key (SQLCipher plus a per-row
AEAD), and so is the **wallet-file passphrase ** : it is kept in the same sealed
row, because `monero-wallet-rpc` holds a wallet only for the life of one process
and reopening the file needs it. That is a deliberate decision with a real
consequence — **whoever can unlock the store can spend ** : the store passphrase
(or its Keystore wrapper) is now sufficient, and there is no second secret
standing between a seized unlocked device and the wallet's balance. Nothing else
changes: `/tip` still refuses on a view-only wallet before any dial, the
spend-authority warning is still unavoidable at create/restore, the passphrase is
never logged, never in an error string and never on a process argv, and `/wipe`
keeps the wallet file and its passphrase exactly as it kept the file before.
2026-09-13 23:25:25 -04:00
The spend-authority warning is unavoidable at that create/restore step. Loopback
binding is not an authorization boundary. Back up the seed; do not leave a
spend-capable wallet on a device you do not trust; a separate hot wallet with a
small balance is the sane spend shape, not savings.
The app talks to `monero-wallet-rpc` over **loopback HTTP Digest ** only
(`--rpc-login` required; open RPC refused). That process may be one the user
already runs, or one the app spawns. Wallet RPC is never dialed over clearnet or
over `.onion` — a remote wallet RPC would move spend authority off the box
through a channel the messenger’ s `--password` gate does not cover.
wallet: optional seed-offset passphrase on import
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.
2026-09-25 00:42:44 -04:00
**The seed-offset passphrase is a second spend secret, and it is not stored.**
An import may be given Monero's optional `seed_offset` : a phrase mixed into the
25 words at restore time, so the same words with a different offset open a
different wallet (plausible deniability). It is typed once, travels only in the
JSON-RPC body (never argv, never logged, never an error string), is never sealed
and never persisted — storing it would defeat the point. It is also not a second
gate on an already-imported wallet: whoever can unlock the store can still spend
the opened file, because the wallet file's own passphrase * is * sealed (previous
paragraph). A wrong offset is silent — the RPC succeeds and the wallet is
simply a different one — so the app cannot warn about it, and after such an
import a later seed backup is the * derived * mnemonic, which opens the wallet
without the offset.
2026-09-13 23:25:25 -04:00
### Chain source is the user’ s choice
Scan, receipt verification, and spend need a Monero daemon. The user picks one;
the app does not pick a public remote node for them.
1. **Spawn a local `monerod` ** (pruned is the on-device target). Chain traffic
stays on the device. The user accepts disk (tens of GB for a pruned mainnet
node), first-sync time, and — on Android — process kills: the daemon is not
always running. A pruned node is not an archive. Seed restore of deep history
can degrade; once the wallet has scanned, its own cache is the history.
Unsynced or not running is an honest “not ready” / unverified state, not a
fake success.
2026-10-08 10:59:45 -04:00
2. **An in-process daemon ** (Cuprate, behind the `cuprate-daemon` feature, on in
the Linux TUI/release binary; a `--no-default-features` build does not
include it). P2P, consensus and RandomX run in the OnionWire process; nothing is
wallet: land the in-process Cuprate chain source on main
`ChainSource::InProcessCuprate { datadir }` is the fourth chain source: P2P,
consensus and RandomX run inside the OnionWire process instead of as a spawned
`monerod`. The wallet layer does not move — the daemon binds the same loopback
unrestricted RPC (`127.0.0.1:18081`) that `WalletChild::daemon_address` already
returns for a local source, so `wallet_rpc_argv`, the RPC client, the payment
frames and the receipt-verification path are untouched.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind the
`cuprate-daemon` feature, OFF by default. `cuprated`'s own `arti` feature is
disabled (`default-features = false`): its arti-client 0.44 cannot unify with
this crate's 0.46, and the in-process daemon is clearnet-only. One Tor stack in
the process. `Cargo.lock` gains the graph; a default build's
`cargo tree --locked -e normal -i cuprated` still says "did not match any
packages", and only `arti-client v0.46.0` is in the lock.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it on a runtime it owns, and owns the node. `launch` is
synchronous on purpose: `WalletChild::start` is sync (the TUI calls it from its
blocking thread, UniFFI calls it from an async context) and a runtime cannot be
started from inside a runtime, so the launch runs on a thread of its own and
the node + its runtime come back over a channel. Dropping the value asks the
node to shut down and `shutdown_background`s the runtime, which is the only
exit that cannot panic when the value is dropped inside another runtime.
The type exists in every build (feature off: `launch` fails with the feature
name), so the chain-source type, its stored record and its copy do not fork on
a cargo feature.
- src/wallet.rs: the variant, its label (`in-process node`), and the chain-daemon
client the wallet line carried (typed `WalletError`, de-chunked HTTP,
`get_height` over the URI endpoint, an above-the-tip height as one typed
error). Cuprate answers those three differently from monerod and the
in-process source is what makes them the *local* case.
- src/wallet_child.rs: launches/holds/stops the node, `chain_datadir` for the
free-space/ownership question, the honest `chain_copy` line, `kind =
"cuprate"` in the sealed record, and `ChildConfig::validate` for it.
- src/tui.rs: the wallet screen's chain line carries the testnet caveat when the
configured source is the in-process one. It computes the line at draw time, so
`Screen::Wallet`'s shape (which tests construct) does not change.
- docs/WALLET.md, docs/THREAT_MODEL.md, docs/cuprate-android-spike.md: the
feature flag and how to enable it, where the (fjall) chain store lives, the
**measured** +11.8 MiB delta, the pre-production/testnet caveat, and the
in-repo aarch64-linux-android proof with exit codes.
Scope deviations, stated plainly:
- `src/cuprate.rs` and its one `src/lib.rs` module line are not in the card's
allowed list; the card's own deliverable describes the module's behaviour.
- `crates/onionwire-sdk/src/lib.rs` is forbidden, but adding a variant to a
`pub enum` that the SDK matches exhaustively breaks the SDK workspace, and the
root CI `sdk` job runs on every PR. One variant plus two match arms land here
so the SDK keeps compiling (`cargo test --locked` + clippy clean); the SDK card
owns the rest — feature passthrough, the config field's semantics, the label
and its tests, and the Android check.
- `tests/wallet.rs` carries the launch test. `tests/tui_frames.rs` is untouched:
main has no `ChainChoice` to pin (the chain-source picker is the unmerged F7
work, and `docs/WALLET.md` says so rather than describing a picker that does
not exist).
Proof (all on this tree):
- Default build: `cargo test --locked --target x86_64-unknown-linux-gnu` → 345
passed / 0 failed across 33 suites, exit 0; `cargo clippy --locked
--all-targets --target x86_64-unknown-linux-gnu -- -D warnings` exit 0.
- Feature on: `cargo test --locked --features cuprate-daemon --target
x86_64-unknown-linux-gnu` → 347 passed / 0 failed, exit 0; same clippy with
`--features cuprate-daemon` exit 0. The two extra tests are the real thing:
`wallet_child::tests::in_process_source_launches_a_daemon_and_stop_shuts_it_down`
and `tests/wallet.rs::an_in_process_cuprate_node_answers_the_typed_daemon_client`
— the latter launches the node, drives `get_info` / `get_height` / `get_block`
through the typed client, checks the above-the-tip 500 maps to
`DaemonHeightOutOfRange`, checks the chain store is under the chain datadir,
and checks the listener dies with the node.
- aarch64: `cargo check --locked --release --target aarch64-linux-android
--features cuprate-daemon` exit 0 (1m 50s), and the full link exit 0
(`cargo rustc ... --bin onionwire -- <NDK C++ runtime / compiler-rt link
args>`) producing `ELF 64-bit LSB pie executable, ARM aarch64, for Android 26,
built by NDK r28c`.
- Size: stripped aarch64 release binary, 24,725,704 bytes without the feature and
37,053,472 with it — +12,327,768 bytes (≈ +11.8 MiB), the figure
`docs/WALLET.md` now quotes.
2026-09-18 13:45:59 -04:00
spawned and nothing leaves the device except the chain P2P traffic itself.
What that changes: there is **no daemon operator ** to trust — your own process
is the daemon, so the "operator sees your addresses" question does not exist.
The spend key, the chain, and the messenger are then all on one device.
What it does not change: the **device is now the trust root for chain data ** .
Chain state is only as trustworthy as the binary running it, and a
compromised device corrupts the chain view along with everything else.
Honest limits, stated here rather than in a footnote:
- Cuprate is **pre-production ** . Its own user book says *"do NOT use cuprated
for any serious purposes"*, and its `monerod` RPC parity is incomplete
(Cuprate issue #278 ). This is why the source is an opt-in build feature and
a stored user choice, never a default.
2026-09-20 00:31:07 -04:00
- Mainnet is **unvalidated ** . The TUI can store a mainnet choice (`F6` 1/2);
every in-process surface still says `testnet only — mainnet is unvalidated` .
Cross-compiled is not device-proven.
wallet: land the in-process Cuprate chain source on main
`ChainSource::InProcessCuprate { datadir }` is the fourth chain source: P2P,
consensus and RandomX run inside the OnionWire process instead of as a spawned
`monerod`. The wallet layer does not move — the daemon binds the same loopback
unrestricted RPC (`127.0.0.1:18081`) that `WalletChild::daemon_address` already
returns for a local source, so `wallet_rpc_argv`, the RPC client, the payment
frames and the receipt-verification path are untouched.
- Cargo.toml: `cuprated` (git, rev 4f8fcd1b) + `toml`, both optional, behind the
`cuprate-daemon` feature, OFF by default. `cuprated`'s own `arti` feature is
disabled (`default-features = false`): its arti-client 0.44 cannot unify with
this crate's 0.46, and the in-process daemon is clearnet-only. One Tor stack in
the process. `Cargo.lock` gains the graph; a default build's
`cargo tree --locked -e normal -i cuprated` still says "did not match any
packages", and only `arti-client v0.46.0` is in the lock.
- src/cuprate.rs (new): `CuprateNode` builds the cuprated config as TOML
(testnet, unrestricted RPC on loopback, restricted RPC disabled, inbound P2P
off), launches it on a runtime it owns, and owns the node. `launch` is
synchronous on purpose: `WalletChild::start` is sync (the TUI calls it from its
blocking thread, UniFFI calls it from an async context) and a runtime cannot be
started from inside a runtime, so the launch runs on a thread of its own and
the node + its runtime come back over a channel. Dropping the value asks the
node to shut down and `shutdown_background`s the runtime, which is the only
exit that cannot panic when the value is dropped inside another runtime.
The type exists in every build (feature off: `launch` fails with the feature
name), so the chain-source type, its stored record and its copy do not fork on
a cargo feature.
- src/wallet.rs: the variant, its label (`in-process node`), and the chain-daemon
client the wallet line carried (typed `WalletError`, de-chunked HTTP,
`get_height` over the URI endpoint, an above-the-tip height as one typed
error). Cuprate answers those three differently from monerod and the
in-process source is what makes them the *local* case.
- src/wallet_child.rs: launches/holds/stops the node, `chain_datadir` for the
free-space/ownership question, the honest `chain_copy` line, `kind =
"cuprate"` in the sealed record, and `ChildConfig::validate` for it.
- src/tui.rs: the wallet screen's chain line carries the testnet caveat when the
configured source is the in-process one. It computes the line at draw time, so
`Screen::Wallet`'s shape (which tests construct) does not change.
- docs/WALLET.md, docs/THREAT_MODEL.md, docs/cuprate-android-spike.md: the
feature flag and how to enable it, where the (fjall) chain store lives, the
**measured** +11.8 MiB delta, the pre-production/testnet caveat, and the
in-repo aarch64-linux-android proof with exit codes.
Scope deviations, stated plainly:
- `src/cuprate.rs` and its one `src/lib.rs` module line are not in the card's
allowed list; the card's own deliverable describes the module's behaviour.
- `crates/onionwire-sdk/src/lib.rs` is forbidden, but adding a variant to a
`pub enum` that the SDK matches exhaustively breaks the SDK workspace, and the
root CI `sdk` job runs on every PR. One variant plus two match arms land here
so the SDK keeps compiling (`cargo test --locked` + clippy clean); the SDK card
owns the rest — feature passthrough, the config field's semantics, the label
and its tests, and the Android check.
- `tests/wallet.rs` carries the launch test. `tests/tui_frames.rs` is untouched:
main has no `ChainChoice` to pin (the chain-source picker is the unmerged F7
work, and `docs/WALLET.md` says so rather than describing a picker that does
not exist).
Proof (all on this tree):
- Default build: `cargo test --locked --target x86_64-unknown-linux-gnu` → 345
passed / 0 failed across 33 suites, exit 0; `cargo clippy --locked
--all-targets --target x86_64-unknown-linux-gnu -- -D warnings` exit 0.
- Feature on: `cargo test --locked --features cuprate-daemon --target
x86_64-unknown-linux-gnu` → 347 passed / 0 failed, exit 0; same clippy with
`--features cuprate-daemon` exit 0. The two extra tests are the real thing:
`wallet_child::tests::in_process_source_launches_a_daemon_and_stop_shuts_it_down`
and `tests/wallet.rs::an_in_process_cuprate_node_answers_the_typed_daemon_client`
— the latter launches the node, drives `get_info` / `get_height` / `get_block`
through the typed client, checks the above-the-tip 500 maps to
`DaemonHeightOutOfRange`, checks the chain store is under the chain datadir,
and checks the listener dies with the node.
- aarch64: `cargo check --locked --release --target aarch64-linux-android
--features cuprate-daemon` exit 0 (1m 50s), and the full link exit 0
(`cargo rustc ... --bin onionwire -- <NDK C++ runtime / compiler-rt link
args>`) producing `ELF 64-bit LSB pie executable, ARM aarch64, for Android 26,
built by NDK r28c`.
- Size: stripped aarch64 release binary, 24,725,704 bytes without the feature and
37,053,472 with it — +12,327,768 bytes (≈ +11.8 MiB), the figure
`docs/WALLET.md` now quotes.
2026-09-18 13:45:59 -04:00
- Cuprate's own `arti` feature is off (its Tor stack is `arti-client` 0.44,
which cannot unify with this crate's 0.46), so the in-process daemon's P2P
traffic is **clearnet ** : your ISP sees that this device talks to Monero
peers. No Tor is on the chain path — Tor is the messenger's transport here,
not the chain's.
- Inbound P2P is off and the restricted RPC listener is disabled; the
unrestricted RPC binds loopback only, and it is the address the wallet
child dials. `--trusted-daemon` is still never passed.
- The chain database is a separate embedded store (fjall) under the chain
data directory, not the SQLCipher store the messenger writes — different
file, different exposure: it is not encrypted by that store's key.
3. **A daemon address they supply. ** The wallet child points `--daemon-address`
2026-09-13 23:25:25 -04:00
at that host. Trust follows the address:
- **Loopback** — same privacy as (1); the user owns `monerod` .
- **`.onion` ** — chain traffic over Tor through a localhost SOCKS5 listener
the app provides for the wallet child (not the messenger’ s Arti
2026-09-15 01:40:12 -04:00
`connect()` , and not a C-tor fallback for chat). That listener is the
bundled `arti` **binary ** run as a child (`arti proxy -p <port>` ) — a
second, separate Tor client with its own state and cache dirs, because
`arti-client` 0.46 exposes no SOCKS listener API. It is TCP loopback only
(`arti proxy -p` binds `127.0.0.1` /`::1` ; arti 2.6.0 / `tor-config` 0.46
have no Unix-socket listen target — arti#1965 ), and the port is usable by
any local process at the user's privilege level: it is an app-private port,
not an access-controlled one. The app gates the spawn on the unlocked store
and waits ≤20s for the listener to accept before starting the wallet child,
so a dead proxy fails visibly instead of hanging. The SOCKS child stops
with the wallet child. Tor hides the transport.
2026-09-13 23:25:25 -04:00
The daemon operator still sees the wallet’ s addresses during sync. The
host is the trust boundary.
- **Clearnet** — only if the user typed it. Not a default, not implied.
The ISP sees Monero-node traffic; the daemon operator sees addresses. Show
that trust shift before using the address.
Remote daemons are untrusted (`--trusted-daemon` off). Setup, view-only vs
spend, and RPC credentials: [WALLET.md ](WALLET.md ).
wallet: no-spend mode + view-only detection over RPC
/tip needs monero-wallet-rpc `transfer`, which a view-only wallet cannot do.
With ONIONWIRE_WALLET_NO_SPEND=1 (`1`/`true`/`yes`/`on`) `Wallet::transfer`
refuses locally, before any RPC dial, and /pay + receipt verification are
unchanged.
When a transfer does fail, ask the documented signal before surfacing the raw
wallet error: `query_key` key_type=spend_key answers
WALLET_RPC_ERROR_CODE_WATCH_ONLY (-29) on a view-only wallet
(wallet_rpc_server.cpp on_query_key). Both paths return one sentence —
"wallet is in view-only/no-spend mode — /tip is disabled; /pay and receipt
verification still work". Fail closed: if the probe cannot answer, the wallet's
own error stands; no fabricated detection.
New docs/WALLET.md: --generate-from-view-key / generate_from_keys watch-only
setup, --rpc-login Digest, why loopback still needs auth, the local
spend-authority warning, and the detection trade-off (a spend-capable wallet
answers the probe with its spend key, which is discarded). Linked from
docs/THREAT_MODEL.md.
2026-09-12 12:59:49 -04:00
sdk: expose the wallet catalogue, the open wallet's keys, and the self profile
The Android wallet/profile screens had nothing to call: the core could list
wallets, switch the child onto one, read its keys and read/write the self
profile, but none of it crossed UniFFI.
Core:
- Wallet::keys() -> WalletKeys { view_key, spend_key: Option<String> }: two
query_key calls against the file the RPC has open. A view-only wallet's -29
is spend_key: None, not an error. WalletKeys' Debug redacts both halves.
- Node::wallet_keys() mirrors wallet_create/wallet_seed; refuses locally when
no wallet is configured.
- Node::active_wallet_filename() -> Option<String>: the file the child is
pointed at, None until wallet-child settings exist, so a client can mark the
open row.
SDK (UniFFI):
- records WalletRow / WalletKeys / SelfProfile, and Wire::{wallets,
open_wallet, active_wallet_filename, wallet_keys, self_profile,
set_self_profile, push_self_profile}.
- The rule the clients must express is in the docs: the seed and the private
keys come from the OPEN wallet, so there is deliberately no accessor that
reads another saved wallet's secrets without opening it.
docs/WALLET.md (catalogue + 'secrets belong to the open wallet'),
docs/THREAT_MODEL.md (the new on-demand-display exposure surface) and the SDK
README are updated in the same commit.
2026-09-22 00:25:33 -04:00
## The recovery phrase and the private keys are displayable on demand
Both clients can show the **open ** wallet's recovery phrase (`query_key
mnemonic`) and its private view and spend keys (` query_key view_key` /
`spend_key` ), from an explicit user action. That is new exposure the threat model
did not previously enumerate: the phone screen — and the Linux TUI window — is
now one of the places a spending secret can be read from.
- The values come from the wallet file the child has **open ** . There is no path
that reads another saved wallet's secret without opening it first, and none
that reads a wallet file directly: the RPC is the only source.
- They are never logged, never written to the store or any other file, and never
placed in an error string; the records that carry them (`WalletKeys` ) redact
themselves under `Debug` . They exist in process memory only while a screen
shows them.
- They are shown only from an explicit user action, never on a refresh path.
- What this does **not ** stop: a shoulder-surfer, a screen recorder, a
screenshot, or a malicious app with screen-capture permission. Whoever reads
the screen gets the keys; a view-only wallet leaks only the view key
(`spend_key` is `None` ), but a spend-capable one leaks everything the file can
spend.
- The spend-authority warning above still applies and is now easier to reach:
the seed that makes a wallet spend-capable can be photographed off the device.
Treat any screen that shows a seed or a private key the way you treat the
wallet file itself.
2026-09-10 14:50:01 -04:00
## Backup file is the identity
`/backup` writes the identity and Noise static secrets. Treat the file like `onionwire.db` . Restore overwrites self keys and does **not ** rewrite the friends table.
## Rate limit is availability, not anonymity
2026-09-11 23:49:29 -04:00
Incoming rendezvous accepts are token-bucket limited (30/60s, burst 10). Excess is dropped without handshake. That is a DoS/availability control. It does not hide that you run an onion, and it is not a traffic-analysis defense. The constants are unchanged. Clients absorb the cost: file senders pace and retry chunks to fit this budget. The accept loop does not distinguish a friend from a flood.
2026-09-10 14:50:01 -04:00
2026-09-11 13:15:51 -04:00
## Network (UDP / clearnet)
The application does not open UDP sockets and does not resolve friends via
2026-09-13 23:25:25 -04:00
system DNS. Peer dials are Arti `connect((onion, 80))` only.
Wallet **RPC ** (HTTP Digest to `monero-wallet-rpc` ) is loopback TCP only
(numeric `127.0.0.1` / `::1` preferred; `localhost` still does `getaddrinfo` ).
That socket is the app talking to the wallet process, not to the chain.
**Chain** traffic is the wallet child’ s connection to a Monero daemon. It is
off unless the user opted into a wallet and chose a chain source: spawned local
`monerod` (loopback), or a daemon address they entered. A `.onion` daemon is
2026-09-15 01:40:12 -04:00
reached through a localhost SOCKS5 proxy used only by that wallet child: the
bundled `arti` binary run as `arti proxy -p <port>` , whose `--proxy` target is
`127.0.0.1` and whose `.onion` name travels inside the SOCKS request (Monero's
SOCKS5 client sends the domain-name form, so no local DNS runs on it). The
messenger's in-process Arti client is never handed to the wallet child. A
2026-09-13 23:25:25 -04:00
clearnet daemon address is an explicit user choice — a clearnet socket they
asked for — not the messenger path and not a hidden default.
Do not add STUN/ICE/WebRTC, a DHT, SOCKS/C-tor fallback for **peer dials ** , or
“direct TCP when the onion is slow.” Those are the Tox-over-Tor leak class. A
SOCKS listener used only by the wallet child to reach a user-chosen `.onion`
daemon is not that class.
2026-09-11 13:15:51 -04:00
2026-09-11 23:42:48 -04:00
## Peer text is untrusted display data
Chat bodies and `fil ` names come from a Noise peer, not from the local user.
They are display data, not terminal commands. A friend (or anyone who stole
that session) can put ESC/CSI/OSC, C1 controls, or bidi overrides in a
payload. OnionWire strips those at ingest (so sqlite history is clean) and
again at TUI render (so rows written before this rule stay inert). Filenames
that contain the same characters are rejected, not rewritten. This is a
UI-redressing / terminal-injection boundary, not a confidentiality control:
the peer already knows the plaintext they sent.
2026-09-10 02:49:42 -04:00
## Out of v1
2026-09-17 20:44:28 -04:00
Prosody, XMPP, s2s, MAM, carbons, a **sealed mailbox ** , a **server-side **
outbox / store-and-forward relay, multi-device, DHT / name server, A/V. The
local retry queue of the previous section is not an outbox in the XMPP sense: it
never leaves the device, and it is not a mailbox either — see “Reachability”.
feat(outbox): local retry queue for chat sends
Queue a chat send locally when the peer's v3 onion is unreachable and retry
it with exponential backoff (30s doubling, capped at 30 min, 8 attempts then
terminal Failed). Still peer-to-peer: no server, no store-and-forward relay,
no new frame prefix — every attempt is a fresh Noise IK handshake.
- src/outbox.rs: Outbox + Deliverer + ArtiDeliverer, pure backoff_secs(),
is_permanent_send_error(), background worker (15s scan).
- store: `outbox` table (no body column — the body is read from the joined
messages row, under that row's existing AEAD + AAD), append_message_id(),
queue/due/pending/mark_* helpers, reset_sending_outbox(), wipe.
- Node::send() returns Result<OutboxStatus, String> (Sent/Queued) instead of
Err on transport failure; protocol errors still fail immediately and are
never queued.
- Retry triggers: timer, unlock/foreground (spawn_flush_all), and "that peer
was just seen" (handshake or connect_onion -> spawn_flush_friend).
- File transfer and payment/rcp frames stay fail-closed.
- docs/PROTOCOL.md + docs/THREAT_MODEL.md: replace the no-queue statements;
add the seizure/cadence delta to the threat model.
src/tui.rs gets one forced arm change (Ok(()) -> Ok(_)); UI surfacing is
child card t_d9a5b065.
2026-09-12 13:35:10 -04:00