Kgothatso NgakoandClaude Opus 5 e07bb68014 feat: the sender ratchet as its own row, and the receive side beside it (marmot-kmp, Phase 8)
The piece Phase 7 deferred, in both directions, because they are one question:
a group's state is a few kilobytes of ratchet tree, group context and epoch
secrets, and the app was rewriting all of it to record things that moved a
counter.

Sending an application message advances exactly one thing -- this leaf's entry
in the secret tree (RFC 9420 §9) -- so the library carries the position as its
own record, `MlsGroupStateStore.saveSenderRatchet`, in the spirit of OpenMLS
keeping `message_secrets` apart from `group_state`. Giza defaulted that to
false, which sent the manager back to a full save per message. It is now a
`MarmotSenderRatchet` row, one per room, schema 36 -> 37 with an AutoMigration.
The bytes are stored as the library wrote them -- the `MarmotPublishObligation`
precedent, not the retained-epoch one -- because a record whose whole job is to
never go backwards is safest when nothing here re-encodes it; the epoch, leaf
and generation sit beside it, read off those same bytes, so they cannot drift.

The hazard this introduces is an ordering, and it is in the app's code, not the
library's. `MlsGroupManager.restoreAll` applies the record itself. A room joined
after the engine restored is loaded from its row by `MarmotEngine.groupFor`
instead, and that has to apply the record BEFORE `adoptGroup`, because adopting
persists and persisting rewrites the row from the group being adopted. The other
way round, the next restart re-emits generations already published, under AEAD
keys and nonces already used.

Finding the test that could tell the two orders apart took two goes. The first
asserted the row after a lazy load and passed with the order inverted: a state
saved before this leaf ever sent has no ratchet entry, `exportOwnSenderRatchet`
returns null, and the adopt writes nothing. The order cannot matter until the
stored state holds a position of its own behind the record's, and a received
message is what puts one there. With one receive in the middle the inverted
order fails with expected:<2> but was:<1>.

The receive side is a full save, from `MarmotEngine.processGroupEvent`, which
`NostrDao` now reads inbound events through so a second caller cannot forget it.
And a correction to Phase 5, which said an unwritten row still lost the late
message. It does not: mls-kmp writes the skipped keys beside the positions they
belong to, so an unwritten row is an older COHERENT state, and a position that
has not passed the late generation derives it forward. quartz's engine saved the
positions and dropped the keys -- that pair is what lost messages. The cost of
an unwritten row is the re-deriving, against SecretTree's thousand-step cap. The
reason the write lands now is the send side: until this change every send wrote
the whole state, so the row could not fall far behind inside an epoch.

1167 tests across 156 classes, 0 failures; Android and JVM compile clean; the
four audits unchanged. docs/mls-skipped-keys.md loses its mitigation claim and
gains the correction; docs/marmot-kmp.md gains Phase 8.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-11-19 09:55:31 +02:00
2026-03-24 04:47:19 +02:00
2026-03-23 01:41:39 +02:00
2026-03-23 01:41:39 +02:00

Giza

Giza is a group chat app where the group can speak as one. Groups talk over nostr using the Marmot protocol's MLS encryption. A group can also run a key ceremony that gives it a threshold key, which no single member holds. The group uses that key to sign as one: what it decides, who it makes a subgroup of, what it says about itself, each signed by a quorum of its members. Giza keeps no wallet (docs/giza-wallet-removal.md).

It is a Kotlin Multiplatform app with a Compose Multiplatform UI, built for Android, iOS and desktop (JVM).

Giza and Bennu

Giza is a fork of Bennu, and the two still speak the same protocol. A group can have members on both apps, and a Bennu recovery phrase restored in Giza opens the same profile. The two install side by side as separate apps (mobi.giza.android and mobi.giza.ios), each with its own data.

Bennu keeps wallets and Giza does not. A Bennu phrase restored in Giza brings back the profile and nothing else, and a Bennu member who puts a wallet to a group Giza is in sees Giza's members decline to sign for it. docs/giza-rebrand.md explains what the fork changed, what it left alone and why.

What it does

  • Group chat. End-to-end encrypted groups on Marmot, with direct messages between members, inside a group or one to one.
  • A key for the group. A ChillDKG ceremony, run in the chat, gives the group a threshold key. Members then approve and sign the group's events with FROST, several at a time if needed.
  • Subgroups. A group can create subgroups, each with a key of its own, certified by its parent's quorum.
  • Profiles. Create a profile from a recovery phrase, sign in with an existing nsec or a phrase, preview one from an npub, or keep several profiles on one device.

The reasoning behind each of these, including the protocol details and the failure modes, is in docs/.

Building

You need JDK 21 and the Android SDK. iOS builds also need Xcode on macOS.

Clone with submodules. The app builds against lightning-kmp-app as a composite build, and that repository nests its own builds down to secp256k1-kmp:

git clone --recursive https://code.sigidli.com/giza.mobi/giza-kmp.git

In an existing clone, or in a git worktree, which does not get submodules automatically:

git submodule update --init --recursive

Each of the five nested Gradle builds needs a local.properties that points at the Android SDK. The file is gitignored, so create it in each one:

for d in . lightning-kmp-app \
         lightning-kmp-app/experimental/lightning-kmp \
         lightning-kmp-app/experimental/lightning-kmp/experimental/bitcoin-kmp \
         lightning-kmp-app/experimental/lightning-kmp/experimental/bitcoin-kmp/experimental/secp256k1-kmp; do
  echo "sdk.dir=$HOME/Android/Sdk" > "$d/local.properties"
done

Then build each target (on Windows, use gradlew.bat):

  • Android: ./gradlew :composeApp:assembleDebug
  • Desktop: ./gradlew :composeApp:run
  • iOS: open iosApp in Xcode and run it from there.

docs/jvm-target.md explains what the desktop target needed and how it is packaged.

Checking your work

./gradlew :composeApp:compileDebugKotlinAndroid :composeApp:jvmTest
./gradlew check

check also runs the Material Design 3 audit, docs/scripts/m3-audit.sh. It fails a build that adds hardcoded spacing or colours, title-case strings, or touch targets under 48dp. CLAUDE.md lists the UI conventions the audit enforces.

Layout

  • composeApp is the shared app. commonMain holds most of the code, and androidMain, iosMain and jvmMain hold each platform's own parts.
  • iosApp is the iOS entry point.
  • lightning-kmp-app is a submodule. Giza takes only its key and preference storage from it, and the threshold crypto (FROST, ChillDKG) from the bitcoin-kmp fork it carries.
  • docs holds the design notes.

License

Copyright (C) 2026 Machankura

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Languages
Kotlin 100%