test: pin a recovery phrase's npub, profile id and host key (wallet removal, Phase 0)

Through LocalKeyManager, the code Phase 6 replaces, on NIP-06's own test
vector. A different npub would be a different person, and a different id
would lose the profile's preference files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kgothatso NgakoandClaude Opus 5.5 committed 2026-11-18 14:59:22 +02:00
1 parent 60e878e74f
commit 94b45c0bc8
2 files changed
+43 -2

No files matched your search

@@ -5,6 +5,12 @@ import fr.acinq.bitcoin.Chain
import fr.acinq.bitcoin.PrivateKey
import fr.acinq.bitcoin.byteVector32
import fr.acinq.secp256k1.Hex
import mobi.giza.compose.identity.StoredIdentity
import fr.acinq.lightning.crypto.LocalKeyManager
import fr.acinq.phoenix.data.WalletId
import fr.acinq.phoenix.managers.NodeParamsManager
import fr.acinq.bitcoin.MnemonicCode
import fr.acinq.bitcoin.byteVector
import mobi.giza.compose.nostr.wallet.MemberWalletRequestEvent
import kotlin.test.Test
import kotlin.test.assertEquals
@@ -105,7 +111,35 @@ class ForkCompatibilityTest {
assertEquals(PINNED_GUARDIAN_CHILD_INDEX, GuardianDerivation.childIndex(room))
}
// NIP-06's own test vector, and the id this app files a recovery phrase's profile under.
//
// Pinned through the code docs/giza-wallet-removal.md Phase 6 replaces: lightning-kmp's
// LocalKeyManager, which derives the nostr key at m/44'/1237'/0'/0/0 and the node key the
// id is the hash160 of. Phase 6 derives both without it, and has to land on these values
// byte for byte -- a different npub is a different person, and a different id loses the
// profile's preference files without a word.
@Test
fun `a recovery phrase's npub, profile id and host key`() {
val words = PHRASE.split(" ")
val secret = StoredIdentity.nostrPrivateKeyOf(words)
assertEquals(PINNED_PHRASE_SECRET, secret.value.toHex())
assertEquals(PINNED_PHRASE_NPUB, StoredIdentity.nostrPublicKeyOf(words))
val nodeId = LocalKeyManager(
seed = MnemonicCode.toSeed(words, "").byteVector(),
chain = NodeParamsManager.chain,
remoteSwapInExtendedPublicKey = NodeParamsManager.remoteSwapInXpub,
).nodeKeys.nodeKey.publicKey
assertEquals(PINNED_PHRASE_PROFILE_ID, WalletId(nodeId).nodeIdHash)
assertEquals(PINNED_PHRASE_HOST_KEY, ChillDkgRitualManager.deriveHostPublicKey(secret.value.toByteArray()).toString())
}
companion object {
/** NIP-06's test vector: https://github.com/nostr-protocol/nips/blob/master/06.md */
const val PHRASE = "leader monkey parrot ring guide accident before fence cannon height naive bean"
const val PINNED_PHRASE_SECRET = "7f7ff03d123792d6ac594bfa67bf6d0c0ab55b6b1fdb6249303fe861f1ccba9a"
const val PINNED_PHRASE_NPUB = "17162c921dc4d2518f9a101db33695df1afb56ab82f5ff3e5da6eec3ca5cd917"
const val PINNED_PHRASE_PROFILE_ID = "c0d0687be5cc7bb9cf053697868bdbcdbc1c0530"
const val PINNED_PHRASE_HOST_KEY = "03b93ca2ea2bac313457180953bbede99450d59ce01916e98d42df09fdabbbe83f"
const val PINNED_HOST_KEY = "028871ab105eac8812fa7aab4b9110ad20b5dcfba9f65271431dcb417258da08af"
const val PINNED_SHARED_KEY = "5eb33e9c2a5a90ae4d273b687eb1265f8b79c2bcee28f9ae9dc44dba6e788444"
const val PINNED_PAYMENT_BASEPOINT = "02973930314ffd75c72fc909bc0b3586b7f2f1196d6423281a24eec32671f3b510"
+9 -2
View File
@@ -11,8 +11,15 @@ Giza takes out every wallet it inherited from Bennu:
What is left is a chat app with groups. Those groups hold a FROST threshold key and sign
events with it, and they can still make subgroups.
This plan is phased. It is **not built**. It was written against `caf1fb18` on
`claude/giza-wallet-removal-plan-2668ff`. Paths below are under
This plan is phased, and is being built on `claude/giza-wallet-removal-plan-2668ff`, one commit
per phase, with the recommended column of [Decisions](#decisions) taken throughout. It was
written against `caf1fb18`.
### Where the build stands
| phase | state |
|---|---|
| 0 | the baseline: `jvmTest` 1,651 run, 0 failed, 2 skipped (the regtest pair); `m3-audit` clean, with **adaptive APIs at 12 against a floor of 12**, none of them in wallet code; `brand-audit` clean. `ForkCompatibilityTest` pins a recovery phrase's secret, npub, profile id and host key, on NIP-06's own test vector. 0.4: a refused proposal is **silent** today (`acceptProposal` logs and returns null), so Phase 1 adds the decline | Paths below are under
`composeApp/src/commonMain/kotlin/mobi/giza/compose/` unless they say otherwise. Line numbers
were right at that commit; confirm them with a grep before using them.