input+signrpc+lnwallet+multi: implement combined nonce support

Add CombinedNonce() and RegisterCombinedNonce() methods with full implementation
stack.

Interface and core implementation:
- input/musig2.go: Added methods to MuSig2Session and MuSig2Signer interfaces
- input/musig2_session_manager.go: MusigSessionManager implementation using
  HaveAllNonces flag for state tracking (simplified, no extra fields)
- internal/musig2v040: Stub implementations returning ErrUnsupportedMethod
- Mock implementations (MockInputSigner, MockSigner, DummySigner)

RPC layer:
- lnrpc/signrpc/signer.proto: RPC method definitions and messages
- lnrpc/signrpc/signer.yaml: REST API endpoint mappings
- Generated protobuf code (all .pb.go files)
- lnwallet/rpcwallet/rpcwallet.go: RPCKeyRing client implementation

The proto types and RPCKeyRing are added together since RPCKeyRing implements
the Signer interface and requires proto types to fulfill the contract.

For v0.4.0, these methods return ErrUnsupportedMethod. Use MuSig2Version100RC2
to access these features.
This commit is contained in:
Elle Mouton committed 2025-12-10 07:15:06 +02:00
1 parent cbcb6a4dcf
commit c945f6749e
15 files changed
+1204 -175

No files matched your search

+53
View File
@@ -780,6 +780,59 @@ func (r *RPCKeyRing) MuSig2RegisterNonces(sessionID input.MuSig2SessionID,
return resp.HaveAllNonces, nil
}
// MuSig2RegisterCombinedNonce registers a pre-aggregated combined nonce for a
// session identified by its ID. This is an alternative to MuSig2RegisterNonces
// and is used when a coordinator has already aggregated all individual nonces.
func (r *RPCKeyRing) MuSig2RegisterCombinedNonce(
sessionID input.MuSig2SessionID,
combinedNonce [musig2.PubNonceSize]byte) error {
req := &signrpc.MuSig2RegisterCombinedNonceRequest{
SessionId: sessionID[:],
CombinedPublicNonce: combinedNonce[:],
}
ctxt, cancel := context.WithTimeout(context.Background(), r.rpcTimeout)
defer cancel()
_, err := r.signerClient.MuSig2RegisterCombinedNonce(ctxt, req)
if err != nil {
considerShutdown(err)
return fmt.Errorf("error registering MuSig2 combined nonce "+
"in remote signer instance: %v", err)
}
return nil
}
// MuSig2GetCombinedNonce retrieves the combined nonce for a session identified
// by its ID.
func (r *RPCKeyRing) MuSig2GetCombinedNonce(sessionID input.MuSig2SessionID) (
[musig2.PubNonceSize]byte, error) {
req := &signrpc.MuSig2GetCombinedNonceRequest{
SessionId: sessionID[:],
}
ctxt, cancel := context.WithTimeout(context.Background(), r.rpcTimeout)
defer cancel()
resp, err := r.signerClient.MuSig2GetCombinedNonce(ctxt, req)
if err != nil {
considerShutdown(err)
return [musig2.PubNonceSize]byte{}, fmt.Errorf("error getting "+
"MuSig2 combined nonce from remote signer instance: %v",
err)
}
var combinedNonce [musig2.PubNonceSize]byte
copy(combinedNonce[:], resp.CombinedPublicNonce)
return combinedNonce, nil
}
// MuSig2Sign creates a partial signature using the local signing key
// that was specified when the session was created. This can only be
// called when all public nonces of all participants are known and have