mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-29 03:01:52 +01:00
itest: add itest for MuSig2 CombineKey
Before we change anything in the MuSig2 API, we first add an integration test that makes sure the current version of the API combines keys according to the v0.4.0 test vectors.
This commit is contained in:
parent
5d22d5eb6c
commit
ff8f1371b5
@ -35,11 +35,14 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
dummyInternalKeyBytes, _ = hex.DecodeString(
|
||||
hexDecode = func(keyStr string) []byte {
|
||||
keyBytes, _ := hex.DecodeString(keyStr)
|
||||
return keyBytes
|
||||
}
|
||||
dummyInternalKey, _ = btcec.ParsePubKey(hexDecode(
|
||||
"03464805f5468e294d88cf15a3f06aef6c89d63ef1bd7b42db2e0c74c1ac" +
|
||||
"eb90fe",
|
||||
)
|
||||
dummyInternalKey, _ = btcec.ParsePubKey(dummyInternalKeyBytes)
|
||||
))
|
||||
)
|
||||
|
||||
// testTaproot ensures that the daemon can send to and spend from taproot (p2tr)
|
||||
@ -61,6 +64,7 @@ func testTaproot(ht *lntemp.HarnessTest) {
|
||||
testTaprootMuSig2KeySpendRootHash(ht, ht.Alice)
|
||||
testTaprootMuSig2ScriptSpend(ht, ht.Alice)
|
||||
testTaprootMuSig2CombinedLeafKeySpend(ht, ht.Alice)
|
||||
testMuSig2CombineKey(ht, ht.Alice)
|
||||
|
||||
testTaprootImportTapscriptFullTree(ht, ht.Alice)
|
||||
testTaprootImportTapscriptPartialReveal(ht, ht.Alice)
|
||||
@ -1856,3 +1860,41 @@ func testTaprootCoopClose(ht *lntemp.HarnessTest) {
|
||||
require.False(ht, assertTaprootDeliveryUsed(closingTxid),
|
||||
"taproot addr shouldn't be used!")
|
||||
}
|
||||
|
||||
// testMuSig2CombineKey makes sure that combining a key with MuSig2 returns the
|
||||
// correct result according to the MuSig2 version specified.
|
||||
func testMuSig2CombineKey(ht *lntemp.HarnessTest, alice *node.HarnessNode) {
|
||||
testVector040Key1 := hexDecode(
|
||||
"F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE0" +
|
||||
"36F9",
|
||||
)
|
||||
testVector040Key2 := hexDecode(
|
||||
"DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502B" +
|
||||
"A659",
|
||||
)
|
||||
testVector040Key3 := hexDecode(
|
||||
"3590A94E768F8E1815C2F24B4D80A8E3149316C3518CE7B7AD338368D038" +
|
||||
"CA66",
|
||||
)
|
||||
|
||||
resp := alice.RPC.MuSig2CombineKeys(&signrpc.MuSig2CombineKeysRequest{
|
||||
AllSignerPubkeys: [][]byte{
|
||||
testVector040Key1, testVector040Key2,
|
||||
testVector040Key3,
|
||||
},
|
||||
TaprootTweak: &signrpc.TaprootTweakDesc{
|
||||
KeySpendOnly: true,
|
||||
},
|
||||
})
|
||||
|
||||
expectedFinalKey := hexDecode(
|
||||
"5b257b4e785d61157ef5303051f45184bd5cb47bc4b4069ed4dd453645" +
|
||||
"9cb83b",
|
||||
)
|
||||
expectedPreTweakKey := hexDecode(
|
||||
"d70cd69a2647f7390973df48cbfa2ccc407b8b2d60b08c5f1641185c79" +
|
||||
"98a290",
|
||||
)
|
||||
require.Equal(ht, expectedFinalKey, resp.CombinedKey)
|
||||
require.Equal(ht, expectedPreTweakKey, resp.TaprootInternalKey)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user