docs: record recovery codes as built (recovery-code-v3, Phase 8)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kgothatso NgakoandClaude Opus 5.5 committed 2026-11-25 23:28:15 +02:00
1 parent f367294cb1
commit 028c1a48f5
5 files changed
+36 -8

No files matched your search

+7 -4
View File
@@ -217,12 +217,15 @@ Bennu still has them, and a Bennu member can put one to a group Giza is in, so:
- The wallet's kind numbers (`RetiredKinds`) stay Bennu's. Nothing new goes on them.
- A recovery phrase is a key backup. `PhraseKeys` derives the npub and the profile id, and
both are pinned in `ForkCompatibilityTest`.
- A recovery code's key is BIP39 entropy: `RecoveryCodeKeys.words` turns it into 24 words,
which derive through `PhraseKeys`, pinned in `RecoveryCodeKeysTest`
([docs/recovery-code-v3.md](docs/recovery-code-v3.md)).
- A new profile is backed by a v3 recovery code ([docs/recovery-code-v3.md](docs/recovery-code-v3.md)),
whose key is BIP39 entropy: `RecoveryCodeKeys.words` turns it into 24 words, which live in
`seed.dat` as a phrase and derive through `PhraseKeys`; the code sits beside them in
`recovery-codes.dat`. A phrase is restored and never made from random bytes. Pinned in
`ForkCompatibilityTest` and `RecoveryCodeKeysTest`.
`./gradlew check` runs `docs/scripts/wallet-audit.sh --check`, which fails on a retired kind in
the app's code, a lightning-kmp import, a file named for a wallet's pieces, or sats in a string.
the app's code, a lightning-kmp import, a file named for a wallet's pieces, sats in a string, or
a phrase made from random bytes.
## Everything sent in a NIP-17 wrap expires
+1 -1
View File
@@ -41,7 +41,7 @@ the [retired](./retired/) notes now.
| [nsec-sign-in.md](./nsec-sign-in.md) | signing in with an existing nostr key — why an nsec can never have a wallet behind it, the ten call sites that make it small, and the sign-in machine that was already built and unreachable |
| [npub-sign-in.md](./npub-sign-in.md) | signing in with only a public key — what a key that cannot sign can still see here, why that is a preview rather than a browser, and the four decisions the word settles |
| [multiple-profiles.md](./multiple-profiles.md) | several profiles on one device — why a profile is a credential and a seed is a wallet attached to one, why a switch is a restart rather than a swap, the two entrances the app lacks, and the inbox a switch would silently lose |
| [recovery-code-v3.md](./recovery-code-v3.md) | backing a new profile with a nine-block v3 recovery code instead of twelve words — planned, not built. Covers why the code's 32-byte key is BIP39 entropy so that every code is also a 24-word NIP-06 phrase, why its words go in `seed.dat` and the code in a file of its own, why a typo is suggested and never applied, and why restoring ships before generating |
| [recovery-code-v3.md](./recovery-code-v3.md) | backing a new profile with a nine-block v3 recovery code instead of twelve words — built, phases 1–8. Covers why the code's 32-byte key is BIP39 entropy so that every code is also a 24-word NIP-06 phrase, why its words go in `seed.dat` and the code in a file of its own, why a typo is suggested and never applied, and why restoring ships before generating |
| [jvm-target.md](./jvm-target.md) | what desktop support cost, phased — why the native chain was already done, why an empty source set in our phoenix fork was the real blocker, and why DAO tests need none of it |
| [npub-profile-preview.md](./npub-profile-preview.md) | showing the person before a direct message is started from a pasted npub — why the preview is a screen keyed by public key, what "found" means when a row can be a placeholder, and the phase that makes the button honest about a key package that never comes |
| [material-design-conformance.md](./material-design-conformance.md) | what the M3 foundations actually require, measured against all 43 screens — the colour pairing that renders the app's own proposals invisible, and eight phases that put the decisions back in the theme |
+1 -1
View File
@@ -244,7 +244,7 @@ Phase 1 cannot be "flip the flags".
| # | question | recommended | the alternative, and what it costs |
|---|---|---|---|
| W1 | Does Giza keep merging from Bennu (rebrand D1, Phase 9)? | **No.** From the end of Phase 1, Giza **cherry-picks** Bennu's non-wallet fixes instead of merging. | Keep merging. Every Bennu commit to a deleted file becomes a modify/delete conflict. Every Bennu wallet change to a shared file (FROST, chat lines, the nav host, the detail screen) becomes a real conflict. Giza's database also has to stay schema-for-schema with Bennu's, so Phase 5 drops nothing: it keeps the 16 entity classes as a frozen file and leaves the tables empty. |
| W2 | What becomes of the recovery phrase? | **Keep it as a key backup.** Create and restore with twelve words as now. Derive only the NIP-06 key and the old id. Strip every mention of funds from the copy. | nsec only. Simpler, but a Bennu user can no longer move to Giza with the same npub, which is the reason the rebrand kept the tags. Twelve words are also a friendlier backup than an nsec, and NIP-06 is nostr's own standard for them. |
| W2 | What becomes of the recovery phrase? | **Keep it as a key backup.** Create and restore with twelve words as now. *(Creating superseded by [recovery-code-v3.md](./recovery-code-v3.md): a new profile gets a recovery code, whose 24 words are a phrase; phrases are still restored.)* Derive only the NIP-06 key and the old id. Strip every mention of funds from the copy. | nsec only. Simpler, but a Bennu user can no longer move to Giza with the same npub, which is the reason the rebrand kept the tags. Twelve words are also a friendlier backup than an nsec, and NIP-06 is nostr's own standard for them. |
| W3 | A Lightning invoice in a note | **Show it as a link** that opens the device's own wallet (`lightning:` through `UriHandler`). | Keep the decoded card. It needs lightning-kmp's `Bolt11Invoice`, which Phase 7 otherwise drops. Paying from the card is already dead: `NoteActions.onPayInvoice` is never assigned. |
| W4 | A Bennu peer's wallet proposal in a mixed group | **Decline it, with a reason**, and show one line saying Giza does not sign for wallets (constraint 3). | Ignore it. That is silent, so the group waits on Giza. Or keep enough checking code to sign, which keeps most of `GuardianManager`, `GuardianDerivation` and the policy reads, and so most of Phase 3. |
| W5 | Making a subgroup of a group whose certificate says `wallet=guarded` | **Giza does not offer it there**, and says why. A Bennu signer refuses an unguarded child of a guarded parent (`SubgroupManager.kt:401-405`), so the ceremony could never finish. | Offer it and let it fail at signing. |
+5
View File
@@ -852,6 +852,11 @@ is named under out of scope. Landing's *create profile* keeps making a seed; if
the product decides the first profile should be a bare key as well, that is the
same writer swapped in one more place.
> **Superseded for Landing** by [recovery-code-v3.md](./recovery-code-v3.md), Phase 7:
> Landing's writer is `recoveryCodeProfileWriter`, which makes a nine-block recovery code
> and writes its 24 words to `seed.dat`; `seedProfileWriter` is gone, and
> `CreateProfileRoute.withWallet` is `withBackup`. The switcher still makes a bare key.
**And *end this* goes.** It wipes the database — every profile's rooms, MLS state,
key packages and queues — from a screen whose purpose is to add a profile, and it
was only ever a development exit. Remove the button and the string;
+22 -2
View File
@@ -12,11 +12,31 @@ that what it derives is pinned byte for byte. A recovery code is a 24-word phras
notation: its key is BIP39 entropy, so it derives through `PhraseKeys` as it stands, and
nothing here changes what a phrase derives.
**Planned, not built.** Phases 1–8, one commit each, in the order given. Phases 1–6 make a
**Built**, phases 1–8, one commit each, in the order given (Phase 3 is two: the library
commit on the submodule's `claude/recovery-codes` branch, and the bump). Phases 1–6 make a
code something Giza can read, restore and show; only Phase 7 makes it something Giza
*hands out*. That order is the spec's own safety rule (§11.1) applied to a single app: no
build may give a person a code that the same build cannot restore, or cannot show them
again.
again. The phases are kept as written because they are the reasoning; where the
implementation chose differently the table below says so:
| what the plan said | what it turned out to be |
|---|---|
| `RecoveryCodeParse` beside the type, with a `Kind` | `RecoveryCode.Parse`, nested, and a public `RecoveryCodeProblem` enum the internal `RecoveryCodeFormat` shares — a public `Invalid` cannot carry an internal type |
| a typo is located when the checksum fails | whatever the first failure, for a 36-symbol input: a mistyped version symbol (`LC…`) fails normalisation before it reaches the checksum, and the spec's own vectors locate it |
| every v2 and v3 `private_key` row through the type | the v3 rows through `RecoveryCode.rootKey`; the v2 rows through the same HMAC called directly, because `RecoveryCode` will not hold a version 2 code |
| `writeRecoveryCode` returning `Written(id)` | `Written(id, isNew)`. Attaching a code to the phrase profile its words already made writes the code alone and skips the new-profile preparation, which would otherwise reset that profile's preferences |
| codes attached in the listing | in `StoredIdentity.merge`, last, with `parseCodes` dropping a stored code that does not parse; `DefaultIdentity` reads the codes too, so a background sync runs as the right kind |
| a refusal "gains an optional suggestion" | `Refused(problem, suggestion)`, and the sign-in view model holds it as `typoSuggestion` with `acceptSuggestion()`; the screen shows the corrected code itself above a *Use this code* button, not only the block and character |
| a checksum failure with no unique suggestion | the same `RecoveryCodeTypo` problem, without a suggestion: the sentence is "There's a typo in this code", which is what the spec's §11.4 asks for |
| `RecoveryPhraseViewModel` becomes `RecoveryBackupViewModel` | a `RecoveryCodeViewModel` and `RecoveryCodeScreen` of their own; the phrase screen is unchanged, and the code screen's error state links to it, since every code profile is also its words in `seed.dat` |
| "after *I have written it down*", two blocks | the two blocks *are* the confirmation: a match records the backup, and there is no checkbox to tick past it. Skipping is not checking, and the reminder stays |
| the words "behind a reveal of their own" | under a revealed code only, derived from it in memory: no second read of the keystore |
| a code round trip in `MultipleProfilesRoundTripJvmTest` | there, A is now made by `recoveryCodeProfileWriter` and listed as `RecoveryCode`; the empty-device round trip — the code, then its words — is in `IdentityWriterJvmTest`, where the files can be deleted between writes |
Not verified here: the iOS target was not compiled, and the screens were not run on a
device. The library commit is on a local branch of the submodule and has to be pushed with
this branch before anything else can build it.
## The format