multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease review: - 2d746f68: replace imports - 4008f0fd: use ecdsa.Signature - 849e33d1: remove btcec.S256() - b8f6ebbd: use v2 library correctly - fa80bca9: bump go modules
This commit is contained in:
350 files changed
+2421
-1289
No files matched your search
@@ -7,7 +7,7 @@ import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/brontide"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
@@ -37,7 +37,7 @@ var (
|
||||
return nil, err
|
||||
}
|
||||
|
||||
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), eBytes)
|
||||
priv, _ := btcec.PrivKeyFromBytes(eBytes)
|
||||
return priv, nil
|
||||
})
|
||||
|
||||
@@ -50,7 +50,7 @@ var (
|
||||
return nil, err
|
||||
}
|
||||
|
||||
priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), eBytes)
|
||||
priv, _ := btcec.PrivKeyFromBytes(eBytes)
|
||||
return priv, nil
|
||||
})
|
||||
)
|
||||
@@ -99,12 +99,6 @@ func handshake(initiator, responder *brontide.Machine) error {
|
||||
// nilAndPanic first nils the initiator and responder's Curve fields and then
|
||||
// panics.
|
||||
func nilAndPanic(initiator, responder *brontide.Machine, err error) {
|
||||
if initiator != nil {
|
||||
initiator.SetCurveToNil()
|
||||
}
|
||||
if responder != nil {
|
||||
responder.SetCurveToNil()
|
||||
}
|
||||
panic(fmt.Errorf("error: %v, initiator: %v, responder: %v", err,
|
||||
spew.Sdump(initiator), spew.Sdump(responder)))
|
||||
}
|
||||
@@ -112,8 +106,8 @@ func nilAndPanic(initiator, responder *brontide.Machine, err error) {
|
||||
// getBrontideMachines returns two brontide machines that use random keys
|
||||
// everywhere.
|
||||
func getBrontideMachines() (*brontide.Machine, *brontide.Machine) {
|
||||
initPriv, _ := btcec.NewPrivateKey(btcec.S256())
|
||||
respPriv, _ := btcec.NewPrivateKey(btcec.S256())
|
||||
initPriv, _ := btcec.NewPrivateKey()
|
||||
respPriv, _ := btcec.NewPrivateKey()
|
||||
respPub := (*btcec.PublicKey)(&respPriv.PublicKey)
|
||||
|
||||
initPrivECDH := &keychain.PrivKeyECDH{PrivKey: initPriv}
|
||||
@@ -128,8 +122,8 @@ func getBrontideMachines() (*brontide.Machine, *brontide.Machine) {
|
||||
// getStaticBrontideMachines returns two brontide machines that use static keys
|
||||
// everywhere.
|
||||
func getStaticBrontideMachines() (*brontide.Machine, *brontide.Machine) {
|
||||
initPriv, _ := btcec.PrivKeyFromBytes(btcec.S256(), initBytes)
|
||||
respPriv, respPub := btcec.PrivKeyFromBytes(btcec.S256(), respBytes)
|
||||
initPriv, _ := btcec.PrivKeyFromBytes(initBytes)
|
||||
respPriv, respPub := btcec.PrivKeyFromBytes(respBytes)
|
||||
|
||||
initPrivECDH := &keychain.PrivKeyECDH{PrivKey: initPriv}
|
||||
respPrivECDH := &keychain.PrivKeyECDH{PrivKey: respPriv}
|
||||
|
||||
@@ -7,7 +7,8 @@ import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcec/v2/ecdsa"
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/lightningnetwork/lnd/zpay32"
|
||||
@@ -27,16 +28,14 @@ func Fuzz_encode(data []byte) int {
|
||||
|
||||
// Initialize the static key we will be using for this fuzz test.
|
||||
testPrivKeyBytes, _ := hex.DecodeString("e126f68f7eafcc8b74f54d269fe206be715000f94dac067d1c04a8ca3b2db734")
|
||||
testPrivKey, _ := btcec.PrivKeyFromBytes(btcec.S256(), testPrivKeyBytes)
|
||||
testPrivKey, _ := btcec.PrivKeyFromBytes(testPrivKeyBytes)
|
||||
|
||||
// Then, initialize the testMessageSigner so we can encode out
|
||||
// invoices with this private key.
|
||||
testMessageSigner := zpay32.MessageSigner{
|
||||
SignCompact: func(msg []byte) ([]byte, error) {
|
||||
hash := chainhash.HashB(msg)
|
||||
sig, err := btcec.SignCompact(
|
||||
btcec.S256(), testPrivKey, hash, true,
|
||||
)
|
||||
sig, err := ecdsa.SignCompact(testPrivKey, hash, true)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't sign the "+
|
||||
"message: %v", err)
|
||||
|
||||
Reference in new issue
Block a user