From 7f3ef8c3fc3af6c9b35a09e75f7920059560f9da Mon Sep 17 00:00:00 2001 From: agent Date: Wed, 16 Sep 2026 19:40:40 -0400 Subject: [PATCH 1/2] 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. --- README.md | 36 ++++++- docs/PROTOCOL.md | 232 ++++++++++++++++++++++++++++++++++++++++++- docs/THREAT_MODEL.md | 71 ++++++++++++- 3 files changed, 335 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 098569c..2c6307a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Lean Tor messenger: one Rust process (ratatui + Noise IK + sqlite + in-process Arti). No hosted server. Identity is a public key; the onion is only a locator. -**v0.2.1** — Linux TUI + Android SDK/APK. Two people add each other with an `onionwire:v1:…` invite string (`F2` share / `F3` paste). There is no QR graphic. Chat is Noise IK over your own v3 onion. Unreachable chat peers go to a **local outbox** (device-only retry queue — no relay); file transfer and payment frames still fail closed. Optional Monero payments: `/pay` invoices (receive), `/tip` payments (send), and a full in-app wallet create/import (`F6` wallet screen, `/wallet create`, `/wallet import`). Arti onion services are still experimental. The whole store is encrypted at rest with SQLCipher; message bodies add a row-bound AEAD layer on top. +**v0.2.1** — Linux TUI + Android SDK/APK. Two people add each other with an `onionwire:v1:…` invite string (`F2` share / `F3` paste). There is no QR graphic. Chat is Noise IK over your own v3 onion, and every chat message is ratcheted inside that session. Unreachable chat peers go to a **local outbox** (device-only retry queue — no relay); file transfer and payment frames still fail closed. Optional Monero payments: `/pay` invoices (receive), `/tip` payments (send), and a full in-app wallet create/import (`F6` wallet screen, `/wallet create`, `/wallet import`). Arti onion services are still experimental. The whole store is encrypted at rest with SQLCipher; message bodies add a row-bound AEAD layer on top. You do **not** install a `tor` daemon, `torrc`, Prosody, or XMPP. OnionWire embeds Arti and publishes its own v3 onion. @@ -185,6 +185,40 @@ Still **fail closed** (no queue, no retry): - Arti cannot publish the onion (no C-tor fallback) - no DHT, no name server, no hosted chat server +## Chat ratchet (per friend, on device) + +Chat is ratcheted on top of the Noise session: each chat send is +Double-Ratchet encrypted first, and the resulting `rat ` frame is what the +one-shot Noise session carries. Forward secrecy is per chain, and a snapshot of +one side's state stops reading the conversation at the next DH ratchet step. +The wire format and the honest limits are in +[docs/PROTOCOL.md](docs/PROTOCOL.md) and +[docs/THREAT_MODEL.md](docs/THREAT_MODEL.md). + +- Per-friend state lives in the encrypted store (`ratchet_sessions`, one row per + friend). Nothing about it is transmitted, so the "no relay, no server queue" + rule is unchanged. +- Message numbers, ratchet keys and chain state ride *inside* the Noise + ciphertext; there is nothing new to observe on the wire. +- **Only chat is ratcheted.** `loc`, `prf`, `inv`, `rcp`, `tip` and file chunks + keep the one-shot Noise shape. +- Out-of-order delivery works (bounded skipped keys: 2000 per chain jump, 2000 + stored, oldest-first eviction; a used key is deleted, so a replay fails + closed). A queued chat message re-sends the *same* `rat ` frame, so an outbox + retry never burns a second chain key. +- `/wipe` clears chat, payments and outbox rows but **keeps** the ratchet state + (roster and identity stay), so chat continues on the same epoch. `/wipe-all` + removes the data dir and the state with it. +- **Session reset.** There is no `/reset` command and no in-band reset in + v0.2.1. The state is dropped automatically when the friend's prekey changes — + i.e. when you `F3`-paste a refreshed invite — and the next chat frame + bootstraps a fresh epoch. That re-paste is the only recovery path today. +- **Desync today is quiet.** An inbound `rat ` frame that does not authenticate + is logged as `rat dropped ()` on stderr and dropped: no chat row, no + TUI marker, nothing stored. A send-side failure surfaces as the usual + `send failed: …` status note. There is no in-app "ratchet desynced" banner + yet, so a desync is diagnosed from the terminal the app was started in. + ## File transfer `/file /path` sends a local file to the selected friend. Both must be online. diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md index e93943f..6bd1383 100644 --- a/docs/PROTOCOL.md +++ b/docs/PROTOCOL.md @@ -142,14 +142,21 @@ After decrypt, classify the plaintext: | `rcp ` | Monero receipt claim | drop | | `png ` | ping (reserved) | drop | | `fil ` | file chunk | drop | +| `rat ` | Double Ratchet chat frame (see Ratchet) | drop | | `[a-z][a-z][a-z] ` | unknown typed frame | **drop** (not chat) | | anything else | chat | store as a chat line | +`rat ` is classified before the `[a-z]{3} ` catch-all, so a peer that does not +implement the ratchet drops a chat frame instead of rendering ciphertext as a +chat line. Older builds that stored `rat `-prefixed bytes as chat are obsolete; +upgrade both sides. + A peer that does not implement a typed prefix MUST still drop `[a-z]{3}…` rather than render it as chat. Mixed-version 0.1.2 clients that stored those as chat are obsolete; upgrade both sides. -Chat MUST NOT begin with three lowercase ASCII letters and a space. +Chat MUST NOT begin with three lowercase ASCII letters and a space. (Inside a +`rat ` frame the plaintext is a chat line and is not re-classified.) Hex on the wire is lowercase on encode; decode accepts either case. No `0x` prefix. @@ -303,6 +310,11 @@ is a chat line `[file] name (N bytes)`, never the raw frame. ### Chat +A chat send is ratcheted: the wire form of a chat message is a `rat ` frame +(see “Ratchet (v1 chat layer)”), and the plaintext inside that frame is the chat +line below. A bare chat frame with no typed prefix is still accepted inbound as +a chat line (v0.2.1 peers), but MUST NOT be emitted. + UTF-8 is not enforced for chat text: invalid bytes become U+FFFD (the implementation does not drop the row). Control and bidi formatting characters are stripped at ingest and at render: C0 0x00–0x1F except @@ -312,6 +324,221 @@ so emoji sequences stay intact. `fil ` filenames must not contain those characters (tab and newline included). Displayed as a line. No length limit beyond the frame cap. +## Ratchet (v1 chat layer) + +Chat is the only application payload that is ratcheted. A chat send is +Double-Ratchet encrypted first, and the resulting `rat ` frame is the +application plaintext that a normal one-shot Noise session carries (handshake, +one application frame, close — see Transport). Nothing else changes about the +session. + +The ratchet header is **inside** the Noise transport message, never in clear on +the wire. That is a deliberate divergence from the shape this layer came from: +the plan assumed a plaintext header (`dh_pub || N || PN`) ahead of the +ciphertext, which was rejected because a plaintext header would hand an observer +per-message counters and ratchet-key changes for no benefit — the Noise session +already hides the frame, so the header is authenticated as AEAD associated data +instead. + +### Frame + +``` +"rat " 4 bytes (0x72 0x61 0x74 0x20) +version 1 byte 0x01 +header 40 bytes dh_pub[32] || N uint32 BE || PN uint32 BE +nonce 12 bytes random, per message +ciphertext n+16 ChaCha20-Poly1305 ciphertext || tag +``` + +- `dh_pub` — the sender's current ratchet public key (X25519, 32 bytes). +- `N` — the index of this message in the sender's current sending chain, + counting from 0. +- `PN` — how many messages the sender sent in its *previous* sending chain. +- Associated data is the 40-byte header, exactly as serialized above + (`dh_pub || N as u32 BE || PN as u32 BE`). A tampered `dh_pub`, `N` or `PN` + therefore fails closed. +- The ChaCha20-Poly1305 key is the message key from `KDF_CK`. The 12-byte nonce + is random per message, not a chain counter. +- Minimum frame (empty plaintext) is 73 bytes: 5 + 40 + 12 + 16. +- A receiver MUST reject a frame without the `rat ` prefix, a version other than + `0x01`, or less than 73 bytes. +- The frame must fit the Noise body cap (65535 bytes, including the 16-byte + Poly1305 tag), so a `rat ` frame is at most 65519 bytes. + +Because the header rides inside Noise, an observer sees one opaque ciphertext +per message: no message counts, no ratchet keys, and nothing that marks a first +message of a chain versus a later one. + +### KDFs + +Signal's constructions, unchanged: + +``` +KDF_RK(root, dh_out): + okm = HKDF-SHA256(salt = root, ikm = dh_out, + info = "onionwire-ratchet-v1-kdfrk", L = 64) + new_root = okm[0..32] + chain_key = okm[32..64] + +KDF_CK(chain_key): + message_key = HMAC-SHA256(chain_key, 0x01) + next_chain_key = HMAC-SHA256(chain_key, 0x02) +``` + +`HKDF` is RFC 5869 with SHA-256 (`hkdf` 0.12), `HMAC` is SHA-256 (`hmac` +0.12). Each side of an epoch derives its chains from one shared DH output with +`KDF_RK` called **twice**: + +``` +epoch_chains(root, shared) -> (new_root, ck_lo, ck_hi): + (root1, ck_lo) = KDF_RK(root, shared) + (root2, ck_hi) = KDF_RK(root1, shared) + new_root = root2 +``` + +`lo` is the lexicographically lower of the pair's two ratchet public keys and +`hi` the higher, comparing the 32 raw bytes. The chain a peer sends on is +`ck_lo` if `sender_pub <= receiver_pub`, else `ck_hi`; the receiving chain is the +other one. The epoch's chains are a pure function of the *unordered* pair, and +the second `KDF_RK` call's root is the epoch's new root. + +### Bootstrap + +The bootstrap epoch is derived, never exchanged: the Noise handshake is frozen +and carries no payload, so there is no wire field to hand over an initial +ratchet public key. Both peers instead derive it from key material they already +have from the invite/roster (identity pubkey and signed prekey): + +``` +shared = X25519(my_prekey_sk, peer_prekey_pk) // 32 bytes +hk = HKDF-SHA256(salt = "onionwire-ratchet-v1-bootstrap", + ikm = shared) +root_key = hk.expand("root", 32) +my_secret = hk.expand("ratchet-key" || my_identity_pk, 32) +peer_secret = hk.expand("ratchet-key" || peer_identity_pk, 32) + +state = bootstrap(root_key, my_keypair(my_secret), X25519_pub(peer_secret)) +``` + +`HKDF.expand` above is the RFC 5869 expand step (no second extract). The two +identity public keys are public (invite/roster), so either peer computes its own +secrets and the peer's, and both agree with no new wire field. Then: + +``` +shared = DH(my_secret, remote_pub) +(new_root, ck_lo, ck_hi) = epoch_chains(root_key, shared) +send_ck = chain_for(my_pub, remote_pub) // ck_lo or ck_hi +recv_ck = chain_for(remote_pub, my_pub) +send_n = recv_n = 0, PN = 0, established = false +``` + +Fresh entropy enters at the first DH ratchet step; the bootstrap epoch itself is +prekey-bound (see [THREAT_MODEL.md](THREAT_MODEL.md)). + +**Convergence when both peers send first.** Either peer may send immediately on +the bootstrap epoch, so two peers can each build a sending chain before either +has received anything. Because the epoch's two chains come from the unordered +pair, both derive both directions and each sends on its own, with no +initiator/responder role. The only tie-break needed is for the *first* rotation: +the peer whose ratchet public key is lexicographically lower rotates — but only +after it has received a bootstrap-epoch frame (see `established` below); the +other adopts that new key as a normal DH step and only then rotates. From the +second epoch on, every rotation is a reply to an adopted key, so no tie-break is +needed and the ratchet alternates. + +**Why it stays in lockstep.** A DH ratchet step happens only on a frame whose +`dh_pub` has not been adopted yet, and the side that steps is the side that +receives. A peer cannot rotate twice without having received the other side's +rotation first, so at most one rotation is ever in flight, and both peers feed +`KDF_RK` the same `(root, dh)` pairs in the same causal order. + +### Receiving + +On a decrypted `rat ` frame (the outer Noise session has already been verified, +so the peer identity is pinned): + +1. Parse; reject bad prefix, version or a frame under 73 bytes. +2. If `(dh_pub, N)` is in the skipped-key store: open with that key, **delete it** + from the store, deliver. A replay of the same frame then fails closed because + the key is gone. +3. Else if `dh_pub` equals the adopted remote ratchet public key, this is the + current receiving chain: + - `N < recv_n` → reject (message key already used). + - `N - recv_n > MAX_SKIP` → reject. + - Derive message keys for `recv_n .. N` into the skipped store, derive the + key for `N`, open, set `recv_n = N + 1`. + - On the *first* frame received in this state (`established == false`): set + `established`, and if `my_pub < remote_pub`, rotate the sending chain + (fresh keypair; `epoch_chains(root, DH(new_secret, remote_pub))`; new + sending chain for `new_pub → remote_pub`; `PN = old send_n`; `send_n = 0`). + The receiving chain is untouched. +4. Else it is a ratchet key not adopted yet: run a full DH ratchet step. + +### DH ratchet step + +On a frame whose `dh_pub` differs from the adopted remote public key: + +1. **Retire the current receiving chain.** `PN` is how many messages the peer + sent in it, so: + - `PN < recv_n` → reject (used message key). + - `PN - recv_n > MAX_SKIP` → reject. + - Derive `recv_n .. PN` into the skipped store, tagged with the retired + remote public key, so stragglers of the old chain still decrypt. +2. **Receiving half of the step**, on the pair `(my current secret, frame.dh_pub)`: + `shared = DH(my_secret, frame.dh_pub)`, + `(root_a, ck_lo, ck_hi) = epoch_chains(root, shared)`, + `recv_ck = chain_for(frame.dh_pub, my_pub)`, then open the frame with this + chain exactly as in step 3 above (it must be within `MAX_SKIP` of index 0). +3. **Sending half:** generate a fresh ratchet keypair, + `shared = DH(new_secret, frame.dh_pub)`, + `(root, ck_lo, ck_hi) = epoch_chains(root_a, shared)`, + `send_ck = chain_for(new_pub, frame.dh_pub)`, `remote_pub = frame.dh_pub`, + `PN = old send_n`, `send_n = 0`, `established = true`. +4. The frame is opened with the *new* receiving chain's message key. If the AEAD + open fails, nothing is applied: the state must be byte-identical to before + the frame. + +The next frame this side sends therefore carries the new `dh_pub`, which is what +lets the peer step too. + +### Bounds and replay + +- `MAX_SKIP = 2000`. Checked on both jumps: `N - recv_n` on the current chain + and `PN - recv_n` while retiring one. `jump == 2000` is accepted, + `jump == 2001` is rejected (`MaxSkipExceeded`) and leaves the state untouched. +- `MAX_SKIPPED_KEYS = 2000` stored message keys. When the store is at the cap, + inserting a new key evicts the **oldest-inserted** entry first — insertion + order, not `N` order. +- A skipped key is removed the moment it decrypts a frame, so a replayed frame + fails closed (`UsedMessageKey` or an AEAD failure). +- Every bound is validated before any state mutation. A rejected or tampered + frame must leave the state byte-identical. + +### State at rest + +`ratchet_sessions` in the SQLCipher store: one row per friend +(`friend_id` primary key, `FOREIGN KEY` → `friends.id` `ON DELETE CASCADE`, +`state BLOB NOT NULL`, `updated_at`). The blob is version byte `0x01` followed by +the implementation's serialized `RatchetState` (root, keypairs, both chain keys +and counters, `established`, and the skipped-key store). The state is +device-local: it is **never** transmitted, and its layout is not part of this +wire protocol. The store is encrypted as a whole, so the blob is ciphertext on +disk. + +### Not ratcheted + +`loc `, `prf `, `inv `, `rcp `, `tip `, `png ` and `fil ` frames — and every +file chunk — keep the one-shot Noise shape: one handshake per application frame, +no ratchet, no persistent session. Only chat is ratcheted. + +### Prekey change resets the epoch + +A peer whose prekey changes invalidates the bootstrap epoch on both sides, and +the stale state is dropped locally, so the next chat frame starts a fresh +bootstrap epoch. Frames sent under the dropped epoch are not readable +afterwards. There is no key-confirmation exchange and no in-band reset command; +the new invite is the signal. + ## Invite (out of band) Not a QR graphic. A single ASCII string, max 4096 characters: @@ -353,3 +580,6 @@ path”). They are out of scope, not postponed. - Frame `version` 1 and invite `onionwire:v1` are this document. - A new handshake prologue or a new invite scheme is a breaking change. - New typed prefixes (`xyz `) are backward compatible if old peers drop them. +- The `rat ` frame has its own version byte (`0x01`). A different ratchet frame + layout or a different KDF is a breaking change for chat only: peers that + disagree cannot read each other's chat, and every other frame keeps working. diff --git a/docs/THREAT_MODEL.md b/docs/THREAT_MODEL.md index 006ee1f..21ddb15 100644 --- a/docs/THREAT_MODEL.md +++ b/docs/THREAT_MODEL.md @@ -23,8 +23,9 @@ 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 -secret key, friend public keys, locators, profiles and payment rows are all -ciphertext on disk. There is no `identity_sk`-on-disk problem to work around +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 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. @@ -65,6 +66,72 @@ A chat send to an unreachable onion is written to an `outbox` row next to its `m 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. +## 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 + in-band reset and no key confirmation. +- *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. + ## 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. From 7ba07f84ea39a297ff035a6e261debf37daf88c4 Mon Sep 17 00:00:00 2001 From: agent Date: Wed, 16 Sep 2026 22:46:45 -0400 Subject: [PATCH 2/2] docs: add Cuprate in-process daemon exploration to payment plan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds §7a documenting the alternative approach of embedding Cuprate's crates directly into the OnionWire binary instead of spawning monerod as a subprocess. Includes PoC results (cargo check passed with both arti-client 0.44 and 0.46), the wallet-layer gap, dependency bloat assessment, and exploration card titles. Does not change any locks — the subprocess wrapper model remains the default path. See references/cuprate-integration.md for full test log. --- docs/payment-integration-plan.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/payment-integration-plan.md b/docs/payment-integration-plan.md index 3d3fe0e..a1d026d 100644 --- a/docs/payment-integration-plan.md +++ b/docs/payment-integration-plan.md @@ -198,6 +198,29 @@ Keep the UniFFI surface honest about wallet state: running/not running, balance, --- +## 7a. Alternative: in-process Cuprate daemon (rust-dev exploration) + +A rust-dev card may explore baking a Monero chain daemon directly into the OnionWire binary via [Cuprate](https://github.com/Cuprate/cuprate)'s internal crates, instead of spawning `monerod` as a subprocess. This is an **exploration**, not a commitment. Key facts that decide whether it's viable: + +- **Cuprate crates are not published to crates.io** — every `cuprate-*` crate is a `0.0.0-placeholder` name reservation. Using them requires a git dependency on `https://github.com/Cuprate/cuprate` at a specific commit, pinning a pre-1.0 project. The root `Cargo.toml` declares no versions on workspace members (path deps only). +- **`cuprated`'s `Node::launch(config)` API** (`binaries/cuprated/src/lib.rs`) is the in-process entry point. It takes a `Config`, opens the database (fjall), starts consensus, P2P, RPC servers, and the sync loop. A `Node` handle is returned with `blockchain`, `txpool`, `clearnet`/`tor` network interfaces, and a `task_executor` for shutdown. This is a real embeddable API — not CLI-only. +- **Tor is already integrated** via `arti-client` (0.44), `tor-hsservice`, `tor-rtcompat` — the same crates OnionWire uses. Config has a `[tor]` section with `mode = Auto|Daemon|Arti` and onion service settings. OnionWire already uses `arti-client` 0.46, so a version-resolution conflict is a real risk. +- **Cuprate is pre-production** — the user book says `do NOT use cuprated for any serious purposes`. RPC parity with `monerod` is tracked in [issue #278](https://github.com/Cuprate/cuprate/issues/278) and is not complete. +- **No wallet layer in Cuprate.** Cuprate replaces only the `monerod` daemon (chain + P2P + consensus). `monero-wallet-rpc` is still required for wallet operations (`create_address`, `get_transfers`, `get_balance`, `transfer`). On Android, the wallet-rpc subprocess survives but the chain daemon is in-process — so the binary-spawning problem is **halved, not eliminated**. +- **Dependency bloat.** `cuprated`'s `Cargo.toml` pulls in `axum`, `hyper`, `tower-http`, `rayon`, `fjall`, `clap`, `tokio-socks`, plus RandomX and CryptoNight bindings. The combined dependency tree would significantly increase binary size and build time. `axum`/`hyper` are not currently in OnionWire's graph. +- **Database is fjall** (an embedded key-value store, not LMDB or SQLCipher), which means a separate chain data store alongside OnionWire's SQLCipher store. + +**Exploration card (confirmed feasible via cargo check):** + +- **`rust-dev`: Spike — embed `cuprated` (git dep) alongside `arti-client` 0.46, verify `Node::launch(Config).await` compiles and the documented usage (`node.blockchain.context().chain_height`) type-checks.** PROOF OF CONCEPT: `cargo check` passed (exit 0) with 575 packages; `arti-client` 0.44 (Cuprate) and 0.46 (OnionWire) coexisted. `cuprated::Node::launch(config: impl Into>) -> Result` is accessible. `Node` fields: `blockchain`, `txpool`, `clearnet`, `tor`, `config`, `task_executor`; implements `Drop` → `shutdown()`. Config is at `cuprated::config::Config`. See `references/cuprate-integration.md` for full test log. + +- **`rust-dev`: If spike passes, actually launch Node::launch on testnet/fakchain, verify sync starts and monerod-compatible JSON-RPC (get_info, get_height) responds with the chain data OnionWire needs for receipt verification.** +- **`rust-dev`: If launch spike passes, assess wallet gap.** Since Cuprate has no wallet layer, determine whether to (a) keep `monero-wallet-rpc` as a subprocess and point it at the in-process Cuprate daemon (halves Android binary spawning), or (b) also adopt `monero-oxide`/`monero-wallet` as an in-process wallet to eliminate all subprocesses. + +This card does **not** pre-empt the existing subprocess-based cards in §9 — those remain the default path until Cuprate proves itself in-process. + +--- + ## 8. Key risks to flag in the card descriptions - **Arti SOCKS feasibility on Android** — backend 2 on Android depends on it. Verify before committing the Android remote-daemon path. @@ -219,6 +242,9 @@ Keep the UniFFI surface honest about wallet state: running/not running, balance, - `apk-dev`: Bundle monerod per Android ABI + local-node opt-in with storage gate + sync controls (full on-device node) - `apk-dev`: Android receive-address QR for wallet screen (separate from messenger invite QR) - `ci`: Native binary build + bundle + verification pipeline for monerod and monero-wallet-rpc (TUI assets + Android ABIs) +- `rust-dev`: Spike — embed `cuprated` (git dep) alongside `arti-client` 0.46, verify `Node::launch(Config).await` compiles and the documented usage (`node.blockchain.context().chain_height`) type-checks** — PoC PASSED +- `rust-dev`: If spike passes, actually launch Node::launch on testnet/fakchain, verify sync starts and monerod-compatible JSON-RPC (get_info, get_height) responds +- `rust-dev`: If launch spike passes, assess wallet gap — keep `monero-wallet-rpc` subprocess (daemon in-process only) or also adopt `monero-oxide`/`monero-wallet` - `docs`: Update WALLET.md + THREAT_MODEL.md for the new backends, SOCKS path, prune-window boundary, spend opt-in, Android lifecycle Cut releases manually and batched as the repo policy already requires — don't let a payment feature land push a release. CI for the native binaries is part of the work, not a follow-up.