lnwire: update Sig to support both ECDSA and schnorr sigs

In this commit, we update the Sig type to support ECDSA and schnorr
signatures. We need to do this as the HTLC signatures will become
schnorr sigs for taproot channels. The current spec draft opts to
overload this field since both the sigs are actually 64 bytes in length.
The only consideration with this move is that callers need to "coerce" a
sig to the proper type if they need schnorr signatures.
This commit is contained in:
Olaoluwa Osuntokun committed 2023-08-22 16:29:19 -07:00
1 parent eccc77315b
commit b368e476c5
29 files changed
+296 -128

No files matched your search

@@ -320,8 +320,8 @@ func testJusticeDescriptor(t *testing.T, blobType blob.Type) {
require.Nil(t, err)
// Complete our justice kit by copying the signatures into the payload.
copy(justiceKit.CommitToLocalSig[:], toLocalSig[:])
copy(justiceKit.CommitToRemoteSig[:], toRemoteSig[:])
justiceKit.CommitToLocalSig = toLocalSig
justiceKit.CommitToRemoteSig = toRemoteSig
justiceDesc := &lookout.JusticeDescriptor{
BreachedCommitTx: breachTxn,
+9 -2
View File
@@ -10,6 +10,7 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/chainntnfs"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/watchtower/blob"
"github.com/lightningnetwork/lnd/watchtower/lookout"
"github.com/lightningnetwork/lnd/watchtower/wtdb"
@@ -57,6 +58,12 @@ func makeArray64(i uint64) [64]byte {
return arr
}
func makeTestSig(i uint64) lnwire.Sig {
sigBytes := makeArray64(i)
sig, _ := lnwire.NewSigFromWireECDSA(sigBytes[:])
return sig
}
func makeAddrSlice(size int) []byte {
addr := make([]byte, size)
if _, err := io.ReadFull(rand.Reader, addr); err != nil {
@@ -141,7 +148,7 @@ func TestLookoutBreachMatching(t *testing.T) {
RevocationPubKey: makePubKey(1),
LocalDelayPubKey: makePubKey(1),
CSVDelay: 144,
CommitToLocalSig: makeArray64(1),
CommitToLocalSig: makeTestSig(1),
}
blob2 := &blob.JusticeKit{
BlobType: blobType,
@@ -149,7 +156,7 @@ func TestLookoutBreachMatching(t *testing.T) {
RevocationPubKey: makePubKey(2),
LocalDelayPubKey: makePubKey(2),
CSVDelay: 144,
CommitToLocalSig: makeArray64(2),
CommitToLocalSig: makeTestSig(2),
}
key1 := blob.NewBreachKeyFromHash(&hash1)