test: Giza derives what Bennu derives, every tag pinned (fork, Phase 8)

ForkCompatibilityTest pins each mantra/ and bennu/ derivation tag through the
function that hashes it: the ChillDKG host key, the Marmot shared-key tweak,
the group Lightning basepoints, the Iceberg pool label and the session,
contribution, commitment, seed and transcript hashes, the member wallet id and
possession message, and the group wallet address and guardian root. A sweep
that renames one of them now fails a test rather than moving a group's coins
and splitting Giza from Bennu.

The vectors come from this tree. A diff against 4e106fb5 shows that the files
holding the tags differ only in packages, imports, comments and the database's
type name, so the vectors are Bennu's too.

docs/giza-rebrand.md gains a table of where the build stands and what turned
out differently, the twelve bennu/ tags first.

jvmTest: 1651 run (1643 + 8), 0 failed, 2 skipped. m3Audit and brandAudit pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kgothatso NgakoandClaude Opus 5.5 committed 2026-11-18 11:00:44 +02:00
1 parent c0f1b3d5e3
commit 851ff0c8c2
2 files changed
+148 -2

No files matched your search

@@ -0,0 +1,117 @@
package mobi.giza.compose.managers
import fr.acinq.bitcoin.ByteVector32
import fr.acinq.bitcoin.Chain
import fr.acinq.bitcoin.PrivateKey
import fr.acinq.bitcoin.byteVector32
import fr.acinq.secp256k1.Hex
import mobi.giza.compose.nostr.wallet.MemberWalletRequestEvent
import kotlin.test.Test
import kotlin.test.assertEquals
/**
* Giza derives what Bennu derives (docs/giza-rebrand.md, Phase 8).
*
* The fork kept every derivation tag it found -- `mantra/` and the twelve `bennu/` --
* because a Bennu peer and a Giza peer have to land on the same keys: in one group, in one
* key ceremony, and for a Bennu seed restored in Giza. Those tags look like brand strings,
* and the next sweep for a name is how they would change. Each one is pinned here, through
* the public function that hashes it, so that a renamed tag fails a test instead of
* silently moving a group's coins.
*
* The vectors were computed by this tree, whose derivation code is Bennu's at `4e106fb5`
* line for line (the fork changed packages and comments in those files, nothing else).
* Some are also pinned elsewhere -- GroupWalletDerivationTest and GuardianDerivationTest
* freeze their own tags -- and this file is the one place that says why every one of
* them must also match Bennu.
*/
class ForkCompatibilityTest {
private fun key(seed: Long): PrivateKey =
PrivateKey(ByteVector32(Hex.decode(seed.toString(16).padStart(64, '0'))))
private val threshold = key(0x91fa).publicKey().toString()
private val room = "00".repeat(31) + "2a"
private val ceremony = ByteVector32("11".repeat(32))
@Test
fun `mantra chilldkg host key`() {
assertEquals(
PINNED_HOST_KEY,
ChillDkgRitualManager.deriveHostPublicKey(key(0x5eed).value.toByteArray()).toString(),
)
}
@Test
fun `mantra shared key tweak at the marmot admin path`() {
assertEquals(PINNED_SHARED_KEY, SharedKeyDerivation.derive(threshold).hex)
}
@Test
fun `bennu group lightning basepoints`() {
val basepoints = GroupLightningDerivation.basepoints(threshold, Chain.Mainnet, 0L)
assertEquals(PINNED_PAYMENT_BASEPOINT, basepoints.payment.publicKey.toString())
assertEquals(PINNED_DELAYED_BASEPOINT, basepoints.delayedPayment.publicKey.toString())
}
@Test
fun `bennu iceberg pool label`() {
assertEquals(PINNED_POOL_LABEL, GroupLightningCoSigner.poolLabel(threshold, 7L).toHex())
}
@Test
fun `bennu iceberg dkg session, contribution, commitment and seed`() {
val params = IcebergDkg.Params.of(2, listOf(key(1).publicKey(), key(2).publicKey(), key(3).publicKey(), key(4).publicKey()), ceremony)
assertEquals(PINNED_ICEBERG_SESSION, params.sessionId.toHex())
val root = ByteVector32("22".repeat(32))
// The first seed participant 1 holds, and the contributions of everyone who holds it.
val rank = params.heldRanks(1).first()
val contribution = IcebergDkg.contribution(params, 1, root, rank)
assertEquals(PINNED_ICEBERG_CONTRIBUTION, contribution.toHex())
assertEquals(PINNED_ICEBERG_COMMITMENT, IcebergDkg.commitment(params, 1, rank, contribution).toHex())
val contributions = params.holders(params.subsets[rank]).map { IcebergDkg.contribution(params, it, root, rank) }
assertEquals(PINNED_ICEBERG_SEED, IcebergDkg.seed(params, rank, contributions).toHex())
}
@Test
fun `bennu iceberg dkg transcript`() {
val params = IcebergDkg.Params.of(2, listOf(key(1).publicKey(), key(2).publicKey(), key(3).publicKey(), key(4).publicKey()), ceremony)
val root = ByteVector32("22".repeat(32))
val commitments = (1..4).associateWith { IcebergDkg.round1(params, it, root) }
assertEquals(PINNED_ICEBERG_TRANSCRIPT, IcebergDkg.transcriptHash(params, commitments).toHex())
}
@Test
fun `bennu member wallet id and possession message`() {
val walletKey = key(0x3a11e7).publicKey()
assertEquals(PINNED_MEMBER_WALLET_ID, MemberWalletDerivation.walletId(walletKey))
assertEquals(
PINNED_POSSESSION_MESSAGE,
MemberWalletRequestEvent.possessionMessage(key(0xa11ce).publicKey().xOnly().value.toHex(), room, walletKey, Chain.Mainnet).toHex(),
)
}
@Test
fun `bennu group wallet account and guardian root`() {
assertEquals(PINNED_GROUP_ADDRESS, GroupWalletDerivation.derive(GroupWalletDerivation.account(threshold, Chain.Mainnet), GroupWalletDerivation.RECEIVE, 0L).address(Chain.Mainnet))
assertEquals(PINNED_GUARDIAN_ROOT, GuardianDerivation.root(threshold).publicKey.toString())
assertEquals(PINNED_GUARDIAN_CHILD_INDEX, GuardianDerivation.childIndex(room))
}
companion object {
const val PINNED_HOST_KEY = "028871ab105eac8812fa7aab4b9110ad20b5dcfba9f65271431dcb417258da08af"
const val PINNED_SHARED_KEY = "5eb33e9c2a5a90ae4d273b687eb1265f8b79c2bcee28f9ae9dc44dba6e788444"
const val PINNED_PAYMENT_BASEPOINT = "02973930314ffd75c72fc909bc0b3586b7f2f1196d6423281a24eec32671f3b510"
const val PINNED_DELAYED_BASEPOINT = "02531089bc88fe949dc54394b8bbb7db2439cb2865495bd239b4ecf0264904a270"
const val PINNED_POOL_LABEL = "9490bb167e551d6e247329d60392e0e9b127c978e9b3a89bd4ddbcb2c2f17b99"
const val PINNED_ICEBERG_SESSION = "fba343265271b4c2ee52d54cf4ea99963ae7205333e36b92af81d9d43aaaceed"
const val PINNED_ICEBERG_CONTRIBUTION = "bd11ce00c8d1a1a825395cd32116e606cba857644e7ef2823b03fedbba362360"
const val PINNED_ICEBERG_COMMITMENT = "ee2b1e4e0a92d2d2722a9149bb8f0487e2dc75d4cd9d76a9510a3e60153c960e"
const val PINNED_ICEBERG_SEED = "d68eeef4eafd2581b55e74e59eb7f6872b0aafd2afe12d3baf6d837fa916d755"
const val PINNED_ICEBERG_TRANSCRIPT = "a0e23009ad3462804bfef145de94ad23901bf188f6ea9a259a30e3db00509316"
const val PINNED_MEMBER_WALLET_ID = "2282987a87614b622a25500102158d65ed01165919f98bc372aa3d39c828d5db"
const val PINNED_POSSESSION_MESSAGE = "43a8cc800f2205edb6384d2758e53b40692859524255449521036f11cdca3396"
const val PINNED_GROUP_ADDRESS = "bc1paul0w26tuf9sm75htghayux7xf6vep4zsqrrm0sysawghqjkdm9smddcqp"
const val PINNED_GUARDIAN_ROOT = "03be02bea3b2feeb8d104c537db973f062211c89a2b82a0d2f9789184c260cbab4"
const val PINNED_GUARDIAN_CHILD_INDEX = 1976210374L
}
}