Repository navigation
net, ariadne: end-to-end encrypted DMs with the keys in the host (TX.WTF's X3DH + Double Ratchet) - #1191
Merged
Conversation
…WTF's X3DH + Double Ratchet) cvc::net::E2eeStore (inc/cvc/net/e2ee.h) ports TX.WTF's client crypto to C++ over libsodium, byte for byte: atx-crypto-club/txwtf txwtf/static/js/e2ee.js and messaging-e2ee.js. That is: - X3DH from a prekey bundle; - a Double Ratchet per message (X25519, BLAKE2b KDFs, XChaCha20-Poly1305); - a random content key per body, wrapped through the ratchet; - grp-dr-v1 group fan-out; - the Argon2id passphrase backup. The store holds every secret: identities, prekeys, sessions, and a cache of opened plaintext. Its API gives and takes public keys, ciphertext and plaintext only. Persistence: - With a file it is owner-only (0600 in 0700), replaced whole on every change before the call returns, and locked to one process (<file>.lock: flock / LockFileEx). - Without one it lives in memory. Its state is in messaging-e2ee.js's own key-store layout. The e2ee-* verbs (inc/cvc/ariadne/e2ee_intrinsics.h, ARIADNE.md §10.8) put it in front of documents, by handle, as the credential store's names work. A document gives them what the server sent and gets back what to send, and never holds a key. - --e2ee-store SPEC (host_cli; NetHostConfig::e2ee_store; enable_net -> enable_e2ee) opens it. - The store lives in the app (app.slot), not the process. - A store that cannot open leaves the verbs out, and (e2ee-status) says why: no libsodium, a browser, another process holding it. The host still runs. - e2ee-backup and e2ee-restore are async, for Argon2id's second. Where it is safer than e2ee.js, on the same wire: - Decrypting is transactional. e2ee.js runs a DH ratchet step before authenticating, so one forged message with a fresh ratchet key breaks the session. - A skipped key is spent only once it opened its message. - Headers are checked before anything is derived. - Skipped keys, cached plaintext and a backup's Argon2id limits are bounded. On wasm the randomness is getentropy(): libsodium's own JS source throws on a pthread. libsodium is optional: find_package(sodium) (cvcpkg's libsodium, cy-pca/cvcpkg#612), else a system one by header and library. Without it e2ee_available() is false. The libcvc recipe gains the dependency once the libsodium bundles are published. private_file.{h,cpp}: the credential store's config_dir and owner-only write and check, now shared with the E2EE store; the messages are unchanged. Tests: - e2ee_test replays src/cvc/tests/data/e2ee/txwtf_vectors.json. tools/e2ee/txwtf_vectors.js wrote it by running txwtf's unmodified e2ee.js (libsodium-wrappers-sumo 0.7.15) for three users with seeded randomness: ten sends, twelve opens (out of order, ratchet turns, no one-time key, groups), tampered copies, and a backup. - Every bundle, body, wrapped key, header, envelope and backup blob comes out byte for byte the same. - Every message opens. - The final stores equal e2ee.js's. - e2ee_test also checks: a forged ratchet key changes nothing; other-device messages say so; MAX_SKIP; the file is owner-only, locked, and survives a restart. - ariadne_e2ee_test runs the verbs in a document, with no secret in the state tree; a backup and restore through the async verbs; and a locked store reported by (e2ee-status). - tools/e2ee/interop.sh is a live round trip with e2ee.js: C++ seals, e2ee.js opens and replies, C++ opens the replies.
…e E2EE libsodium 1.0.22+cvc.1 is in the catalog for linux (x86_64, arm64), macos (arm64, x86_64), windows, wasm and wasm-mt (cy-pca/cvcpkg#612). With it CVC_HAVE_SODIUM is on and ari, arigl and arisrv get the e2ee-* verbs and --e2ee-store; without it they build as before, with no verbs.
transfix
added a commit
to cy-pca/nicotina
that referenced
this pull request
Nov 12, 2026
…d by the host (#28) The TX.WTF window gets DMs, the bar's last button (✉ in ImGui; also the menu's Messages): the conversations, latest first, and a conversation's last 30 messages with a box that sends. Message on someone's profile opens or starts the conversation with them, and a plaintext conversation can be encrypted, one-way as in the web app. End-to-end encrypted conversations are sealed and opened by the host, which keeps the keys as it keeps the session token: TX.WTF's X3DH + Double Ratchet through libcvc's e2ee-* verbs (transfix/libcvc#1191, over cy-pca/cvcpkg#612's libsodium). The document names the account's handle and posts what the host gives it, and never holds a key. - The launcher passes --e2ee-store to a host whose --help lists it; NICOTINA_E2EE=0 leaves it out. - DMs backs the keys up under a passphrase (Argon2id), restores them, and makes new ones. - A conversation whose session another device holds says so and has no box. - On a host without the verbs, encrypted conversations show locked, with the reason. DMs is the words bar's eighth stop, so every tmux count past the bar counts one more, in run.sh and local.sh, main's Admin walkthroughs included. The words bar's unread count is a bare number, so the row fits 80x24. The stub gains the DM API and the E2EE key directory and message store, ciphertext only. tests/e2ee.sh runs TX.WTF's own e2ee.js as the other side against a host that keeps keys; without a libcvc#1191 host, node and a txwtf checkout it skips.
transfix
enabled auto-merge (squash)
November 13, 2026 03:54
…uilds on today's master
… check requires net_host.cpp: master's register_http_uri_handler(app, policy) beside enable_e2ee.
…ction #1203 turned state_exec's nil_value, true_value and false_value from constants into functions. `k ? keys_value(*k) : se::nil_value` still compiled: the function's address converts to a bool, so (e2ee-identity) with no identity, and five more nil results, came back true. ariadne_e2ee_test caught it after the master merge (ui.dm.none was "some"). se::value_t() is nil on master and on release/3.x alike, so the code stays the same on both.
transfix
added a commit
that referenced
this pull request
Nov 15, 2026
- app_runtime.cpp: the constructor hands the scene its repeat: count function (#1230), then takes the verb table's lock as before. - e2ee_intrinsics.cpp (#1191): the e2ee-* provider registers its async functions on the calling program's host (*ictx.host, else the app's), as every provider on this branch does (B30), so an isolated document's e2ee-backup and e2ee-restore park on its own group. - STATE_EXEC_THREADED.md: the e2ee provider in the provider table and the file list.
transfix
added a commit
that referenced
this pull request
Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
End-to-end encrypted TX.WTF DMs, with every key held by the host.
cvc::net::E2eeStoreis TX.WTF's client crypto ported to C++ over libsodium, byte for byte. The originals are atx-crypto-club/txwtftxwtf/static/js/e2ee.jsandmessaging-e2ee.js.e2ee-*Ariadne verbs put it in front of documents, by handle, as the credential store does with names. A document such as nicotina gives them what the server sent, gets back what to send, and never holds a key.Design:
docs/E2EE.md. Verbs:docs/ARIADNE.md§10.8. libsodium comes from cy-pca/cvcpkg#612, published 2026-11-12.What's in it
inc/cvc/net/e2ee.h,src/cvc/net/e2ee.cpp: the store and the crypto.grp-dr-v1group fan-out, and the Argon2id passphrase backup.identity,session:<ref>,pt:<id>).<file>.lock, through flock or LockFileEx. Two writers would fork a ratchet.inc/cvc/ariadne/e2ee_intrinsics.h: the verbs. The plain ones aree2ee-status,-identity,-create,-prekeys,-forget,-session?,-seal,-seal-group,-sent,-openand-fingerprint;e2ee-backupand-restoreare async, for Argon2id's second. They make no requests: the document posts what they give it withhttp-request.--e2ee-store SPECcomes throughhost_cli,NetHostConfig::e2ee_storeandenable_net, thenenable_e2ee.app.slot<E2eeHost>).(e2ee-status)says why: no libsodium, a browser, another process holding it. The host runs on.src/cvc/net/private_file.{h,cpp}: the credential store's config dir and its owner-only write and check, now shared with the E2EE store. Its messages are unchanged;net_policy_testpasses.find_package(sodium CONFIG)(cvcpkg'ssodium::sodium), else a system libsodium by header and library.CVC_HAVE_SODIUMis set only when it is found; without ite2ee_available()is false and the verbs are absent.cvcConfig.cmakerecreates the target for a static cvc.getentropy(). libsodium's own JS source throws on a pthread (Module.getRandomValue is not a function; it is set up per thread).Where it is safer than e2ee.js, on the same wire
dh(the server is untrusted by TX.WTF's own threat model) runs a DH step and then fails. After that every later genuine message of the page load fails too, and on each reload the forged message replays first. Here decryption works on a copy and keeps it only once the message opened:E2eeStore.AForgedRatchetKeyChangesNothing.dh, counters under 2^31.The first two are worth reporting to txwtf.
Interop with e2ee.js
1. Vectors, byte for byte (
e2ee_test,E2eeVectors.*).tools/e2ee/txwtf_vectors.jsruns txwtf's unmodified e2ee.js and messaging-e2ee.js with libsodium-wrappers-sumo 0.7.15, the build the TX.WTF page loads. It runs three users through a stand-in server, with every random draw from a seeded BLAKE2b stream, and writessrc/cvc/tests/data/e2ee/txwtf_vectors.json.2. Live, with the system's randomness (
tools/e2ee/interop.sh). C++ seals, e2ee.js opens and replies, C++ opens the replies:3. Through nicotina (cy-pca/nicotina#28's
tests/e2ee.sh, with Linux ari built from this branch). nicotina talks to TX.WTF's e2ee.js through the stub instance. The host opened e2ee.js's message, sealed nicotina's typed answer, and e2ee.js opened it: 13 passed, 0 failed.Tests
e2ee_test:no-session, and a missing one-time prekey);E2eeInterop.*, which runs only undertools/e2ee/interop.sh.ariadne_e2ee_test:(e2ee-status)says why.Local runs:
e2ee_test8 passed (1 skipped: the interop case),ariadne_e2ee_test3 passed,net_policy_test25 passed,ariadne_host_test57 passed;interop.shas above/Zsofe2ee.cpp,e2ee_intrinsics.cpp)-fsyntax-only -Wall -Wextraofe2ee.cpp)-fsyntax-only,CVC_HAVE_SODIUM)e2ee.cppandprivate_file.cppcompile for both;e2ee_intrinsics.cppfor wasm-mt (single-threaded stops in this box's boost/thread, before any E2EE code)cvcpkg install-deps cvcpkg/recipes/libcvc, #612's libsodium)e2ee_test8 passed (1 skipped),ariadne_e2ee_test3,net_policy_test27,ari_net_test12 (ARI_BINARYset);interop.shas above; every changed TU-Wall -Wextraclean (it caught a missing<sys/stat.h>); the writable-data scan finds nothing newclang-format 18 is clean on the changed lines.
libsodium
cvcpkg/recipes/libcvc(depends.runtime, for linux, macos, windows, wasm and wasm-mt). The recipe jobs now build withCVC_HAVE_SODIUMon, and the E2EE tests run there.--e2ee-store.