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
2023-01-16 19:33:21 -08:00
parent eccc77315b
commit b368e476c5
29 changed files with 296 additions and 128 deletions

View File

@@ -147,7 +147,9 @@ func TestWriteShortChannelID(t *testing.T) {
func TestWriteSig(t *testing.T) {
buf := new(bytes.Buffer)
data := Sig{1, 2, 3}
data := Sig{
bytes: [64]byte{1, 2, 3},
}
expectedBytes := [64]byte{1, 2, 3}
err := WriteSig(buf, data)
@@ -158,14 +160,14 @@ func TestWriteSig(t *testing.T) {
func TestWriteSigs(t *testing.T) {
buf := new(bytes.Buffer)
sig1, sig2, sig3 := Sig{1}, Sig{2}, Sig{3}
sig1, sig2, sig3 := Sig{bytes: [64]byte{1}}, Sig{bytes: [64]byte{2}}, Sig{bytes: [64]byte{3}}
data := []Sig{sig1, sig2, sig3}
// First two bytes encode the length of the slice.
expectedBytes := []byte{0, 3}
expectedBytes = append(expectedBytes, sig1[:]...)
expectedBytes = append(expectedBytes, sig2[:]...)
expectedBytes = append(expectedBytes, sig3[:]...)
expectedBytes = append(expectedBytes, sig1.bytes[:]...)
expectedBytes = append(expectedBytes, sig2.bytes[:]...)
expectedBytes = append(expectedBytes, sig3.bytes[:]...)
err := WriteSigs(buf, data)