mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-01 18:27:43 +02:00
multi: implement MuSig2 RPCs and remote signing
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
package mock
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||
"github.com/btcsuite/btcd/btcec/v2/schnorr/musig2"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
@@ -47,6 +50,50 @@ func (d *DummySigner) ComputeInputScript(tx *wire.MsgTx,
|
||||
return &input.Script{}, 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 (d *DummySigner) MuSig2CreateSession(keychain.KeyLocator,
|
||||
[]*btcec.PublicKey, *input.MuSig2Tweaks,
|
||||
[][musig2.PubNonceSize]byte) (*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 (d *DummySigner) 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 (d *DummySigner) 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 (d *DummySigner) MuSig2CombineSig(input.MuSig2SessionID,
|
||||
[]*musig2.PartialSignature) (*schnorr.Signature, bool, error) {
|
||||
|
||||
return nil, false, nil
|
||||
}
|
||||
|
||||
// SingleSigner is an implementation of the Signer interface that signs
|
||||
// everything with a single private key.
|
||||
type SingleSigner struct {
|
||||
@@ -136,3 +183,47 @@ 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(keychain.KeyLocator,
|
||||
[]*btcec.PublicKey, *input.MuSig2Tweaks,
|
||||
[][musig2.PubNonceSize]byte) (*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
|
||||
}
|
||||
|
Reference in New Issue
Block a user