94de86a3ce10a48c09f40e588e4632cfbdea1ac3
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3cdce6a908 |
feat(marmot): send the canonical app payload, and an envelope for direct messages (v2 Phase 2)
What goes into MLS is now the Marmot app event the spec defines: six members and no `sig`. The rumor serialised as an Event carried `"sig":""`, which a conformant decoder refuses outright -- a payload with a signature would be a standalone relay event, republishable as a signed statement by its author. The id does not move, because NIP-01 never hashed the signature, so every row filed under an inner event's id stays valid; and the build already in the field reads the new shape, because Event.fromJsonOrNull defaults a missing signature. This switch alone needs no gating and is made everywhere at once. The `encoding` tag comes off the application kind:445 while here -- transports/nostr.md forbids it on every shape. docs/marmot-v2.md, Phase 2. A direct message could not make that switch as it was. Its payload is a NIP-59 wrap signed by a throwaway key, which a conformant peer refuses twice over: for the sig member and for an author that is not the MLS sender. In a current-profile room the wrap now travels inside an envelope -- an unsigned app event of kind 30330 authored by the sender, one `p` tag for the recipient, the wrap's JSON as content. The envelope passes the author check like any payload, so the carve-out in mip03Rejection that admitted bare wraps is confined to legacy rooms by a new `legacyRoom` flag: in a current-profile room a bare kind:1059 is refused as every other conformant client refuses it. Every property the throwaway key was chosen for survives -- the envelope is unsigned and so a claim rather than a proof, the wrap inside is still signed by nobody, and the seal-to-leaf binding in classify still decides who wrote the words. The line for a message this device cannot read now hangs off the row the payload was filed under (the envelope's id in a current-profile room), which ChatMessage's foreign key requires. The envelope is gated, and the gate is the room's profile: an old build renders it as a raw-JSON bubble, so a legacy room keeps sending the bare wrap, and a current-profile room -- which admits only leaves carrying an identity proof, which only a build past Phase 3 can make -- never holds an old build. That is the flag for every wire change after this one. A conformant decoder bounds the whole app payload at 64 KiB, and a chronicle page rides inside one as JSON-escaped content. The new bounds test caught what the arithmetic missed: dense JSON payloads escape to half again their size, so a 48 KiB page became a 70 KiB app event. The packer now measures a page by ChronicleEvent.escapedByteSize -- the bytes it will occupy inside the envelope -- against MAX_PAGE_BYTES, lowered from 64 to 48 KiB, and MAX_PAGE_EVENTS drops from 128 to 96 so the count cap still binds under it, as the comment on the two caps insists. The receiver's raw-bytes check is unchanged and now holds by construction. Tests: MarmotMip03CarveOutTest becomes the test that the exemption is confined to legacy rooms and that an envelope passes the ordinary check; MarmotDirectMessageTest round-trips the envelope through the strict decoder and opens the wrap inside; MarmotPayloadBoundsTest asserts the largest chronicle pages and an envelope are conformant app events, including the dense-content page measured the way the packer measures it. The ingest test's tamper case flips a decoded byte rather than the base64 tail, which could change nothing but padding. Full JVM suite: 1,148 tests pass. The direct-message and chronicle notes record the changes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
65e4a3acc0 |
fix: seal the Welcome, the one gift wrap an MLS room must publish
No invite to a Marmot room has been delivered since |
||
|
|
c24cbed390 |
docs: record what the coverage work found, and what it left uncovered
Three additions. The decision the inbound path makes now has a name and a home -- MarmotDirectMessage.classify -- and the doc says why it is separate from the filing of it: only the filing needs a database, so splitting them is what lets the check that replaces MIP-03 be tested at all. A security property found while writing those tests, which I had asserted backwards. Relabelling a seal with another member's pubkey does not get as far as the signature check: NIP-44 derives the conversation key from the pubkey being claimed, so a relabelled seal is undecryptable by the person it was encrypted for. The label is bound to the key rather than asserted alongside it, and the outcome is a message the recipient genuinely cannot read. verify() catches the narrower case of a seal altered after signing in a way that survives decryption. An honest list of what has no automated test and why -- the recipient validation and the outbound id lookup (both need a database), the two transcript renderings (no Compose UI test dependency in this project), and anything touching a real MlsGroup. Better written down than rediscovered by someone assuming a green suite means the path is covered. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
635cef9311 |
docs: write down how a direct message travels, and what it costs
The reasoning behind this is not recoverable from the code, which is the bar docs/README.md sets for having a document at all. Three things in particular would otherwise have to be rediscovered by whoever changes this next, and two of them are traps. Why the wrap uses a throwaway key rather than the sender's own -- and what that does not buy. It does not hide the sender from the group: MLS authenticates every application message to a leaf, so the identity is there regardless. What it costs is a carve-out in MIP-03's pubkey check and the sender's ability to ever read their own messages back. Why the check that carve-out removes is not a hole. The authorship claim moves from the wrap's plaintext pubkey to the seal's verified signature, bound to the MLS leaf that sent it -- strictly harder to forge than what it replaced. The one query that would broadcast one of these. What this builds is a genuine, correctly signed NIP-59 gift wrap, indistinguishable from what the NIP-17 path would be right to publish, and the only thing keeping it off a relay is that it never becomes a GiftWrapPayload. Written against what shipped rather than what was planned, so it records two deviations. senderIdentity is resolved in NostrDao rather than added to GroupEventResult.ApplicationMessage, because quartz is a binary dependency here and the local checkout is a reference copy, not a build input. And a failed validation drops the message and logs rather than throwing, because the caller is inside storeNostrEvent's transaction. The unbuilt parts are listed as absences rather than left implied: there is no member picker, so a private message can only be a reply to one somebody already sent, and nothing in the UI yet tells a user in words that the group can see who they messaged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |