Repository navigation
feat(chat): add Shroud Chat with instant payment notices over Marmot - #233
Open
theanmolsharma wants to merge 18 commits into
Open
theanmolsharma wants to merge 18 commits into
theanmolsharma wants to merge 18 commits into
Conversation
marmot-ts needs WebCrypto, which Hermes lacks. Install a lazy subtle backed by @noble (digest, HMAC, HKDF, AES-GCM, X25519, Ed25519) only when the runtime has none, and add the chat dependencies plus the jest ESM allowlist. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Runs key package, group, invite, join, chat, notice and receipt between two in-memory clients. Exposed as a "Chat self-test" DevMenu action and exercised in jest with the native subtle removed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The silent payment address is the chat address: pubkey = x-only(B_scan + t·G) with t a tagged hash of B_scan, so any saved contact maps to a chat pubkey with no lookup server. Includes the cross-checked test vector. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Chat text, payment notice, receipt and request rumors with strict schema validation: malformed or foreign events parse to null instead of throwing. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
AsyncStorage-backed marmot stores with tagged JSON for Uint8Array and bigint, AES-256-GCM per value keyed from the chat secret, and a persisted client id. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
NostrNetworkInterface over nostr-tools SimplePool with NIP-42 auth answered by the chat identity, and one shared default relay list. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
One MarmotClient per wallet: publishes key packages and relay lists, creates and joins 1:1 groups, auto-accepts invites from contacts, holds the rest as message requests, converges duplicate groups on the lower pubkey, and sends text, payment notices, receipts and requests. Integration-tested on an in-memory relay. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Starts the service for the active wallet once storage is unlocked, restarts it when the wallet, bucket or network changes, and stays off while chat is disabled or Tor-only is on. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Inverted thread with text bubbles and payment cards, composer with Pay, and a message requests list for invites from people who are not contacts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Message button beside Pay, an on-Shroud badge with preview and unread count in the contact list, a message requests entry, and a Shroud Chat settings screen. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Extracts the BIP-352 input maths into computeScanTweak, shared with the post-broadcast change scan, and adds detectUnconfirmedPayment: it verifies the notice's hex by hash (or fetches from Electrum), scans with the sender's tweak, and stores matches as pending coins through the de-duplicating addUTXO. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Receiver checks a notice at once, goes Pending and sends a detected receipt, retries per block while nothing matches, and confirms on the first confirmation. Sender follows its own transaction. Both resume after a restart. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Confirm computes the scan tweak before broadcasting, then tells each silent payment payee who is on Shroud chat, fire and forget. Success shows when it went out. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
useSendToAddress takes an amount, note and chat request id; SendDetails fills them in and Confirm passes the request id on so the payment notice answers it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Request button asks for an amount and note. The payer's Pay button opens send prefilled, but only after checking that the request's address belongs to the sender (pubkeyFromAddress(address) === rumor.pubkey); a paid request shows Paid. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Until the receiver's own scan matches, the sender's amount is shown muted and never as received. Also tidies lint in the tracker, wallet and request sheet. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Chat keeps encrypted records in AsyncStorage beside the wallet's; a forgot-PIN wipe now removes them too. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Opens the conversation directly, with an unread count on the icon. Hidden while chat is off or unavailable. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Summary
Shroud Chat: Google Pay-style messaging between contacts, with payments showing up inside the conversation. 1:1 end-to-end encrypted text over Marmot (MLS over Nostr) via
marmot-ts, plus an encrypted payment notice that lets the receiver find an incoming silent payment in the mempool within seconds instead of waiting for a block and an indexer scan.x-only(B_scan + TaggedHash("Shroud/NostrIdentity", B_scan)·G), so every saved contact maps to a chat pubkey with no lookup server. A 1:1 chat is a two-member Marmot group; invites from contacts are joined automatically, anything else waits under Message requests.addUTXO, and replies with a receipt. The amount shown is always what the receiver's own scan matched.What's in the diff
helpers/chat/:nobleSubtle.ts(crypto.subtleshim for Hermes),identity.ts,events.ts,storage.ts(tagged JSON + AES-256-GCM, keys from the chat secret),network.ts,ChatService.ts,PaymentTracker.ts,ChatProvider.tsx, plus an in-memory relay and a DevMenu "Chat self-test".hd-bip352-wallet.ts:computeScanTweak(extracted from the post-broadcast change scan, which now shares it) anddetectUnconfirmedPayment.Electrum.onNewBlock,SettingsProviderchat toggle, device wipe clears chat storage.marmot-ts@0.9.0,applesauce-*,nostr-tools,@noble/ciphers,@noble/curves,@scure/base).package.jsonscripts are untouched, so the OTA fingerprint is unaffected; no native changes.Verification
npm run tslintandnpm run lintpass (0 errors, same 113 warnings as master).npm run unit: 782 pass, 1 fails.sendDetails.test.tsx › fills in a payment request opened from home, fails identically on a cleanbc5ac6f90and is unrelated.ChatServices on an in-memory relay (invite → chat → notice → receipt, duplicate-group race, restart),PaymentTracker, sender tweak and receiver detection (Rust scanner stood in byscanOutputsWithTweak), request-address verification.Notes for review
AppLockis only an auth gate; the seed stays in memory). It stops on wallet, decoy-bucket or network switch, and when Tor-only is on. It resumes on foreground to re-subscribe and backfill.setChatRelaysadds one).🤖 Generated with Claude Code