From 91e855d59ab5e79bf6400f9358304d96f6a6d998 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 26 Jul 2023 17:03:04 -0700 Subject: [PATCH] lntest: update SingleMockSigner to support musig2 --- lntest/mock/signer.go | 66 +++++++++++-------------------------------- 1 file changed, 16 insertions(+), 50 deletions(-) diff --git a/lntest/mock/signer.go b/lntest/mock/signer.go index 7ce6cf4e0..5f21437e7 100644 --- a/lntest/mock/signer.go +++ b/lntest/mock/signer.go @@ -105,6 +105,22 @@ func (d *DummySigner) MuSig2Cleanup(input.MuSig2SessionID) error { type SingleSigner struct { Privkey *btcec.PrivateKey KeyLoc keychain.KeyLocator + + *input.MusigSessionManager +} + +func NewSingleSigner(privkey *btcec.PrivateKey) *SingleSigner { + signer := &SingleSigner{ + Privkey: privkey, + KeyLoc: idKeyLoc, + } + + keyFetcher := func(*keychain.KeyDescriptor) (*btcec.PrivateKey, error) { + return signer.Privkey, nil + } + signer.MusigSessionManager = input.NewMusigSessionManager(keyFetcher) + + return signer } // SignOutputRaw generates a signature for the passed transaction using the @@ -189,53 +205,3 @@ func (s *SingleSigner) SignMessage(keyLoc keychain.KeyLocator, } return ecdsa.Sign(s.Privkey, digest), nil } - -// MuSig2CreateSession creates a new MuSig2 signing session using the local -// key identified by the key locator. The complete list of all public keys of -// all signing parties must be provided, including the public key of the local -// signing key. If nonces of other parties are already known, they can be -// submitted as well to reduce the number of method calls necessary later on. -func (s *SingleSigner) MuSig2CreateSession(input.MuSig2Version, - keychain.KeyLocator, []*btcec.PublicKey, *input.MuSig2Tweaks, - [][musig2.PubNonceSize]byte, - ...musig2.SessionOption) (*input.MuSig2SessionInfo, error) { - - return nil, nil -} - -// MuSig2RegisterNonces registers one or more public nonces of other signing -// participants for a session identified by its ID. This method returns true -// once we have all nonces for all other signing participants. -func (s *SingleSigner) MuSig2RegisterNonces(input.MuSig2SessionID, - [][musig2.PubNonceSize]byte) (bool, error) { - - return false, 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 -// been registered with the session. If this node isn't responsible for -// combining all the partial signatures, then the cleanup parameter -// should be set, indicating that the session can be removed from memory -// once the signature was produced. -func (s *SingleSigner) MuSig2Sign(input.MuSig2SessionID, - [sha256.Size]byte, bool) (*musig2.PartialSignature, error) { - - return nil, nil -} - -// MuSig2CombineSig combines the given partial signature(s) with the -// local one, if it already exists. Once a partial signature of all -// participants is registered, the final signature will be combined and -// returned. -func (s *SingleSigner) MuSig2CombineSig(input.MuSig2SessionID, - []*musig2.PartialSignature) (*schnorr.Signature, bool, error) { - - return nil, false, nil -} - -// MuSig2Cleanup removes a session from memory to free up resources. -func (s *SingleSigner) MuSig2Cleanup(input.MuSig2SessionID) error { - return nil -}