From 263c9ba10bce0e4c44d10e6443d520952d7c2d1d Mon Sep 17 00:00:00 2001 From: Bernardo Ramos Date: Fri, 1 Dec 2023 17:20:55 -0300 Subject: [PATCH 1/2] update btcec and remove btcd --- account/key/aergo_storage_test.go | 6 +++--- account/key/badgerdb.go | 4 ++-- account/key/badgerdb_test.go | 6 +++--- account/key/crypto/address_test.go | 6 +++--- account/key/crypto/strategy.go | 2 +- account/key/crypto/v1strategy.go | 4 ++-- account/key/crypto/v1strategy_test.go | 4 ++-- account/key/sign.go | 17 ++++++---------- account/key/storage.go | 2 +- account/key/store.go | 10 ++++----- account/key/store_test.go | 4 ++-- chain/signverifier_test.go | 6 +++--- cmd/aergocli/cmd/keygen.go | 4 ++-- cmd/aergocli/cmd/signtx.go | 4 ++-- contract/vm_callback.go | 9 +++++---- go.mod | 2 +- go.sum | 29 ++++----------------------- mempool/mempool_test.go | 6 +++--- p2p/certmanager.go | 2 +- p2p/p2pcommon/certificate.go | 5 +++-- p2p/p2putil/PKTest_test.go | 6 +++--- p2p/p2putil/certificate.go | 12 +++++------ p2p/p2putil/certificate_test.go | 16 +++++++-------- p2p/p2putil/cryptoutil.go | 6 +++--- p2p/p2putil/cryptoutil_test.go | 6 +++--- 25 files changed, 76 insertions(+), 102 deletions(-) diff --git a/account/key/aergo_storage_test.go b/account/key/aergo_storage_test.go index c4e0b2792..35dbbf22c 100644 --- a/account/key/aergo_storage_test.go +++ b/account/key/aergo_storage_test.go @@ -12,7 +12,7 @@ import ( "testing" crypto "github.com/aergoio/aergo/v2/account/key/crypto" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/stretchr/testify/assert" ) @@ -24,7 +24,7 @@ func TestSaveAndLoadOnAergo(t *testing.T) { if nil != err { assert.FailNow(t, "Could not create storage", err) } - expected, err := btcec.NewPrivateKey(btcec.S256()) + expected, err := btcec.NewPrivateKey() if nil != err { assert.FailNow(t, "Could not create private key", err) } @@ -52,7 +52,7 @@ func TestSaveAndListOnAergo(t *testing.T) { if nil != err { assert.FailNow(t, "Could not create storage", err) } - expected, err := btcec.NewPrivateKey(btcec.S256()) + expected, err := btcec.NewPrivateKey() if nil != err { assert.FailNow(t, "Could not create private key", err) } diff --git a/account/key/badgerdb.go b/account/key/badgerdb.go index 5256fe44b..bc17cff0e 100644 --- a/account/key/badgerdb.go +++ b/account/key/badgerdb.go @@ -14,7 +14,7 @@ import ( "github.com/aergoio/aergo-lib/db" "github.com/aergoio/aergo/v2/types" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" ) type BadgerStorage struct { @@ -94,7 +94,7 @@ func (ks *BadgerStorage) Load(identity Identity, password string) (*PrivateKey, return nil, types.ErrWrongAddressOrPassWord } - privateKey, _ := btcec.PrivKeyFromBytes(btcec.S256(), decrypted) + privateKey, _ := btcec.PrivKeyFromBytes(decrypted) return privateKey, nil } diff --git a/account/key/badgerdb_test.go b/account/key/badgerdb_test.go index 6ca49925f..c51b7819f 100644 --- a/account/key/badgerdb_test.go +++ b/account/key/badgerdb_test.go @@ -12,7 +12,7 @@ import ( "testing" crypto "github.com/aergoio/aergo/v2/account/key/crypto" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/stretchr/testify/assert" ) @@ -21,7 +21,7 @@ func TestSaveAndLoadOnBadger(t *testing.T) { defer os.RemoveAll(dir) storage, _ := NewBadgerStorage(dir) - expected, err := btcec.NewPrivateKey(btcec.S256()) + expected, err := btcec.NewPrivateKey() if nil != err { assert.FailNow(t, "Could not create private key", err) } @@ -47,7 +47,7 @@ func TestSaveAndListOnBadger(t *testing.T) { defer os.RemoveAll(dir) storage, _ := NewBadgerStorage(dir) - expected, err := btcec.NewPrivateKey(btcec.S256()) + expected, err := btcec.NewPrivateKey() if nil != err { assert.FailNow(t, "Could not create private key", err) } diff --git a/account/key/crypto/address_test.go b/account/key/crypto/address_test.go index 6cce535f4..86bffde28 100644 --- a/account/key/crypto/address_test.go +++ b/account/key/crypto/address_test.go @@ -9,16 +9,16 @@ import ( "testing" "github.com/aergoio/aergo/v2/types" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/stretchr/testify/assert" ) func TestGenerateAddress(t *testing.T) { for i := 0; i < 100; i++ { - key, err := btcec.NewPrivateKey(btcec.S256()) + key, err := btcec.NewPrivateKey() assert.NoError(t, err, "could not create private key") - address := GenerateAddress(&key.PublicKey) + address := GenerateAddress(key.PubKey().ToECDSA()) assert.Equalf(t, types.AddressLength, len(address), "wrong address length : %s", address) assert.Equal(t, key.PubKey().SerializeCompressed(), address, "wrong address contents") } diff --git a/account/key/crypto/strategy.go b/account/key/crypto/strategy.go index ce1d1600f..020cae905 100644 --- a/account/key/crypto/strategy.go +++ b/account/key/crypto/strategy.go @@ -6,7 +6,7 @@ package key import ( - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" ) type PrivateKey = btcec.PrivateKey diff --git a/account/key/crypto/v1strategy.go b/account/key/crypto/v1strategy.go index c7a80fe82..36d05b0ca 100644 --- a/account/key/crypto/v1strategy.go +++ b/account/key/crypto/v1strategy.go @@ -17,7 +17,7 @@ import ( "github.com/aergoio/aergo/v2/internal/enc/hex" "github.com/aergoio/aergo/v2/types" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "golang.org/x/crypto/scrypt" ) @@ -179,7 +179,7 @@ func (ks *v1Strategy) Decrypt(encrypted []byte, passphrase string) (*PrivateKey, return nil, err } - privateKey, _ := btcec.PrivKeyFromBytes(btcec.S256(), plaintext) + privateKey, _ := btcec.PrivKeyFromBytes(plaintext) rawAddress := GenerateAddress(&(privateKey.ToECDSA().PublicKey)) encodedAddress := types.EncodeAddress(rawAddress) diff --git a/account/key/crypto/v1strategy_test.go b/account/key/crypto/v1strategy_test.go index 15c2a2d9a..e9b355c24 100644 --- a/account/key/crypto/v1strategy_test.go +++ b/account/key/crypto/v1strategy_test.go @@ -10,7 +10,7 @@ import ( "os" "testing" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/stretchr/testify/assert" ) @@ -34,7 +34,7 @@ func TestEncryptAndDecrypt(t *testing.T) { defer os.RemoveAll(dir) for i := 0; i < 2; i++ { - expected, err := btcec.NewPrivateKey(btcec.S256()) + expected, err := btcec.NewPrivateKey() if nil != err { assert.FailNow(t, "Could not create private key", err) } diff --git a/account/key/sign.go b/account/key/sign.go index 42bcdd9c8..62b24424c 100644 --- a/account/key/sign.go +++ b/account/key/sign.go @@ -9,7 +9,8 @@ import ( "encoding/binary" "github.com/aergoio/aergo/v2/types" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcec/v2/ecdsa" sha256 "github.com/minio/sha256-simd" ) @@ -19,20 +20,14 @@ func (ks *Store) Sign(addr Identity, pass string, hash []byte) ([]byte, error) { if err != nil { return nil, err } - sign, err := key.Sign(hash) - if err != nil { - return nil, err - } + sign := ecdsa.Sign(key, hash) return sign.Serialize(), nil } // SignTx return tx signature using stored key func SignTx(tx *types.Tx, key *aergokey) error { hash := CalculateHashWithoutSign(tx.Body) - sign, err := key.Sign(hash) - if err != nil { - return err - } + sign := ecdsa.Sign(key, hash) tx.Body.Sign = sign.Serialize() tx.Hash = tx.CalculateTxHash() return nil @@ -59,11 +54,11 @@ func VerifyTx(tx *types.Tx) error { func VerifyTxWithAddress(tx *types.Tx, address []byte) error { txBody := tx.Body hash := CalculateHashWithoutSign(txBody) - sign, err := btcec.ParseSignature(txBody.Sign, btcec.S256()) + sign, err := ecdsa.ParseSignature(txBody.Sign) if err != nil { return err } - pubkey, err := btcec.ParsePubKey(address, btcec.S256()) + pubkey, err := btcec.ParsePubKey(address) if err != nil { return err } diff --git a/account/key/storage.go b/account/key/storage.go index f01a6a17e..a3e4d1a4e 100644 --- a/account/key/storage.go +++ b/account/key/storage.go @@ -6,7 +6,7 @@ package key import ( - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" ) // Identity is a raw, i.e. decoded address generated from a public key diff --git a/account/key/store.go b/account/key/store.go index bfd554d22..c437fdb1d 100644 --- a/account/key/store.go +++ b/account/key/store.go @@ -11,7 +11,7 @@ import ( crypto "github.com/aergoio/aergo/v2/account/key/crypto" "github.com/aergoio/aergo/v2/types" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" ) type aergokey = btcec.PrivateKey @@ -61,7 +61,7 @@ func (ks *Store) CloseStore() { // CreateKey make new key in keystore and return it's address func (ks *Store) CreateKey(pass string) (Identity, error) { //gen new key - privkey, err := btcec.NewPrivateKey(btcec.S256()) + privkey, err := btcec.NewPrivateKey() if err != nil { return nil, err } @@ -76,10 +76,10 @@ func (ks *Store) ImportKey(imported []byte, oldpass string, newpass string) (Ide if err != nil { return nil, err } - privkey, _ := btcec.PrivKeyFromBytes(btcec.S256(), key) + privkey, _ := btcec.PrivKeyFromBytes(key) idendity, err := ks.addKey(privkey, newpass) if err != nil { - address := crypto.GenerateAddress(&privkey.PublicKey) + address := crypto.GenerateAddress(privkey.PubKey().ToECDSA()) return address, err } return idendity, nil @@ -164,7 +164,7 @@ func (ks *Store) GetKey(address []byte, pass string) (*aergokey, error) { } func (ks *Store) addKey(key *btcec.PrivateKey, pass string) (Identity, error) { - address := crypto.GenerateAddress(&key.PublicKey) + address := crypto.GenerateAddress(key.PubKey().ToECDSA()) return ks.storage.Save(address, pass, key) } diff --git a/account/key/store_test.go b/account/key/store_test.go index bb3801410..7d4aacc1c 100644 --- a/account/key/store_test.go +++ b/account/key/store_test.go @@ -13,7 +13,7 @@ import ( crypto "github.com/aergoio/aergo/v2/account/key/crypto" "github.com/aergoio/aergo/v2/types" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/stretchr/testify/assert" ) @@ -67,7 +67,7 @@ func TestImportKey(t *testing.T) { defer deinitTest() const testSize = 3 for i := 0; i < testSize; i++ { - key, err := btcec.NewPrivateKey(btcec.S256()) + key, err := btcec.NewPrivateKey() addr := crypto.GenerateAddress(&(key.PublicKey)) if err != nil { t.Errorf("could not create key : %s", err.Error()) diff --git a/chain/signverifier_test.go b/chain/signverifier_test.go index 4fc5bf950..d96f172a8 100644 --- a/chain/signverifier_test.go +++ b/chain/signverifier_test.go @@ -8,7 +8,7 @@ import ( "github.com/aergoio/aergo/v2/account/key" crypto "github.com/aergoio/aergo/v2/account/key/crypto" "github.com/aergoio/aergo/v2/types" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/stretchr/testify/assert" ) @@ -41,12 +41,12 @@ func beforeTest(txCount int) error { } for i := 0; i < maxAccount; i++ { - privkey, err := btcec.NewPrivateKey(btcec.S256()) + privkey, err := btcec.NewPrivateKey() if err != nil { return err } //gen new address - accs[i] = crypto.GenerateAddress(&privkey.PublicKey) + accs[i] = crypto.GenerateAddress(privkey.PubKey().ToECDSA()) sign[i] = privkey recipient[i] = _itobU32(uint32(i)) } diff --git a/cmd/aergocli/cmd/keygen.go b/cmd/aergocli/cmd/keygen.go index da8ecf07f..cd23e4313 100644 --- a/cmd/aergocli/cmd/keygen.go +++ b/cmd/aergocli/cmd/keygen.go @@ -12,7 +12,7 @@ import ( "github.com/aergoio/aergo/v2/internal/enc/base64" "github.com/aergoio/aergo/v2/p2p/p2putil" "github.com/aergoio/aergo/v2/types" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/libp2p/go-libp2p/core/crypto" "github.com/spf13/cobra" ) @@ -137,7 +137,7 @@ func saveFilesFromKeys(priv crypto.PrivKey, pub crypto.PubKey, prefix string) er if err != nil { return err } - _, pubkey := btcec.PrivKeyFromBytes(btcec.S256(), pkBytes) + _, pubkey := btcec.PrivKeyFromBytes(pkBytes) address := keycrypto.GenerateAddress(pubkey.ToECDSA()) addrf.WriteString(types.EncodeAddress(address)) addrf.Sync() diff --git a/cmd/aergocli/cmd/signtx.go b/cmd/aergocli/cmd/signtx.go index 39f515177..8bf746292 100644 --- a/cmd/aergocli/cmd/signtx.go +++ b/cmd/aergocli/cmd/signtx.go @@ -10,7 +10,7 @@ import ( "github.com/aergoio/aergo/v2/internal/enc/base58" "github.com/aergoio/aergo/v2/types" "github.com/aergoio/aergo/v2/types/jsonrpc" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/spf13/cobra" ) @@ -60,7 +60,7 @@ var signCmd = &cobra.Command{ return } tx := &types.Tx{Body: param} - signKey, pubkey := btcec.PrivKeyFromBytes(btcec.S256(), rawKey) + signKey, pubkey := btcec.PrivKeyFromBytes(rawKey) err = key.SignTx(tx, signKey) if err != nil { cmd.Printf("Failed: %s\n", err.Error()) diff --git a/contract/vm_callback.go b/contract/vm_callback.go index 943ce6024..0cadc5b32 100644 --- a/contract/vm_callback.go +++ b/contract/vm_callback.go @@ -45,7 +45,8 @@ import ( "github.com/aergoio/aergo/v2/state/statedb" "github.com/aergoio/aergo/v2/types" "github.com/aergoio/aergo/v2/types/dbkey" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcec/v2/ecdsa" ) var ( @@ -862,7 +863,7 @@ func luaECVerify(L *LState, service C.int, msg *C.char, sig *C.char, addr *C.cha if err != nil { return -1, C.CString("[Contract.LuaEcVerify] invalid aergo address: " + err.Error()) } - pubKey, err = btcec.ParsePubKey(bAddress, btcec.S256()) + pubKey, err = btcec.ParsePubKey(bAddress) if err != nil { return -1, C.CString("[Contract.LuaEcVerify] error parsing pubKey: " + err.Error()) } @@ -877,7 +878,7 @@ func luaECVerify(L *LState, service C.int, msg *C.char, sig *C.char, addr *C.cha copy(btcsig[1:], bSig) bSig = btcsig } - pub, _, err := btcec.RecoverCompact(btcec.S256(), bSig, bMsg) + pub, _, err := ecdsa.RecoverCompact(bSig, bMsg) if err != nil { return -1, C.CString("[Contract.LuaEcVerify] error recoverCompact: " + err.Error()) } @@ -895,7 +896,7 @@ func luaECVerify(L *LState, service C.int, msg *C.char, sig *C.char, addr *C.cha verifyResult = bytes.Equal(bAddress, signAddress) } } else { - sign, err := btcec.ParseSignature(bSig, btcec.S256()) + sign, err := ecdsa.ParseSignature(bSig) if err != nil { return -1, C.CString("[Contract.LuaEcVerify] error parsing signature: " + err.Error()) } diff --git a/go.mod b/go.mod index 2f2769a70..1cdaa685d 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/aergoio/etcd v0.0.0-20190429013412-e8b3f96f6399 github.com/anaskhan96/base58check v0.0.0-20181220122047-b05365d494c4 github.com/bluele/gcache v0.0.0-20190518031135-bc40bd653833 - github.com/btcsuite/btcd v0.21.0-beta + github.com/btcsuite/btcd/btcec/v2 v2.3.4 github.com/c-bata/go-prompt v0.2.3 github.com/coreos/go-semver v0.3.0 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc diff --git a/go.sum b/go.sum index 4492bec44..979805c62 100644 --- a/go.sum +++ b/go.sum @@ -53,7 +53,6 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMx github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/Workiva/go-datastructures v1.0.50 h1:slDmfW6KCHcC7U+LP3DDBbm4fqTwZGn1beOFPfGaLvo= github.com/Workiva/go-datastructures v1.0.50/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= -github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/aergoio/aergo-actor v0.0.0-20190219030625-562037d5fec7 h1:dYRi21hTS3fJwjSh/KZTAuLXUbV/Ijm2395Nf4b3wNs= github.com/aergoio/aergo-actor v0.0.0-20190219030625-562037d5fec7/go.mod h1:/nqZcvcM0UipJRnUm61LrQ8rC7IyBr8mfx5F00sCbvs= github.com/aergoio/aergo-lib v1.1.0 h1:tPilY3bZr28DyJ0gZFXquiYv2veUIar1fGTDYljAL4k= @@ -91,19 +90,10 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/bluele/gcache v0.0.0-20190518031135-bc40bd653833 h1:yCfXxYaelOyqnia8F/Yng47qhmfC9nKTRIbYRrRueq4= github.com/bluele/gcache v0.0.0-20190518031135-bc40bd653833/go.mod h1:8c4/i2VlovMO2gBnHGQPN5EJw+H0lx1u/5p+cgsXtCk= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= -github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd v0.21.0-beta h1:At9hIZdJW0s9E/fAz28nrz6AmcNlSVucCH796ZteX1M= -github.com/btcsuite/btcd v0.21.0-beta/go.mod h1:ZSWyehm27aAuS9bvkATT+Xte3hjHZ+MRgMY/8NJ7K94= -github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= -github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= -github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= -github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= -github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= -github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= -github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= -github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ= +github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/c-bata/go-prompt v0.2.3 h1:jjCS+QhG/sULBhAaBdjb2PlMRVaKXQgn+4yzaauvs2s= github.com/c-bata/go-prompt v0.2.3/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= @@ -152,7 +142,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:ma github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -163,7 +152,6 @@ github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5il github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/derekparker/trie v0.0.0-20190322172448-1ce4922c7ad9 h1:aSaTVlEXc2QKl4fzXU1tMYCjlrSc2mA4DZtiVfckQHo= github.com/derekparker/trie v0.0.0-20190322172448-1ce4922c7ad9/go.mod h1:D6ICZm05D9VN1n/8iOtBxLpXtoGp6HDFUJ1RNVieOSE= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= @@ -419,12 +407,9 @@ github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+ github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk= github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPwbGVtZVWC34vc5WLsDk= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= -github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -441,7 +426,6 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= @@ -603,7 +587,6 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg= github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= -github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8= @@ -923,7 +906,6 @@ go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= -golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -935,8 +917,6 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200602180216-279210d13fed/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= @@ -990,7 +970,6 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= -golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= diff --git a/mempool/mempool_test.go b/mempool/mempool_test.go index 9c982ca1e..afe2ae33d 100644 --- a/mempool/mempool_test.go +++ b/mempool/mempool_test.go @@ -17,7 +17,7 @@ import ( crypto "github.com/aergoio/aergo/v2/account/key/crypto" "github.com/aergoio/aergo/v2/config" "github.com/aergoio/aergo/v2/types" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/stretchr/testify/assert" ) @@ -75,12 +75,12 @@ func initTest(t *testing.T) { pool = newTestPool() for i := 0; i < maxAccount; i++ { - privkey, err := btcec.NewPrivateKey(btcec.S256()) + privkey, err := btcec.NewPrivateKey() if err != nil { t.Fatalf("failed to init test (%s)", err) } //gen new address - accs[i] = crypto.GenerateAddress(&privkey.PublicKey) + accs[i] = crypto.GenerateAddress(privkey.PubKey().ToECDSA()) sign[i] = privkey recipient[i] = _itobU32(uint32(i)) } diff --git a/p2p/certmanager.go b/p2p/certmanager.go index 20883f5ca..01d85238b 100644 --- a/p2p/certmanager.go +++ b/p2p/certmanager.go @@ -11,7 +11,7 @@ import ( "github.com/aergoio/aergo/v2/p2p/p2putil" "github.com/aergoio/aergo/v2/types" "github.com/aergoio/aergo/v2/types/message" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" ) var emptyIDArr []types.PeerID diff --git a/p2p/p2pcommon/certificate.go b/p2p/p2pcommon/certificate.go index 63f7fb223..811e90075 100644 --- a/p2p/p2pcommon/certificate.go +++ b/p2p/p2pcommon/certificate.go @@ -5,7 +5,8 @@ import ( "time" "github.com/aergoio/aergo/v2/types" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcec/v2/ecdsa" ) var ( @@ -35,7 +36,7 @@ type AgentCertificateV1 struct { ExpireTime time.Time AgentID types.PeerID AgentAddress []string - Signature *btcec.Signature + Signature *ecdsa.Signature } // IsValidInTime check if this certificate is expired diff --git a/p2p/p2putil/PKTest_test.go b/p2p/p2putil/PKTest_test.go index 7750606af..f41ff7dc8 100644 --- a/p2p/p2putil/PKTest_test.go +++ b/p2p/p2putil/PKTest_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/aergoio/aergo/v2/internal/enc/hex" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/libp2p/go-libp2p/core/crypto" ) @@ -47,7 +47,7 @@ func PrintBTCPKey(priv *btcec.PrivateKey, t *testing.T) { } func TestLibs(t *testing.T) { - btcKey, err := btcec.NewPrivateKey(btcec.S256()) + btcKey, err := btcec.NewPrivateKey() if err != nil { t.Fatalf("Failed to generate btcec key : %s ", err) } @@ -65,7 +65,7 @@ func TestLibs(t *testing.T) { } func TestLibs2(t *testing.T) { - btcKey, err := btcec.NewPrivateKey(btcec.S256()) + btcKey, err := btcec.NewPrivateKey() if err != nil { t.Fatalf("Failed to generate btcec key : %s ", err) } diff --git a/p2p/p2putil/certificate.go b/p2p/p2putil/certificate.go index d0409f9d5..3e8cdd9ad 100644 --- a/p2p/p2putil/certificate.go +++ b/p2p/p2putil/certificate.go @@ -7,7 +7,8 @@ import ( "github.com/aergoio/aergo/v2/internal/network" "github.com/aergoio/aergo/v2/p2p/p2pcommon" "github.com/aergoio/aergo/v2/types" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcec/v2/ecdsa" "github.com/libp2p/go-libp2p/core/peer" "github.com/minio/sha256-simd" ) @@ -86,7 +87,7 @@ func CheckAndGetV1(cert *types.AgentCertificate) (*p2pcommon.AgentCertificateV1, if err != nil { return nil, p2pcommon.ErrInvalidPeerID } - wrap.BPPubKey, err = btcec.ParsePubKey(cert.BPPubKey, btcec.S256()) + wrap.BPPubKey, err = btcec.ParsePubKey(cert.BPPubKey) if err != nil { return nil, p2pcommon.ErrInvalidKey } @@ -121,7 +122,7 @@ func CheckAndGetV1(cert *types.AgentCertificate) (*p2pcommon.AgentCertificateV1, } wrap.AgentAddress[i] = addrStr } - wrap.Signature, err = btcec.ParseSignature(cert.Signature, btcec.S256()) + wrap.Signature, err = ecdsa.ParseSignature(cert.Signature) if err != nil { return nil, p2pcommon.ErrInvalidCertField } @@ -138,10 +139,7 @@ func SignCert(key *btcec.PrivateKey, wrap *p2pcommon.AgentCertificateV1) error { if err != nil { return err } - sign, err := key.Sign(hash) - if err != nil { - return err - } + sign := ecdsa.Sign(key, hash) wrap.BPPubKey = key.PubKey() wrap.Signature = sign return nil diff --git a/p2p/p2putil/certificate_test.go b/p2p/p2putil/certificate_test.go index edfb2701c..93bb382de 100644 --- a/p2p/p2putil/certificate_test.go +++ b/p2p/p2putil/certificate_test.go @@ -10,11 +10,11 @@ import ( "github.com/aergoio/aergo/v2/internal/enc/proto" "github.com/aergoio/aergo/v2/p2p/p2pcommon" "github.com/aergoio/aergo/v2/types" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" ) func TestNewAgentCertV1(t *testing.T) { - pk, _ := btcec.NewPrivateKey(btcec.S256()) + pk, _ := btcec.NewPrivateKey() pid1, pid2 := types.RandomPeerID(), types.RandomPeerID() addr0 := "192.168.0.2" addr1 := "2001:0db8:85a3:08d3:1319:8a2e:370:7334" @@ -63,9 +63,9 @@ func TestNewAgentCertV1(t *testing.T) { } func TestCheckAndGetV1(t *testing.T) { - pk1, _ := btcec.NewPrivateKey(btcec.S256()) + pk1, _ := btcec.NewPrivateKey() libp2pKey1 := ConvertPKToLibP2P(pk1) - //pk2, _ := btcec.NewPrivateKey(btcec.S256()) + //pk2, _ := btcec.NewPrivateKey() pid1, _ := types.IDFromPrivateKey(libp2pKey1) pid2 := types.RandomPeerID() addrs := []string{"192.168.0.2", "2001:0db8:85a3:08d3:1319:8a2e:370:7334", "tester.aergo.io"} @@ -177,8 +177,8 @@ func (b *cb) Build() *types.AgentCertificate { } func TestAgentCertificateV1_Convert(t *testing.T) { - pk1, _ := btcec.NewPrivateKey(btcec.S256()) - //pk2, _ := btcec.NewPrivateKey(btcec.S256()) + pk1, _ := btcec.NewPrivateKey() + //pk2, _ := btcec.NewPrivateKey() pid1, _ := types.IDFromPrivateKey(ConvertPKToLibP2P(pk1)) pid2 := types.RandomPeerID() @@ -234,8 +234,8 @@ func TestAgentCertificateV1_Convert(t *testing.T) { } func Test_calculateCertificateHash(t *testing.T) { - pk1, _ := btcec.NewPrivateKey(btcec.S256()) - //pk2, _ := btcec.NewPrivateKey(btcec.S256()) + pk1, _ := btcec.NewPrivateKey() + //pk2, _ := btcec.NewPrivateKey() pid1, pid2 := types.RandomPeerID(), types.RandomPeerID() addrs := []string{"192.168.0.2", "2001:0db8:85a3:08d3:1319:8a2e:370:7334", "tester.aergo.io"} DAY := time.Hour * 24 diff --git a/p2p/p2putil/cryptoutil.go b/p2p/p2putil/cryptoutil.go index 57a9f0a16..f7e8b2aeb 100644 --- a/p2p/p2putil/cryptoutil.go +++ b/p2p/p2putil/cryptoutil.go @@ -1,7 +1,7 @@ package p2putil import ( - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/libp2p/go-libp2p/core/crypto" ) @@ -11,7 +11,7 @@ func ConvertPKToBTCEC(pk crypto.PrivKey) *btcec.PrivateKey { if err != nil { return nil } - priv, _ := btcec.PrivKeyFromBytes(btcec.S256(), raw) + priv, _ := btcec.PrivKeyFromBytes(raw) return priv } @@ -21,7 +21,7 @@ func ConvertPubKeyToBTCEC(pk crypto.PubKey) *btcec.PublicKey { if err != nil { return nil } - pub, _ := btcec.ParsePubKey(raw, btcec.S256()) + pub, _ := btcec.ParsePubKey(raw) return pub } diff --git a/p2p/p2putil/cryptoutil_test.go b/p2p/p2putil/cryptoutil_test.go index 7990739cf..92eb55814 100644 --- a/p2p/p2putil/cryptoutil_test.go +++ b/p2p/p2putil/cryptoutil_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/aergoio/aergo/v2/internal/enc/hex" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/libp2p/go-libp2p/core/crypto" ) @@ -17,7 +17,7 @@ func TestConvertPKToLibP2P(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - btcPK, err := btcec.NewPrivateKey(btcec.S256()) + btcPK, err := btcec.NewPrivateKey() if err != nil { t.Fatalf("Failed to create test input pk: %v", err.Error()) } @@ -57,7 +57,7 @@ func TestConvertPubKeyToLibP2P(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - btcPK, err := btcec.NewPrivateKey(btcec.S256()) + btcPK, err := btcec.NewPrivateKey() if err != nil { t.Fatalf("Failed to create test input pk: %v", err.Error()) } From 2c7cdb4c7eade3fc2a26ecd3913d150b1e5efb01 Mon Sep 17 00:00:00 2001 From: Bernardo Ramos Date: Fri, 1 Dec 2023 17:40:49 -0300 Subject: [PATCH 2/2] fix tests --- account/key/aergo_storage_test.go | 4 ++-- account/key/badgerdb_test.go | 4 ++-- account/key/store_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/account/key/aergo_storage_test.go b/account/key/aergo_storage_test.go index 35dbbf22c..b3348230f 100644 --- a/account/key/aergo_storage_test.go +++ b/account/key/aergo_storage_test.go @@ -29,7 +29,7 @@ func TestSaveAndLoadOnAergo(t *testing.T) { assert.FailNow(t, "Could not create private key", err) } - identity := crypto.GenerateAddress(&expected.PublicKey) + identity := crypto.GenerateAddress(expected.PubKey().ToECDSA()) password := "password" saved, err := storage.Save(identity, password, expected) if nil != err { @@ -57,7 +57,7 @@ func TestSaveAndListOnAergo(t *testing.T) { assert.FailNow(t, "Could not create private key", err) } - identity := crypto.GenerateAddress(&expected.PublicKey) + identity := crypto.GenerateAddress(expected.PubKey().ToECDSA()) password := "password" saved, err := storage.Save(identity, password, expected) if nil != err { diff --git a/account/key/badgerdb_test.go b/account/key/badgerdb_test.go index c51b7819f..0b3232521 100644 --- a/account/key/badgerdb_test.go +++ b/account/key/badgerdb_test.go @@ -26,7 +26,7 @@ func TestSaveAndLoadOnBadger(t *testing.T) { assert.FailNow(t, "Could not create private key", err) } - identity := crypto.GenerateAddress(&expected.PublicKey) + identity := crypto.GenerateAddress(expected.PubKey().ToECDSA()) password := "password" saved, err := storage.Save(identity, password, expected) if nil != err { @@ -52,7 +52,7 @@ func TestSaveAndListOnBadger(t *testing.T) { assert.FailNow(t, "Could not create private key", err) } - identity := crypto.GenerateAddress(&expected.PublicKey) + identity := crypto.GenerateAddress(expected.PubKey().ToECDSA()) password := "password" saved, err := storage.Save(identity, password, expected) if nil != err { diff --git a/account/key/store_test.go b/account/key/store_test.go index 7d4aacc1c..afff1c6eb 100644 --- a/account/key/store_test.go +++ b/account/key/store_test.go @@ -68,7 +68,7 @@ func TestImportKey(t *testing.T) { const testSize = 3 for i := 0; i < testSize; i++ { key, err := btcec.NewPrivateKey() - addr := crypto.GenerateAddress(&(key.PublicKey)) + addr := crypto.GenerateAddress(key.PubKey().ToECDSA()) if err != nil { t.Errorf("could not create key : %s", err.Error()) }