The group's inbox (docs/group-inbox.md) and the confederation's signing both took schema 45. The confederation landed first, so it keeps 45 and the inbox moves to 46 with its own AutoMigration(45, 46); ShippedProfileUpgradeJvmTest's current is 46. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54 KiB
The group's inbox: NIP-4E for a group's npub
A plan for four things a group cannot do today:
- Be written to privately. Anyone on nostr can send the group a NIP-17 direct message, addressed to the group's npub, the way they would write to a person.
- Have its admins read what it is sent. Every current admin's device opens those messages, and nobody else's does: not the group's other members, and not a relay.
- Answer as itself. An admin drafts a reply; it reaches the person only once the group's quorum has signed it, so the reply is the group's word and not the drafter's.
- Change the lock when the admins change. The key that opens the inbox is regenerated, by a new ceremony, whenever an admin leaves or joins, and whenever an admin asks for it.
None of this is possible with the group's own key. Nobody holds a group's secret key, so nothing can be NIP-44-encrypted to its npub or from it (confederation.md says so and builds around it). NIP-4E is the way out: a nostr identity may announce a separate encryption key, and senders encrypt to that instead. This plan gives the group such a key, generated by a ChillDKG ceremony among its admins and held in full by each of them. The group's npub still signs, through FROST, and only through FROST.
Read shared-key-ceremony.md and shared-key-derivation.md first: the ceremony is the one this plan runs again, and the derivation note's one rule (never reconstruct a derived key in the clear) is the rule D2 explains this plan does not break. Then group-nostr-profile-and-posts.md, for how a group proposes, signs and broadcasts an event in its own name; admin-change-rotation.md, for the follow-through an admin change already runs, which D14 adds to; and marmot-direct-messages.md, for the last time this app built a gift wrap by hand.
Built on claude/nip4e-group-profiles-38d2ac, against 5ac4c053, on 2026-11-22, one commit
per phase (ccc439b2 to the commit that adds this header), plus one test commit in Phase 8.
Behind ExperimentalFeatures.groupInbox, on in development builds and off in release.
jvmTest 1,706, all passing; m3Audit, brandAudit and walletAudit at their budgets;
compileDebugKotlinAndroid builds. The phases are kept as written, because they are the
reasoning. Where the build chose differently:
| what the plan said | what it turned out to be |
|---|---|
| D3: candidate kinds 30390–30396 | 30410–30416. quartz 2.20.1 has 30392–30395 (experimental trusted lists); Phase 0 found the collision |
Phase 3: a GroupInboxOutbound table for wraps |
GroupInboxPublication, one table for everything owed to relays: the 10044 and 10050 (D7) and the reply wraps (D10). Phase 5 folded InboxSigning (a reply's manifest and a refusal's reason, kept past arrival) and InboxKeyCeremony.announceRelays into schema 46 (45 when built; see Phase 3), which has not shipped |
Phase 4: InboxKeyRitualScreen |
the settings screen's ceremony card (Phase 7): who it waits on, and Abandon |
| Phase 4: transcript lines that say what each step does | three lines a ceremony (started, made, ended). Nobody is asked anything in it, so a ladder per step names nobody whose door to knock on; the ceremony card names them when it stalls |
| (not in the plan) | an announcement that arrives before this device has finished the same ceremony waits instead of being declined as a key nobody made. The coordinator asks for the signature the moment its own copy is made, which is routinely before anyone else's; FrostSigningManager.resumeInboxAnnouncements looks again when the ceremony finishes here |
| (not in the plan) | a member who only watches the ceremony learns the key, by running the coordinator's two aggregations over the public messages, which need no secret. That is what lets a share-holder who is not an admin check a 10044 before signing it |
| Phase 6: catch-up from the newest wrap less two days | no since, as the personal inbox has none, and no negentropy pass: the live subscription's limit covers reconnection. A device away longer than that window misses mail; the same is true of the personal inbox today |
Phase 6: the subscription asks for #p = the group's npub |
and for #p = each inbox key this device holds, routing a wrap by its key when it is not tagged with the group. An app that knows only the announcement, and builds its wrap with quartz's GiftWrapEvent.create, tags the key it encrypts to |
Phase 6: indexNostrEvent skips a wrap tagged with a group |
not needed: the personal subscription asks only for #p = the identity, so a group's mail never reaches storeNostrEvent |
| Phase 6: the wipe | in MarmotInboundManager.processGroupMembershipChanges, and it deletes the inbox's messages and ledger too, with a transcript line said once |
| D10: any admin can Send again | offered on the proposer's device, the only one that knows a relay never took the wrap. InboxReplies.sendAgain works on any device holding the session's manifest; nothing else offers it yet |
Phase 8: FrostSigningScreen shows the decrypted reply |
through the notes the confederation already used, renamed proposalNotes (FrostSigningRepository, FrostSigningUIState.notes). ProposedEvent says only "A private reply from the group's inbox", since it has no key to read with |
Phase 9: GovernanceFollowThrough owes an inbox rotation after each change |
a rule every device reads off what it holds, InboxRotation.isOwed: the newest key was made over admins the room no longer has. The admin whose key sorts first starts it. Run from the governance follow-through and the sweep |
| (not in the plan) | crossing ceremonies: two admins who start one at once end in the one whose session id sorts first, on every device, the other ended out loud. A proposal for a generation a device already has is dropped |
| Phase 9: a test that no inbox ceremony starts during a share rotation | the refusal reads RotationHold as planned, but the inbox harness runs no share refresh, so it is not tested |
Phase 0, check 4 in SignedGroupKeyStateTest |
moved: Phase 8 made a seal nobody can read a decline, so that test now pins the decline, and InboxReplyJvmTest checks the premise end to end |
| (not in the plan) | the worktree's build needed lightning-kmp-app and its nested submodules initialised from the main checkout's copies, with their local.properties and the prebuilt native secp256k1 |
Not done: Phase 10's device run. Nothing here has run on a device or a desktop client: no inbox has been set up across real devices, no stranger's NIP-17 client has written to one, and no reply has been opened by a client that follows nostr-protocol/nips#2361 -- or by one that does not, which is the case D13 warns about and nobody has watched happen.
Written against 5ac4c053, on 2026-11-22. Paths starting K/ are under
composeApp/src/commonMain/kotlin/mobi/giza/compose/.
The specification, as it stands
NIP-4E is a draft. Two open pull requests carry it, and this plan follows both, as they read on 2026-11-22:
| where | what it defines | what this plan takes |
|---|---|---|
nostr-protocol/nips#1647 (4e.md on per-device-keys) |
kind 10044, a replaceable announcement {"kind":10044,"tags":[["n","<E>"]]} signed by the identity; kinds 4454 and 4455, a client asking for the encryption secret and another client handing it over |
10044, exactly. Not 4454 or 4455: see D1 |
nostr-protocol/nips#2361 (17.md on nip17-key, head bee7463) |
how NIP-17's layers change when either side has an encryption key | all of it |
#2361's layers, in its own pseudo-code's terms:
gift wrap (1059) pubkey = a fresh random key, per message
tags = [["p", receiverIdentityKey, relay]] the identity, not E
content = nip44(seal, conv(wrapper secret, receiverEncryptionKey))
seal (13) pubkey = senderIdentityKey signed by the identity
tags = [["n", senderEncryptionKey]] when it differs from the identity
content = nip44(rumor, conv(senderEncryptionKey secret, receiverEncryptionKey))
rumor (14) unchanged; its pubkey must equal the seal's
Two consequences shape everything below:
- The seal is signed by the identity, but encrypted with the encryption key. For a group, that splits cleanly: the admins hold the encryption key and can build the seal's content; only the quorum can sign the seal. That is the user's requirement — any admin can read, a reply needs the group's signature — and it falls out of the spec rather than being built on top of it.
- The gift wrap names the identity, not the key. A recipient with several keys (the current one and the ones before it) cannot tell from the outside which one a wrap was encrypted to, and tries them. #2361's review says so as an objection. For a group that rotates on every admin change, it is a cost this plan pays on purpose (D14).
quartz 2.20.1 already ships the announcement side, under
com.vitorpamplona.quartz.experimental.decoupling: EncryptionKeyListEvent (kind 10044,
encryptionKey(), keys(), build), KeyTag (the n tag), DecoupledCipher, and the
4454/4455 exchange. The app uses none of it today. quartz's GiftWrapEvent.create and
SealEvent.create encrypt to the key they address and sign with the signer they are
given, so neither can build #2361's layers for a group; both are built by hand here, as
MarmotDirectMessage.wrap already does for its own reasons. quartz's DecoupledCipher
reads a sender's key from their 10044 and has no seal n tag; D8 reads both.
The spec is open, and the main objection to #2361 (that a decoupled sender writing to an
app that does not follow it fails silently) is a live one. So every wire decision lives in
one package, K/nostr/inbox/, with tests that pin the bytes, and Phase 0 records the
commits read.
What Giza does today
Traced through the code at 5ac4c053. Phase 1 pins them as tests before anything changes.
| event | where it lands | what happens |
|---|---|---|
a kind 1059 #p-tagged to a group's npub |
nowhere: LiveSubscriptionManager asks only for #p = the active identity, on Relays.DefaultDMRelayList |
never fetched. If it arrived another way, NostrDao.indexNostrEvent stores a GiftWrapMessage and never opens it: only the active identity's key is tried |
| a peer proposes a kind 10044 for the group to sign | FrostSigningManager.acceptProposal |
no refusal fires (the signer has no allowlist), so it is asked as "Event of kind 10044" and can be signed |
| a peer proposes a kind 13 | same | "Event of kind 13", signable. A member asked to sign a sealed ciphertext it cannot read is a rubber stamp, which is the thing giza-wallet-removal.md says a Giza device must not be |
| either completes | complete → applySignedEvent → ChatMessage.applyInnerEvent |
falls to unsupported(): a raw-JSON bubble on every device |
| a ChillDKG ceremony in a Marmot room | ChillDkgRitualManager.proposeRitual |
allowed only as a subgroup's (require at :267); every completed DkgSession is a key completedKey and getKeyHoldingSessions may sign with |
| the user's own NIP-17 send | NostrNip17Dao.persistAndBroadcastGiftWrap |
goes to DefaultDMRelayList only; the recipient's 10050 is looked up and the block that would use it is commented out (:186-218) |
Four things already exist and are reused unchanged:
- ChillDKG accepts
t = 1, and with it every participant's share is the whole secret (subgroups.md notes that it "will happily generate one", which is whyacceptProposalrefuses one for a signing key). That is D2. proposeSigningBatchwithproposalTagscarries hidden tags inside the MLS-encrypted proposal, as the confederation's seal does. That is D11.approveIfVouchedsigns a key state a device can check for itself without asking its owner. D5 uses the same door for a rotated key's announcement.ConfederationPublisher's owed-event pattern (ownSessionId,publishedAt, backoff from a minute to half an hour) is how a signed event reaches relays without a person pressing Broadcast. D7 and D10 reuse it.
Decisions
D1. 10044 from #1647, the layers from #2361, and no 4454 or 4455
The announcement and the layers are what a sender's app reads, so they follow the drafts to the byte.
4454 and 4455 are how one person's clients pass the secret between themselves: a new client asks in public, an old one answers in public, both signed by the identity. A group has no use for them. The admins are not one person's clients, the identity cannot sign a 4455 without a quorum, and the ceremony (D2) already leaves the secret on every device that should have it. Publishing either would announce, under the group's name, which devices hold its inbox.
D2. The inbox key is a ChillDKG ceremony with threshold 1, over the admins
A ChillDKG ceremony among the current admins, with t = 1. In ChillDKG every participant's
share is the sum of every participant's polynomial evaluated at its index; at t = 1 each
polynomial is a constant, so every share is the same number: the sum of everyone's
contributions. Every admin ends the ceremony holding the same secret e, the ceremony's
threshold public key is E = e·G, and nobody had to send anybody a secret outside the
protocol.
What the ceremony buys over one admin picking e and sending it round (which is how
Bennu's lightning wallet shared its node seed, D4 of
retired/group-lightning-wallet.md):
- Nobody chooses the key. Every admin contributes. An admin whose device is compromised cannot steer the group onto a key the attacker picked in advance, and an admin who knows the dealer's habits learns nothing about the next key.
- Everybody agrees on it, provably. ChillDKG's CertEq round fails the ceremony unless
every participant saw the same result, so no admin can be left holding a different
Efrom the one the group announces. - Blame is built in. A participant who sends a bad contribution is named, as for any ceremony.
- It is the ceremony the app already runs: the rounds, the resume sweep, the transcript lines and the waiting-on screen.
Why not a t-of-n ceremony whose shares are then revealed to everyone: it needs a fourth
round and a pairwise channel, and ends in the same place. t = 1 gets there in the rounds
that exist.
This does not break the derivation note's rule. That rule is about the signing key: a derived signing key reconstructed in the clear leaks the group key. The inbox key is a different key, from a different ceremony, related to the signing key by nothing. Its secret being whole on every admin's device is the point of it.
Phase 0 checks the premise in bitcoin-kmp before anything is built: a three-participant
t = 1 ChillDKG leaves three identical secretShares, each times G equal to the
threshold public key.
D3. Its own kinds, its own tables, its own manager. Never a DkgSession
A t = 1 key in DkgSession would be worse than misfiled. getKeyHoldingSessions and
FrostSigningManager.completedKey scan that table for keys to sign with, and a key any
one admin can sign with alone would be found there. So the inbox ceremony is kept apart
the way the confederation's is:
- Kinds: a family of seven, the same shape as 30310–30316 (proposal, host key, round 1,
coordinator round 1, round 2, certificate, failure). 30410–30416, checked in Phase 0 against the NIP
kind table, quartz, Curare, Bennu and
RetiredKinds, as confederation Phase 0 did for 9430–9433. New kinds also keep a Bennu admin's device from mistaking the ceremony for a subgroup's, which a 30310 with a subset ofptags in a Marmot room would be to it. - Tables:
InboxKeyCeremonyandInboxKeyCeremonyMessage(the ceremony's inputs and received messages, asDkgSessionandDkgParticipantMessagekeep them), andInboxKey(the output). Phase 3. - Manager:
K/managers/InboxKeyRitualManager.kt, on the samefr.acinq.bitcoin.crypto.dkg.chill.ChillDKGcalls asChillDkgRitualManager, with the same discipline: every step a pure function of stored inputs, faults as values. - Transport: MLS inner events in the group's own Marmot room,
p-tagging the admins. Every member of the room receives them, which is fine: ChillDKG encrypts each contribution to its recipients' host keys, so a member who is not an admin learnsEand nothing else. - Host key:
sha256("mantra/inbox-key/host-key/v1" || nsec || room id), so the inbox ceremony's host key is not the one the group's signing ceremony used, and an inbox key in one group is unlinkable to another's. The tag is a hash input and is spelled withmantra/, as every protocol tag in the app is (giza-rebrand.md). - Recovery: the host secret comes from the nsec, and
InboxKeykeeps ChillDKG's recovery data, so a recovery phrase restores the inbox key as it restores a share.
A test pins that no InboxKeyCeremony is ever returned by getKeyHoldingSessions,
completedKey or ShareGenerations.
D4. Who takes part: exactly the admins, and nobody is asked
The participants are RoomAdmins.of(room) when the ceremony is proposed, and every
device checks the proposal's p tags against its own reading of the policy. A mismatch
fails the ceremony out loud, with the difference named, through the family's failure kind.
A member who is not an admin files the transcript lines and takes no part.
An admin's device takes part without asking. The decision to hold the key was made when the group made them an admin, and the decision to have an inbox is the group's signature on its announcement (D5), not the ceremony. Joining a key ceremony is asked today (shared-key-ceremony.md) because it enrols someone in a permanent signing quorum; this ceremony enrols nobody in anything, and an admin who could decline it would only be holding the group's inbox shut.
Every admin has to take part, as in every ChillDKG. A device that never answers is named on the ceremony's screen after a day, with Abandon beside it, as today. A Bennu admin cannot take part at all, so a group with one cannot open an inbox until that admin runs Giza or stops being an admin. The screen says that rather than "waiting".
The ceremony refuses to start while a rotation or an admin change is in flight
(RotationHold), for the same reason rotations and admin changes take turns
(admin-change-rotation.md): the admin set it is run over
would be stale before it finished.
D5. The group decides to have an inbox by signing its announcement
Nothing is public until the group signs a kind 10044 naming E. That signature is the
decision, and it is asked: the approval screen says, in plain words, that anyone on nostr
will be able to send the group private messages, that every admin will be able to read
them, and which relays they will arrive on (D6).
Later announcements, for a rotated key, are not asked again. The group already decided to
have an inbox, and a rotation is what keeping it means. They go through approveIfVouched,
the door key states use, when this device can vouch for all of:
- the group has signed a 10044 before;
Eis the output of a completed inbox ceremony in this room, which this device took part in and holdsefor;- that ceremony's participants are the room's current admins.
A device that cannot vouch is asked, as for an unvouchable key state.
InboxKeyRefusal declines, out loud, in the four places every refusal sits
(acceptProposal, the approve backstop, publishDecline's reason, the unshowable-session
check), any 10044 that:
- names a key which is not the output of a completed inbox ceremony in this room;
- names more than one
n, or has content; - is proposed in a room that is not a keyed Marmot room.
D6. The group's DM relays are a group-signed 10050, proposed with the first 10044
A sender's app sends a NIP-17 message to the recipient's 10050 relays, and many send
nothing when there are none. So the first announcement is a batch of two events, the
10044 and a 10050, signed in one session
(frost-batch-signing.md). The setup screen fills the 10050 with
Relays.DefaultDMRelayList and the member can edit it before proposing. Changing it later
is its own proposal from the inbox's settings.
This brings back one of the four relay lists
group-nostr-profile-and-posts.md
left out, and only that one: an inbox nobody can deliver to is not an inbox. InboxKeyRefusal
declines a 10050 whose relays are not all wss:// and public (the profile plan's
relayUrlOrNull).
D7. The announcement is published by the device that proposed it
A 10044 that is signed but not on relays is an inbox no sender can find. So the signed
10044 and 10050 are filed as owed on the proposer's device and sent by an
InboxAnnouncementPublisher (the ConfederationPublisher pattern) to the publish set and
the group's own 10050 relays, with backoff until a relay takes each. They are also added to
BROADCASTABLE_KINDS, so any member can send them again by hand from the broadcast screen.
Neither writes a NostrEvent row (D7 of the profile plan, for the same reasons).
D8. Reading: a pipeline of its own, beside the personal one and never inside it
The personal DM path is built around one identity: it subscribes to #p = me, tries only
the active key, and files what it opens into chat rooms keyed by participants. Putting the
group's mail through it would mix the group's correspondents into the admin's own DM list,
and give every wrap two keys to be tried against for no reason. So the group's inbox has
its own path, and writes no GiftWrapMessage, GiftWrapPayload or NostrEvent row:
- Subscription.
LiveSubscriptionManagerholdslive-group-inboxwhile the flag is on: kind 1059 with#p= the npub of every room where this device holds an inbox key, on the union of those groups' 10050 relays and the app's DM relays, re-sent when the set changes (thefollowConfederationsshape). Catch-up usessince= the newest wrap seen minus two days, since NIP-59 back-dates wraps by up to that much. - Opening the wrap. Try each
InboxKeythis device holds for the room, newest first. Every wrap goes into a ledger,GroupInboxWrap, keyed by its id, as opened or not, so redelivery is a no-op and a key that arrives later (a restore) can reopen what is there. - Opening the seal. Verify its signature. The sender's key for the conversation key is
the seal's
ntag if it has one, else thenof the sender's own 10044 if this device has it (quartz's model), else the sender's identity. The rumor's pubkey must equal the seal's, as for any NIP-17 message. - Filing. A kind 14 rumor becomes a
GroupInboxMessage: room, rumor id (unique, so two wraps of one rumor are one message), wrap id, sender, the rumor's JSON, its time, which key generation opened it, and a conversation id: the sorted set of the sender and the rumor'sptags, without the group, as NIP-17 defines a chat. A rumor of any other kind is filed as a message this screen cannot show yet, not dropped.
A wrap no held key opens is counted, not hidden. The inbox says how many messages this device cannot open, and why that happens: a sender's app that does not follow NIP-4E encrypted to the group's npub, which nobody can open (see Out of scope for the only fix), or the message was sent to a key from before this admin's time.
D9. Only the admins who hold the key see anything of the inbox
The inbox screen, its row on the group's screen and its count are shown only on a device
that holds an InboxKey for the room. A member who is not an admin sees that the group has
an inbox (the 10044 is public) and nothing in it. D11 keeps the same true of replies, which
otherwise would travel through the room in a form every member can read.
D10. A reply is a batch of seals, signed by the group and wrapped by the proposer
An admin replying to a conversation builds:
rumor kind 14, pubkey = the group's npub (the room id), unsigned
tags: ["p", <each recipient>] … , ["e", <the message replied to>, <relay>, "reply"]
content: the reply
for each recipient r, and once for the group itself:
seal kind 13, pubkey = the group's npub
tags: [["n", E]] the current generation's key
content: nip44(rumor, conv(e, encryption key of r))
created_at: now minus up to two days, at random (NIP-59)
r's encryption key is the n of r's 10044 when this device has one, otherwise r's
identity. For the group's own copy it is E.
The seals go to the quorum as one batch through proposeSigningBatch. Proposing is the
proposer's approval, as for every proposal. Once the session completes, the proposer's
device wraps each signed seal under a fresh random key (p = the recipient's identity,
content encrypted to the recipient's encryption key, #2361's wrap) and publishes it to that
recipient's 10050 relays, falling back to the publish set. The group's own copy goes to the
group's 10050. This is filed as owed and sent with backoff by an InboxReplyPublisher, the
same pattern as D7.
The group's own copy is how every admin sees the reply: it arrives through D8 like any other message, on every admin's device, as an outgoing line in the conversation. The proposer's device files it at once too, without waiting for the round trip.
If the proposer's device is gone, any admin can Send again from the conversation: the
signed seals are on every signer's device as GroupSignedEvent rows, and wrapping needs no
key but a random one. A second send makes second wraps of the same rumor, which D8's
rumor-id key collapses on the group's side; a recipient's app may show it twice.
Why one seal per recipient: NIP-17's seal is encrypted to its one recipient. A reply to a conversation of three people is four seals, and four signatures in one session.
D11. The proposal hides the reply from members who are not admins
A FROST proposal travels as an MLS inner event and reaches every member of the room. Its content is the unsigned events to sign, which here are seals: ciphertext. What the signers also need — which seal is for whom, and on what evidence — rides as a proposal tag, encrypted to the inbox key:
["inbox_manifest", nip44(manifest, conv(e, E))]
manifest:
{"v":1,"generation":<g>,
"seals":[{"recipient":"<pubkey hex>","key":"<encryption key hex>",
"announcement":<the recipient's signed 10044 as JSON, or null>}, …],
"group_copy":<index of the group's own seal>}
A member without the key sees that the group is signing so many seals, which is the number of recipients plus one, and nothing else. That leak is stated in Risks.
D12. Every signer reads the reply before signing it, and declines what does not add up
InboxReplyRefusal joins the others in the same four places. A signer:
- decrypts the manifest with a key of the generation it names. A signer that holds no such key declines, out loud: "This device holds no inbox key for this group". That is a share-holder who is not a current admin (possible while share refresh is experimental), or an admin whose device missed the ceremony. Signing a ciphertext it cannot read is the rubber stamp Giza does not do;
- checks the generation is one this device holds and the batch's every
ntag is that generation'sE; - checks every
announcementit is given: a valid 10044, authored by that seal's recipient, whosenis that seal'skey. Anullannouncement means the key must be the recipient's identity; - opens every seal with
conv(e, key)and checks they all hold the same rumor, byte for byte; - checks that rumor: kind 14, pubkey the room id, no signature, non-blank content, and its
ptags exactly the manifest's recipients other than the group; - checks exactly one seal is the group's own copy, to
E, and eachcreated_atis within two days before now and not in the future.
A proposer who wrote one thing to the group's copy and another to a recipient, sealed to a
key that is not the recipient's, or added a recipient the rumor does not name, is declined
by every honest signer. What a signer cannot check — that a recipient without a 10044
has not published one since, or that their app reads #2361's n tag — is a warning, not a
refusal, per the line automatic-key-ceremony.md drew.
The approval screen shows what the signer is agreeing to: the reply's text, the message it answers, its recipients by name, and any warning.
D13. A recipient without a 10044 gets the reply, with a warning
A seal encrypted from the inbox key opens only in an app that reads #2361's n tag. An app
that does not computes the conversation key from the group's npub, and fails. Giza cannot
tell which a recipient uses: a 10044 shows they do, its absence shows nothing.
So the composer and the approval screen warn when a recipient has no 10044 ("Their app may not be able to open a message from a group"), and the reply goes anyway. Refusing would refuse every recipient whose app reads the tag without announcing a key of its own, which is every #2361 app whose user has not decoupled.
D14. Rotation is a new ceremony, and old keys are kept for reading only
InboxKey has a generation. A rotation runs D2 again over the current admins, and once
its 10044 is signed (D5, unasked) and sent (D7), the new generation is the one replies are
sealed from. Until then the announced one stays in use, so there is never a moment where
the group seals from a key senders have not been told about. A reply proposed under one
generation and completed after a rotation is still valid: its seals' n names the key they
used.
What starts a rotation:
| trigger | how | asked? |
|---|---|---|
| an admin is removed, demoted or steps down | GovernanceFollowThrough owes one once the change has landed, as it owes a share rotation today, and runs it after that rotation (D4's RotationHold) |
no. The group's signature on the change was the decision |
| an admin is promoted | the same, after the enrollment | no. The new admin needs a key |
| an admin asks for one | Rotate the inbox key in the inbox's settings, for a lost phone or a suspicion | no further approval: proposing is the proposer's, and nobody else is asked anything until the announcement, which is vouched |
| a rotation failed or was abandoned | the same button, offered on the failed ceremony's screen | as above |
Old keys are kept, marked retired, and used only to open: a sender may hold a 10044 from before the rotation for a while, and messages from before are in the ledger to be reopened. D8 tries the newest first.
What a rotation cannot do, and the screen does not pretend otherwise:
- A removed admin keeps every message they already read, and the keys they held. Their Giza device wipes its inbox keys and inbox messages for the room when it sees itself removed (as a share is wiped), but that is cooperation, not enforcement.
- A sender who has not refreshed the group's 10044 still encrypts to the old key, which the removed admin also holds, until their app looks again. Nothing the group does reaches that cache.
D15. A promoted admin starts with an empty inbox
The rotation a promotion triggers gives the new admin the new key and none of the old ones, so they read what arrives from then on. Handing a new admin the group's whole correspondence is a different decision from making them an admin, and it is the quorum's to make, not a side effect of a rotation. This plan does not make it (Out of scope). The inbox screen says why a new admin sees nothing earlier.
D16. Behind a flag
ExperimentalFeatures.groupInbox, groupInboxOverride ?: isDevelopmentBuild(), as
confederation is. Off in release until the device run (Phase 10) has passed and the two
pull requests have settled. The refusals (D5, D12) and the declines run whatever the flag
says, as every refusal does: a release build declines a peer's inbox proposal out loud
rather than signing it blind.
Who is asked what
| step | who | asked? |
|---|---|---|
| set up an inbox (propose the first ceremony) | any admin | the button |
| take part in the ceremony | every admin | no (D4) |
| propose the first 10044 + 10050 | the ceremony's coordinator, on completion | no (it is the coordinator's follow-through) |
| sign the first 10044 + 10050 | t holders |
yes: the group's decision to have an inbox (D5) |
| publish them | the proposer's device | no (D7) |
| read a message | every admin's device | no |
| propose a reply | any admin | the Send button |
| sign a reply | t holders |
yes: each reply (D12) |
| wrap and send it | the proposer's device | no (D10) |
| a rotation's ceremony and its 10044 | every admin, t holders |
no (D14, D5) |
Phases
One commit per phase, in the repository's style (feat: … (group-inbox, Phase n)). Every
phase leaves ./gradlew :composeApp:jvmTest and :composeApp:m3Audit green, and
check's brand and wallet audits at budget.
Phase 0: this document, and five checks
This document and its row in README.md. Then, before any code:
t = 1ChillDKG (D2). In bitcoin-kmp's tests or a scratch jvmTest: three participants,t = 1; everysecretShareis equal, and equals the threshold public key's discrete log (secretShare·G == thresholdPublicKey). If the library refusest = 1or the shares differ, stop: the fallback is at = nceremony followed by a reveal round to host keys, checked againstpublicShares, and D2 and Phase 4 change.- Kinds (D3). A family of seven against the NIP README's table, quartz 2.20.1, Curare,
Bennu and
RetiredKinds. Record the result here. - quartz. That
Nip44.v2.computeConversationKey/encrypt/decrypttake an arbitrary secret and public key; thatEncryptionKeyListEventparses #1647's form; that an event template of kind 13 can be built unsigned and handed to the signing session asFrostSigningManager.unsignedEventOfexpects. - The premise. In
SignedGroupKeyStateTest's harness, a batch of two kind 13 events signed in a keyed room verifies as the room's id. If it fails, no recipient would accept the group's seal, and the plan stops. - The spec. Re-read #1647 and #2361 at their heads and record the commits in
The specification, as it stands. If #2361 has moved the
ntag or added a secondp, the wire phase follows it.
Done, on 2026-11-22:
| check | result |
|---|---|
1. t = 1 ChillDKG |
holds. InboxKeyPremiseTest 3/3: three admins finish with one secret, that secret times G is the ceremony's threshold key, and NIP-44 between a stranger and the x-only inbox key agrees from both sides whatever the key's parity |
| 2. kinds | the plan's 30390–30396 collide: quartz 2.20.1 has 30392–30395 (experimental trusted lists). 30410–30416 are in none of the NIP README's table (whose 30300–30499 rows are 30311–30315, 30382–30384, 30402–30403), quartz, Curare at dc1895ee, Bennu at 2db6dde5, RetiredKinds or the app. D3 now says 30410–30416. (The ceremony's own 30311–30315 and the confederation's 30382–30385 share numbers with public kinds; they travel only inside encryption, which is why that never mattered, and why it would not here either. A clean range costs nothing.) |
| 3. quartz | Nip44v2.computeConversationKey, encrypt, encryptWithNonce and decrypt take any secret and any x-only key. EncryptionKeyListEvent (kind 10044, encryptionKey(), build(pubkey)) and KeyTag read #1647's ["n", key]. EventTemplate<Event>(createdAt, 13, tags, content) goes through proposeSigningBatch unchanged |
| 4. the premise | holds. SignedGroupKeyStateTest's a batch of seals the group signs verifies as the room's own: two kind 13 events, signed by a quorum, authored by the room and passing verifies() on both devices |
| 5. the spec | #1647 read at its per-device-keys head (5 commits, last pushed 2025-10-08); #2361 at bee7463 (2026-06-02). Neither merged. #2361 has one p on the wrap and the n on the seal, as this plan has it |
Phase 1: pin today
Tests of What Giza does today, written to pass now and flipped on purpose later:
ProposedEventTest: a kind 10044, 10050 and 13 summarise as "Event of kind N". Phase 5 and Phase 8 flip them.GroupInboxTodayJvmTest:- a kind 1059
p-tagged to a group's npub, fed tostoreNostrEvent, is stored and never opened. Phase 6 makes it never stored by that path at all; - a peer's kind 10044 and kind 13 proposals reach the owner's approval prompt (Phase 5 and Phase 8 turn them into declines unless they check out);
live-group-inboxdoes not exist.
- a kind 1059
Phase 2: the wire, in one package
No database, no UI. K/nostr/inbox/:
InboxKeyRitualEventsand its tags: the seven kinds, each with theinbox_key_sessionand generation tags, and the proposal'sptags.InboxAnnouncement: builds and reads the group's 10044 through quartz'sEncryptionKeyListEvent, and the 10050 throughDmRelayListEvent.InboxSeal: builds the unsigned seal of D10; opens a seal by D8's rule (thentag, then the sender's 10044, then the identity).InboxWrap: wraps a signed seal by #2361 (p= identity, encrypted to the encryption key, fresh key, back-datedcreated_at); opens a wrap by trying keys.InboxReplyManifest: D11's JSON, encrypted toconv(e, E), with a decoder that accepts only its own encoding.InboxConversation.idOf(rumor): D8's conversation id.
Tests (InboxWireTest, pure): every layer round-trips; a seal opens with the n tag, with
a 10044 and with neither; a wrap built here opens with quartz's own
unwrapAndUnsealOrNull when both sides use identity keys (so the hand-built wrap is
still a NIP-59 wrap); a manifest with a stray field is refused; the conversation id is the
same whatever order the p tags are in.
Phase 3: storage, schema 45 → 46
Additive, so an AutoMigration(45, 46) with its comment, the exported
composeApp/schemas/…/46.json, and ShippedProfileUpgradeJvmTest's current moved to 46.
(Built as 44 → 45; the confederation's signing took 45 first on giza, so the merge moved
the inbox up one.)
| table | key | holds |
|---|---|---|
InboxKeyCeremony |
session id | room, generation, participants, coordinator, the ChillDKG inputs (randomness, host secret's tag), stage, the waiting-since time |
InboxKeyCeremonyMessage |
(session, participant, kind) |
each received message, as DkgParticipantMessage |
InboxKey |
(room, generation) |
E, e, recovery data, ceremony id, state (HELD, ANNOUNCED, RETIRED, WIPED), the signed 10044's id |
GroupInboxWrap |
wrap id | room, received at, opened by which generation or not yet |
GroupInboxMessage |
rumor id | room, wrap id, conversation id, sender, rumor JSON, created at, generation, outgoing or not |
GroupInboxOutbound |
(signing session, seal id) |
recipient, the relays, the wrap once built, publishedAt, the backoff |
e is stored as a share is stored, and wiped as a share is wiped. DAOs beside them, and
InboxStorageJvmTest: redelivery of a wrap or a rumor is a no-op, wiping a generation
removes e and keeps E, and no InboxKey is visible to getKeyHoldingSessions,
completedKey or ShareGenerations (D3).
Phase 4: the ceremony (D2, D3, D4)
InboxKeyRitualManager:propose(refused unless the proposer is a current admin, the room is a keyed Marmot room, the flag is on andRotationHoldis clear),process(store, then ask whether it can move),advance(the ChillDKG steps att = 1),abandon,resumeRunning. On completion, checke·G == Eand writeInboxKeyat the next generation.- Inbound: an arm in
NostrDao.fileGroupEventResult's dispatch for the seven kinds, ahead of content kinds as the ceremony's are. - The sweep:
NostrRepository.resumeRunningCeremoniesresumes inbox ceremonies too. - The transcript:
INBOX_KEY_TYPES, rendered asRitualNotices that open the ceremony's screen. Wording says what a step does: "set up the group's inbox", "added their part to the inbox key", "the group's inbox key is ready". InboxKeyRitualScreen: the ceremony's state, who it waits on and since when, Abandon. M3 rules as inCLAUDE.md, and a back button.- Tests, in the ritual harness that
CeremonyAcrossDevicesJvmTestuses, three admins and a member:- every admin's device ends with the same
e, ande·Gis the announcedE; - the member's device files the lines and holds no
InboxKey; - a proposal naming a non-admin, or leaving an admin out, fails out loud on every admin's device;
- a ceremony survives a restart mid-round (stored inputs, as
DkgSession); - a faulty contribution names its sender.
- every admin's device ends with the same
Phase 5: announcing (D5, D6, D7)
InboxKeyRefusal, in the four places.ProposedEventarms: a 10044 is "The group's inbox key", with the key's fingerprint and whether this device holds it; a 10050 is "Where the group receives messages", with the relays.- The follow-through: on the coordinator's device, a completed first-generation ceremony
proposes the 10044 and 10050 batch. A later generation proposes the 10044 alone, and
approveIfVouchedsigns it where D5's three conditions hold. ChatMessage.applyInnerEventarms: a room-signed 10044 is "The group has an inbox" the first time and "The group changed its inbox key" after; a 10050 is "The group changed where it receives messages". Types inGROUP_IDENTITY_TYPES.- On a signed 10044,
InboxKey.statemoves toANNOUNCEDfor its generation and the previous one toRETIRED. InboxAnnouncementPublisher, started bySynchronizationViewModelbesideConfederationPublisher.BROADCASTABLE_KINDSgains 10044 and 10050.- Tests:
InboxAnnouncementJvmTest— the first batch is asked, a rotation's is not, a 10044 naming a stranger's key is declined with its reason and the proposer's device shows the decline, the published event is identical to the signed one and writes noNostrEventorProfilerow. Phase 1's 10044/10050 pins flip.
Phase 6: reading (D8, D9)
live-group-inboxinLiveSubscriptionManager, and catch-up with the two-day margin.GroupInboxManager.receive(wrap): ledger, open, verify, file. Never throughstoreNostrEvent: the subscription hands wraps straight to it, andindexNostrEventskips a wrapp-tagged to a room this device keeps an inbox for.GroupInboxManager.reopen(room), run when a key arrives.DirectMessagePeerSync.KINDSgains 10044, so a correspondent's encryption key is known when the group replies, and D8 can use a sender's 10044 for a seal with nontag.- Repository flows: conversations for a room (newest first, unread count), messages of a conversation, the count of wraps no key opens.
- The wipe: a device that sees itself no longer an admin of a room wipes that room's
InboxKeys andGroupInboxMessages, and writes a transcript line saying so. - Tests:
GroupInboxReadJvmTest— a stock NIP-17 message from an identity-only sender to a group with a 10044, built with quartz's ownGiftWrapEvent.createaround a seal made toE, opens on every admin's device and on no member's; a #2361 sender with anntag opens; a wrap to the group's npub is counted unopenable; the same rumor in two wraps is one message; a wrap to a retired key still opens; the wipe. Phase 1's wrap pin flips.
Phase 7: the inbox, seen
- Routes and screens, each with a back button,
readableContent(), the four states andScreenStateTransition:GroupInboxScreen: conversations, each with its people by name, the last line and an unread mark; the empty state says nobody has written yet, or for a new admin that earlier messages were sent before they held the key (D15); the count of messages this device cannot open, with a line on why.GroupInboxConversationScreen: the messages, incoming and outgoing, with outgoing ones marked by state (being signed, sent, signed but not sent).GroupInboxSettingsScreen: the current key's generation and fingerprint, whether it is announced, the 10050's relays with Change, Rotate the inbox key, and the ceremony's state while one runs.
- The group's screen: an "Inbox" row with the unread count, shown only where this device holds a key (D9). Where the group has no inbox and this device's identity is an admin, a "Set up an inbox" row instead, which explains the decision and opens a setup screen with the 10050 relays to edit before the ceremony is proposed.
- Strings in sentence case from the catalogue; nothing says Bennu, and nothing says "NIP-4E" to a person.
- Tests:
GroupInboxScreenJvmTest— the row is absent for a member and present for an admin with a key; the empty states; the unopenable count.
Phase 8: replying (D10, D11, D12, D13)
InboxReply.build(room, conversation, text, replyTo): the rumor, the seals and the manifest, from the current announced generation and each recipient's latest 10044.- The composer under
GroupInboxConversationScreen: proposes throughproposeSigningBatchwith the manifest tag, warns per D13, and says above the button that the group's quorum has to sign it before it is sent. InboxReplyRefusal, in the four places, with D12's checks.ProposedEventfor a batch of seals: on a device with the key, "A reply from the group's inbox" with the text and recipients; on one without, "A private reply from the group's inbox".FrostSigningScreenshows the decrypted reply, what it answers, and the warnings.ChatMessage.applyInnerEvent: a room-signed kind 13 draws nothing in the room's transcript. The signing session's own lines already say the group signed something, and a line naming the reply would reach members who are not admins.InboxReplyPublisher: on completion, on the proposer's device, wrap each seal and send it with backoff (D10); file the group's copy as an outgoing message at once. Send again in the conversation, for any admin, on a reply whose session completed.- Recipient relays: the recipient's 10050 if known, else the publish set. This is new code rather than reuse: the personal path's equivalent is commented out, and fixing that is not this plan's.
- Tests:
InboxReplyJvmTest, three admins with threshold 2 and an outside recipient —- a reply proposed by A and signed by B reaches the recipient's relays as #2361 wraps, and opens with the recipient's encryption key, and with their identity key when they have no 10044;
- the group's copy opens on C's device as an outgoing message;
- each D12 refusal on its own: a mismatched group copy, a seal to a key that is not the recipient's, an extra recipient, a forged 10044, a blank reply, a manifest for a generation the signer does not hold. Each is declined with its reason, and the proposer's device shows it;
- a member's device without the key reads the proposal as "A private reply" and learns no text and no recipient. Phase 1's kind 13 pin flips.
Phase 9: rotation (D14, D15)
GovernanceFollowThroughowes an inbox rotation after a removal, demotion, step-down or promotion has landed, and starts it onceRotationHoldis clear, after any share rotation the same change owes.- Rotate the inbox key in the settings screen, and on a failed ceremony's screen.
InboxReply.buildreads the announced generation, never the newest held one.- Tests:
InboxRotationJvmTest—- removing an admin rotates the key with nobody asked, the new 10044 is vouched and signed unasked, the removed admin's device wipes its keys, and a message sent to the new key does not open on it;
- a message to the old key still opens on the remaining admins' devices;
- a promoted admin holds only the new generation and sees an empty inbox with D15's explanation;
- a reply proposed before the rotation and completed after it still verifies and opens;
- an inbox ceremony does not start while a share rotation is pending.
Phase 10: the record, and devices
- Mark this plan built, with a what the plan said / what it turned out to be table, and update the README row.
- A since note on confederation.md D5: something can now be encrypted to a group, through its inbox key, for a group that has one. D5's seal stays as it is; whether a confederation should use the inbox is its own question.
- Device run, three desktop clients or emulators in one keyed group with threshold 2, a
fourth member who is not an admin, and an outside identity on a NIP-17 client that
supports #2361 (and, separately, one that does not):
- A sets up the inbox; the ceremony runs with nobody tapping; A and B sign the 10044 and 10050; a public client shows the group's 10044.
- The outside identity writes to the group. A, B and C see it; D sees an inbox row nowhere.
- B replies; A signs; the outside identity's client shows the reply as from the group.
- The same with the client that does not support #2361: confirm the warning was shown, and record what that client does with the reply.
- Remove C as admin; the rotation runs unasked; C's device wipes; a new message opens on A and B and not on C.
- Write to the group from an app with no NIP-4E at all; confirm the inbox counts it as unopenable.
Risks
| risk | what to do |
|---|---|
| #1647 or #2361 changes, or is not merged. #2361's main reviewer opposes it in base NIP-17 | the wire is one package with pinned tests (Phase 2); Phase 0 records the commits read. The flag stays off in release until they settle |
a recipient's app does not read the seal's n tag, and the group's reply fails to open with nothing said on either side |
D13's warning; the device run records what real clients do. The only fix that needs nobody else's cooperation is threshold ECDH (Out of scope) |
| senders whose apps ignore 10044 write to the group's npub, which nobody can open | counted and explained (D8), never hidden |
every admin's device holds e in full: one compromised admin device reads the whole inbox, past and future, until the next rotation |
inherent to "every admin can read". The rotation on every admin change, and Rotate the inbox key, are the mitigations, and D14 says what they cannot undo. It cannot sign a reply: that still takes t |
| members who are not admins see how many seals a reply has, so how many people it goes to | stated in D11. Padding the batch with decoy seals would hide it at the cost of signatures; not planned |
ChillDKG at t = 1 is refused by a future bitcoin-kmp, or behaves differently |
Phase 0's check, kept as a test in InboxKeyRitualJvmTest, fails first |
a t = 1 key is mistaken for a signing key |
D3: its own tables, and a test that no signing path can see it |
| trial decryption against every retired key, for every wrap | a NIP-44 decryption per key per wrap; a group that rotated twenty times tries twenty. Measure in Phase 6; retire keys past a horizon only if it shows |
| two admin devices both send a reply's wraps | only the proposer's sends unprompted (D10); Send again is a person's choice. The group's side collapses duplicates by rumor id |
| a group with a Bennu admin can never open an inbox | the ceremony's screen says why (D4) |
| the group's 10050 lists relays that drop gift wraps | the setup screen fills in the app's own DM relays, which take them |
Out of scope
- Threshold ECDH. The one way to read mail sent to the group's npub, and to reply to
someone whose app ignores the
ntag, with no help from anyone else: each share-holder multiplies the sender's key by its share, andtof the results combine, by the same Lagrange weights as a signature, into the conversation key nobody holds the secret for. It needs the share scalars out of the signing library, the derivation's tweaks applied to them, an interactive round per message, and its own plan. - The group starting a conversation. A reply needs a conversation to answer. Writing first is the same machinery with a recipient picker and is the natural next plan.
- Handing a promoted admin the inbox's history (D15). A group-signed decision to send retired keys to a named admin, sealed to their host key.
- Kind 15 (files) and reactions. Filed and shown as "a message this screen cannot show yet".
- 4454 and 4455 (D1), and a NIP-4E key for a person's own identity.
- Notifications for new inbox messages.
- Chronicling inbox announcements to late members:
ChronicleKindsstaysNONE. - The confederation's seal moving onto inbox keys.
- The personal path's ignored 10050 (
NostrNip17Dao.kt:186-218). Noticed, not fixed here.
Order and size
| phase | rough size | depends on |
|---|---|---|
| 0 checks | a scratch test or two, this document | — |
| 1 pin | ~150 lines of test | 0 |
| 2 wire | ~600 main, ~500 test | 0 |
| 3 storage | ~400 main, ~200 test | 2 |
| 4 ceremony | ~1,200 main, ~600 test | 3 |
| 5 announcing | ~600 main, ~400 test | 4 |
| 6 reading | ~700 main, ~500 test | 3 and 5 (a key to subscribe with) |
| 7 inbox UI | ~1,300 main, ~300 test | 6 |
| 8 replying | ~1,100 main, ~700 test | 6 and 7 |
| 9 rotation | ~400 main, ~400 test | 5 and 8 |
| 10 record | docs and a device session | all |
Phase 2 can be written beside Phase 1. Phases 6 and 7 can overlap once 6's repository flows exist. Everything else is in order: the ceremony before anything it produces, the reading before the replying, and rotation last, because it is the only phase that needs everything else to rotate.
Checking the work
./gradlew :composeApp:compileDebugKotlinAndroid :composeApp:jvmTest
./gradlew :composeApp:m3Audit
./gradlew check
wallet-audit.sh greps for retired kinds and sats: none of 10044, 10050, 13, 14, 1059 or
30410–30416 is retired. brand-audit.sh fails on a Bennu name outside a comment, which the
D4 explanation for a Bennu admin has to put in a comment or say without naming it ("an admin
whose app cannot take part").