Merge pull request #6502 from bhandras/musig-fix

signer: fix crash in `MuSig2Combine` when the final signature isn't ready
This commit is contained in:
Oliver Gugger 2022-05-06 13:24:27 +02:00 committed by GitHub
commit 5d8fba6810
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 4 deletions

View File

@ -85,6 +85,8 @@ to Bitcoin nodes that advertise a Tor v3 onion service address.
* [Fixed an edge case where the lnd might be stuck at starting due to channel
arbitrator relying on htlcswitch to be started
first](https://github.com/lightningnetwork/lnd/pull/6214).
* [Fixed crash in MuSig2Combine](https://github.com/lightningnetwork/lnd/pull/6502)
## Neutrino

View File

@ -938,10 +938,15 @@ func (s *Server) MuSig2CombineSig(_ context.Context,
return nil, fmt.Errorf("error combining signatures: %v", err)
}
return &MuSig2CombineSigResponse{
resp := &MuSig2CombineSigResponse{
HaveAllSignatures: haveAllSigs,
FinalSignature: finalSig.Serialize(),
}, nil
}
if haveAllSigs {
resp.FinalSignature = finalSig.Serialize()
}
return resp, err
}
// MuSig2Cleanup removes a session from memory to free up resources.

View File

@ -902,6 +902,20 @@ func testTaprootMuSig2CombinedLeafKeySpend(ctxt context.Context, t *harnessTest,
)
require.NoError(t.t, err)
// Before we have all partial signatures, we shouldn't get a final
// signature back.
combineSigResp, err := alice.SignerClient.MuSig2CombineSig(
ctxt, &signrpc.MuSig2CombineSigRequest{
SessionId: sessResp1.SessionId,
OtherPartialSignatures: [][]byte{
signResp2.LocalPartialSignature,
},
},
)
require.NoError(t.t, err)
require.False(t.t, combineSigResp.HaveAllSignatures)
require.Empty(t.t, combineSigResp.FinalSignature)
signResp3, err := alice.SignerClient.MuSig2Sign(
ctxt, &signrpc.MuSig2SignRequest{
SessionId: sessResp3.SessionId,
@ -935,7 +949,6 @@ func testTaprootMuSig2CombinedLeafKeySpend(ctxt context.Context, t *harnessTest,
ctxt, &signrpc.MuSig2CombineSigRequest{
SessionId: sessResp1.SessionId,
OtherPartialSignatures: [][]byte{
signResp2.LocalPartialSignature,
signResp3.LocalPartialSignature,
},
},