From 1ccf0e71123770902da2cfe5ce98cd201e02cf97 Mon Sep 17 00:00:00 2001 From: babyhalimao Date: Sun, 20 Oct 2024 14:46:16 +0800 Subject: [PATCH] chore: use decred secp256k1 directly --- waku/v2/utils/crypto.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/waku/v2/utils/crypto.go b/waku/v2/utils/crypto.go index 0b0f2c0e5..2c15780db 100644 --- a/waku/v2/utils/crypto.go +++ b/waku/v2/utils/crypto.go @@ -3,21 +3,21 @@ package utils import ( "crypto/ecdsa" - "github.com/btcsuite/btcd/btcec/v2" + "github.com/decred/dcrd/dcrec/secp256k1/v4" "github.com/libp2p/go-libp2p/core/crypto" ) // EcdsaPubKeyToSecp256k1PublicKey converts an `ecdsa.PublicKey` into a libp2p `crypto.Secp256k1PublicKey“ func EcdsaPubKeyToSecp256k1PublicKey(pubKey *ecdsa.PublicKey) *crypto.Secp256k1PublicKey { - xFieldVal := &btcec.FieldVal{} - yFieldVal := &btcec.FieldVal{} + xFieldVal := &secp256k1.FieldVal{} + yFieldVal := &secp256k1.FieldVal{} xFieldVal.SetByteSlice(pubKey.X.Bytes()) yFieldVal.SetByteSlice(pubKey.Y.Bytes()) - return (*crypto.Secp256k1PublicKey)(btcec.NewPublicKey(xFieldVal, yFieldVal)) + return (*crypto.Secp256k1PublicKey)(secp256k1.NewPublicKey(xFieldVal, yFieldVal)) } // EcdsaPrivKeyToSecp256k1PrivKey converts an `ecdsa.PrivateKey` into a libp2p `crypto.Secp256k1PrivateKey“ func EcdsaPrivKeyToSecp256k1PrivKey(privKey *ecdsa.PrivateKey) *crypto.Secp256k1PrivateKey { - privK, _ := btcec.PrivKeyFromBytes(privKey.D.Bytes()) + privK := secp256k1.PrivKeyFromBytes(privKey.D.Bytes()) return (*crypto.Secp256k1PrivateKey)(privK) }