test: a confederation signs as its room's id, and today's answer to its kinds (confederation, Phase 1)

SharedKeyDerivation.Derived carries the tweak scalars it applied, so a
key held some other way can reach the same room key. The three premises
of the plan pass: the room-id derivation replays under a confederation
key, NIP-44 seals reproduce byte for byte, and the new kinds currently
reach the member unrefused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kgothatso NgakoandClaude Opus 5.5 committed 2026-11-21 21:39:06 +02:00
1 parent e84fc9b599
commit abe555e57c
8 files changed
+411 -52

No files matched your search

@@ -86,7 +86,14 @@ object SharedKeyDerivation {
*/
data class Derived(
val cache: TweakCache,
val publicKey: XonlyPublicKey
val publicKey: XonlyPublicKey,
/**
* The x-only scalars [cache] applied, in order. A key held some other way -- a
* confederation's, whose signing takes a list of tweaks rather than a cache --
* reaches the same derived key by applying exactly these, and nothing else may
* recompute them: the scalar for each step commits to the key before it.
*/
val tweaks: List<ByteVector32> = emptyList()
) {
/** The x-only key as 32-byte hex — the form nostr and Marmot both use. */
val hex: HexKey get() = publicKey.value.toHex()
@@ -195,9 +202,11 @@ object SharedKeyDerivation {
// derived -- returns exactly what a session created from this cache would
// produce a signature against.
var current = cache.tweakedPublicKey
val tweaks = mutableListOf<ByteVector32>()
path.forEach { index ->
val scalar = tweakScalar(current, index)
tweaks += scalar
when (val tweaked = cache.tweak(scalar, isXonly = true)) {
is Either.Left -> throw IllegalArgumentException(
@@ -212,7 +221,7 @@ object SharedKeyDerivation {
}
}
return Derived(cache = cache, publicKey = current)
return Derived(cache = cache, publicKey = current, tweaks = tweaks)
}
/**