The group's threshold key is `X = x·G`. Nobody holds `x`. Each share-holder `i` of the
active generation holds a Shamir share `sᵢ`, and for any set `S` of `t` holders,
`x = Σᵢ∈S λᵢ·sᵢ`, where `λᵢ` are the Lagrange coefficients at zero over the ids in `S`.
FROST signing relies on exactly this, inside libsecp256k1-zkp.
The group's npub is not `X`. It is the key derived at `m/9420/0/0` by three x-only tweaks
([shared-key-derivation.md](./shared-key-derivation.md)), and its secret, which nobody
holds either, is
```
d = a·x + b where a ∈ {1, −1} and b are public, fixed by replaying the tweaks
```
NIP-44's conversation key between the group and a nostr key `P` is
```
convKey = HKDF-extract(salt = "nip44-v2", IKM = x-coordinate of d·P)
```
and `d·P` can be computed without `d`:
```
each holder i ∈ S: Dᵢ = sᵢ·P one scalar multiplication
πᵢ = DLEQ(Yᵢ = sᵢ·G, Dᵢ = sᵢ·P) a proof that Dᵢ is honest (D3)
the combiner: x·P = Σ λᵢ·Dᵢ
d·P = a·(x·P) + b·P
```
Three properties do all the work:
- **Every subset gives the same point.** Any `t` honest holders produce `x·P`, so whoever
answers first is enough.
- **A partial alone is useless.** `Dᵢ` reveals nothing about `sᵢ` (it is a Diffie-Hellman
value), and fewer than `t` partials reveal nothing about `x·P`.
- **The sign of the whole does not matter.** NIP-44 reads only the x-coordinate, and
`x(Q) = x(−Q)`. So neither `P`'s lifted parity nor the npub's final even-y normalisation
needs care. The sign of `a`*inside* the sum does matter, which is D2.
What comes out is the conversation key of the pair (group, `P`), the one any NIP-44 library
computes from `d` and `P`. That is the whole interoperability argument: a sender's app
cannot tell the group's key apart from a person's.
---
## What NIP-17 asks of the group
A message to the group arrives as:
```
gift wrap (1059) pubkey W, a fresh random key p = the group's npub
content = nip44(seal, conv(w, group))
seal (13) pubkey S, the sender signed by S
content = nip44(rumor, conv(s, group))
rumor (14) pubkey S, the message
```
So reading one message takes two group ECDHs. **`d·W` is new on every message**, because the
wrap key is fresh. **`d·S` is the same for every message from that sender**, and once
computed it can be kept (D6).
A message from the group is:
```
rumor (14) pubkey = the group's npub, unsigned
seal (13) pubkey = the group's npub, signed by FROST
content = nip44(rumor, conv(group, R)) one group ECDH per recipient R, kept
gift wrap pubkey = a fresh key this device holds ordinary: no group secret involved
content = nip44(seal, conv(w, R))
```
So writing takes one group ECDH per recipient (kept afterwards) and one FROST signature
per recipient's seal. The signature is the existing signing session; the ECDH is this plan.
---
## What Giza does today
Traced through the code at `5ac4c053`. Phase 1 pins them.
| event | where it lands | what happens |
|---|---|---|
| a kind 1059 `#p`-tagged to a group's npub | nowhere: `LiveSubscriptionManager` subscribes to `#p` = the active identity, on `Relays.DefaultDMRelayList` | never fetched. If one arrived another way, `NostrDao.indexNostrEvent` stores a `GiftWrapMessage` and never opens it, because only the active identity's key is tried |
| a peer proposes a kind 13 for the group to sign | `FrostSigningManager.acceptProposal` | no refusal fires, because the signer has no allowlist. It is asked as "Event of kind 13" and can be signed: a ciphertext the signer cannot read, which is the rubber stamp [giza-wallet-removal.md](./giza-wallet-removal.md) says a Giza device must never be |
| a peer proposes a kind 10050 | same | "Event of kind 10050", signable. Signing it leaves nothing behind |
| either completes | `ChatMessage.applyInnerEvent` | `unsupported()`: a raw-JSON bubble |
| the user's own NIP-17 send | `NostrNip17Dao.persistAndBroadcastGiftWrap` | to `DefaultDMRelayList` only. The recipient's 10050 is looked up, and the block that would use it is commented out (`:186-218`) |
What already exists and is reused:
- **The share, the public shares and the ids.** `ShareGenerations.active(database, key)`
returns this device's `secretShare` (a `PrivateKey`), every holder's `publicShares`, the
`signerIds` by member, and the `roster` with each holder's **host key**. That is every
input the arithmetic needs, and none of it leaves the device.
- **The point and scalar operations.** bitcoin-kmp's `PublicKey.plus`, `unaryMinus` and
`times(PrivateKey)`, and `PrivateKey.plus`, `times` and `unaryMinus` (`B/PublicKey.kt:48-60`,
`B/PrivateKey.kt:47-53`). Each is a libsecp256k1 call, so **every operation on a secret
stays inside libsecp256k1's constant-time code**. Kotlin only handles public values.
- **The tweaks.** `SharedKeyDerivation.Derived.tweaks` carries the three scalars `derive`
applied. The confederation already replays them by hand to reach the same key
`ThresholdEcdhPremiseJvmTest` keeps all six. What they found:
| check | result |
|---|---|
| 1. ids | the evaluation point is the id plus one, as BIP 445 says; every 3-subset of a 3-of-5 dealer key rebuilds `x`, and the unshifted ids do not |
| 2. tweaks | D2's replay reaches `Derived.publicKey` for forty dealer seeds, which between them meet both parities at all three steps |
| 3. the conversation key | **holds.** Every 3-subset, either lift of `P`, gives quartz's `computeConversationKey(d, P)`, which equals the sender's side; the wrong sign of `a` gives another key |
| 4. scalars | `times` and `plus` reduce mod `n`; Fermat's inverse works; **the `PrivateKey` constructor does not range-check**, so D3 calls `isValid()` |
| 5. kinds | 30400 and 30401 are free in the NIP README, quartz, Bennu's tree, this one and `RetiredKinds` (30402 and 30403 are NIP-99's) |
| 6. size | **D4 and D11 changed.** Sealing each payload per admin with the wrap as evidence was 918 KB for 20 items and 7 admins. The payload is now encrypted once under a key sealed per admin, and wraps and seals travel by reference: 20 items for 7 admins is 10.9 KB |
at most 60 new wrap rounds per room per hour, two batches' worth at Phase 0's size. Beyond that, wraps wait in the ledger, newest first, and the inbox says some
## What the plan said, and what it turned out to be
Built in eleven commits on top of `5ac4c053`, one or two per phase. The tests named in each
phase exist and pass; `ThresholdEcdhPremiseJvmTest` keeps Phase 0's six checks.
| the plan said | what was built | why |
|---|---|---|
| `K/crypto/threshold/` | `K/cryptography/threshold/` | the app already had a `cryptography` package |
| D3: the `PrivateKey` constructor rejects a hash at or above `n` | it does not; `Dleq` calls `isValid()` on every hash it reads as a scalar | Phase 0, check 4 |
| D4: each partial message's payload sealed once per admin | the payload is encrypted once under a fresh key, and only that key is sealed per admin (`AdminSeal`) | Phase 0, check 6: 918 KB for twenty items and seven admins |
| D9, D11: the first partial carries the wrap as evidence | wraps and seals are named by the wrap's id; only a recipient's evidence travels | Phase 0, check 6: one wrap of a long message is most of a relay's event |
| D11: a device answers a round once | a device answers once, and sends its partial *again* to an admin whose message shows it lacks it (each item lists the partials its sender holds, `have`) | Phase 7: an admin promoted after a round combined was never answered, because nobody answers a combined round |
| D12: one `dm_manifest` tag per admin | one `dm_manifest` ciphertext and a `dm_slot` per admin, the same shape as the partials | `AdminSeal`, for the size reason above |
| D13, check 4: the approval waits, and the signing screen says it is waiting for a key | the proposal is held unfiled and handed to the signing manager again when the recipient's round combines (`GroupDmSender.retryHeld`); nothing shows on the signer's device while it is held | the arrival check needs this device's nostr key to open the manifest, and a session filed as asked could be approved before it was read |
| D13: a decline says which check failed | three reasons: `REASON` for any of D13's checks, `CANNOT_READ` for a device that is not a current admin or a batch with no manifest, `FEATURE_OFF` with the flag off. A decline published later, without the key to hand, gives the general one for an admin | `publishDecline` has no nostr key; the specific reason is in the log |
| Phase 4: `GroupDmOutbound` for a message's wraps | it also carries the group's signed 10050, owed by the proposer (`recipient` is the group) | one publisher, `GroupDmPublisher`, for everything the group's mail owes relays |
| Phase 6: the setup screen shows the relays to edit | one field, one `wss://` address per line, refused until every line is a public relay | |
| Phase 7: `DirectMessagePeerSync` fetches each correspondent's 10050 and kind 0 | not built. Evidence and relays come from what the device already holds: a seal the person sent the group, or their kind 0, 10050, 10002 or 1 in the `NostrEvent` table. The composer says when there is none | the profile sync the app already runs fills the table for anyone the device has looked at |
| Phase 7: the rate cap set from the batch size | 60 new wrap rounds per room per hour, two batches' worth | |
| Phase 8: outgoing states and Send again | built in Phase 9, with the data they read: being signed, signed and not yet sent, sent, signed but not sent, declined. Send again is offered on any admin's device for the two unsent states | only the proposer's device wraps on its own, so another admin's cannot tell sent from not |
| Phase 9: the signing screen shows the text, what it answers and the recipients | as notes under the seals, beside the confederation's (`DatabaseFrostSigningRepository.confederationNotes`) | the screen already had the slot |
| Phase 10: the wipe on seeing oneself removed | on every sweep, and whenever partials still reach the device: keys, messages, wraps and rounds, the freed pages scrubbed, and one line in the room | |
The NIP-4E plan (`group-inbox.md`) was built on `giza` at the same time and merged first. The
two now share the wire where they meet, as *Against the NIP-4E plan* said they would:
| where they meet | what the merge settled |
|---|---|
| the schema | the inbox took versions 45 and 46 (with the confederation's signing); this plan's tables are **v47**, `AutoMigration(46, 47)` |
| the group's 10050 | one event, whichever feature proposes it. `InboxRefusal` declines a relay list a stranger could not reach (`RELAYS_SHAPE`), `InboxAnnouncements.onSigned` publishes it from the proposer's device, and the transcript line and the signing screen's label are the inbox's. `GroupDmRelayRefusal` and this plan's own 10050 publishing were removed rather than run twice |
| a batch of kind 13s | split on the seal's `n` tag, by the inbox's own reading of it: a seal naming one inbox key is a reply, for `InboxRefusal` and `InboxReplies`; every other seal is this plan's, for `GroupDmRefusal` and `GroupDmSender`. None is read by both and none is asked blind (`GroupSealRoutingJvmTest`) |
| a wrap to the group's npub | both subscriptions hear it. `GroupDmReceiver` tries the inbox keys this device holds first and hands what they open to `GroupInboxManager`; a round is opened only for what they cannot. The inbox's count of mail it cannot open leaves out what the admins opened by threshold ECDH |
| D2's signs are wrong, and every key is wrong | Phase 0, check 3, against quartz's own key derivation; Phase 2 covers every parity case |
| D3's proof is hand-written cryptography | about forty lines over libsecp256k1 calls, with no secret arithmetic outside it; tested for every way a proof can be wrong; reviewed before Phase 5 builds on it |
| reading waits for `t` admin apps to be open | the cost of never putting the group's key in one place. The screen names who it waits on. Background sync is a separate plan for the whole app ([long-running-sync.md](./long-running-sync.md)) |
| anyone can make the admins' devices work, and fill the room with partials, by sending wraps | D11's batching, Phase 7's rate cap, and the group's choice of relays in its 10050 |
| the static Diffie-Hellman oracle | D5: only keys whose owner signed something, so no `x^k·G` can be asked for, and never the group's own npub |
| a kept conversation key leaks with a stolen phone | it opens no new wrap without `t` holders (D6), and the phone is cut off once its owner is removed (D4). Not keeping keys would cost a round per message from known senders; keeping them is recommended |
| members who are not admins see how many seals a message has, so how many recipients | stated in D12; padding with decoy seals is possible and not planned |
| a promoted admin reads the past (D14) | a decision, made explicitly in D14 and reversible by policy |
| a recipient's relays drop gift wraps from unknown keys | the wrap is stock NIP-59, so it fares like any NIP-17 message; Send again exists |
| a Bennu admin answers nothing | the group still reads with `t` Giza admins; the waiting line names who has not answered |
| NIP-17's sender copy is skipped (D10) | the group's sent messages live in its signing sessions, which reach every admin; a non-Giza client holding the group's key does not exist, so no other device misses the copy |
---
## Out of scope
- **NIP-4E.** The sibling plan. *Against the NIP-4E plan* says how the two would meet.
- **Narrowing a promoted admin's view to after their promotion** (D14).
- **Kind 15 (files), reactions and edits.** Filed, and shown as a message this screen
cannot show yet.
- **Notifications** for the group's new messages.
- **Answering rounds in the background.** The app's sync runs in the foreground; this plan
inherits that.
- **Decoy seals** to hide the number of recipients from members who are not admins.
- **Threshold ECDH for anything else.** The confederation's seal, NIP-44 content for other
kinds, NIP-46. Each would widen D5's table, and each needs its own argument.
- **The personal path's ignored 10050** (`NostrNip17Dao.kt:186-218`). Noticed, not fixed
here.
---
## Order and size
| phase | rough size | depends on |
|---|---|---|
| 0 checks | scratch tests, this document | — |
| 1 pin | ~150 test | 0 |
| 2 arithmetic | ~350 main, ~500 test | 0 |
| 3 wire | ~500 main, ~450 test | 2 |
| 4 storage | ~400 main, ~200 test | 3 |
| 5 rounds | ~900 main, ~700 test | 4 |
| 6 relays | ~600 main, ~300 test | 1 |
| 7 receiving | ~700 main, ~600 test | 5 and 6 |
| 8 screens | ~1,200 main, ~300 test | 7 |
| 9 writing | ~1,100 main, ~800 test | 5, 7 and 8 |
| 10 admin changes | ~250 main, ~400 test | 9 |
| 11 record | docs and a device session | all |
Phase 6 touches none of Phases 2 to 5's files and can be built beside them. Everything else
is in order: the arithmetic before anything rests on it, rounds before either direction,
and reading before writing, because writing reuses the rounds and keys reading leaves