From 60b09a5a0c0e5def9f5a5caaa0b667cb4738e72c Mon Sep 17 00:00:00 2001 From: mrekucci Date: Mon, 18 Dec 2023 20:37:20 +0700 Subject: [PATCH] chore: bump btcd to version v0.23.3 --- go.mod | 16 ++++++++++++++-- go.sum | 21 +++++++++++++++++++++ pkg/crypto/crypto.go | 18 +++++++++++------- pkg/crypto/dh_test.go | 7 +++---- pkg/crypto/signer.go | 14 ++++++++------ pkg/keystore/file/key.go | 2 +- pkg/pss/trojan.go | 12 ++++++------ 7 files changed, 64 insertions(+), 26 deletions(-) diff --git a/go.mod b/go.mod index ec511812715..e6b2628bd66 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( contrib.go.opencensus.io/exporter/prometheus v0.4.2 github.com/armon/go-radix v1.0.0 - github.com/btcsuite/btcd v0.22.3 + github.com/btcsuite/btcd v0.23.4 github.com/casbin/casbin/v2 v2.35.0 github.com/coreos/go-semver v0.3.0 github.com/ethereum/go-ethereum v1.13.4 @@ -60,10 +60,17 @@ require ( github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/StackExchange/wmi v1.2.1 // indirect + github.com/aead/siphash v1.0.1 // indirect github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.7.0 // indirect - github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect + github.com/btcsuite/btcd/btcutil v1.1.0 // indirect + github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect + github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect + github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect + github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect + github.com/btcsuite/winsvc v1.0.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/codahale/hdrhistogram v0.0.0-00010101000000-000000000000 // indirect github.com/consensys/bavard v0.1.13 // indirect @@ -74,7 +81,9 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect + github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect + github.com/decred/dcrd/lru v1.0.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/elastic/gosigar v0.14.2 // indirect github.com/ethereum/c-kzg-4844 v0.3.1 // indirect @@ -104,6 +113,9 @@ require ( github.com/ipfs/go-log/v2 v2.5.1 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect + github.com/jessevdk/go-flags v1.4.0 // indirect + github.com/jrick/logrotate v1.0.0 // indirect + github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 // indirect github.com/klauspost/compress v1.16.7 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/koron/go-ssdp v0.0.4 // indirect diff --git a/go.sum b/go.sum index 5ac8b1c297d..2545b22d5ea 100644 --- a/go.sum +++ b/go.sum @@ -79,6 +79,7 @@ github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9 github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= +github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/alangpierce/go-forceexport v0.0.0-20160317203124-8f1d6941cd75/go.mod h1:uAXEEpARkRhCZfEvy/y0Jcc888f9tHCc1W7/UeEtreE= @@ -124,21 +125,35 @@ github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx2 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.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA= +github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= github.com/btcsuite/btcd v0.22.3 h1:kYNaWFvOw6xvqP0vR20RP1Zq1DVMBxEO8QN5d1/EfNg= github.com/btcsuite/btcd v0.22.3/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y= +github.com/btcsuite/btcd v0.23.3/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= +github.com/btcsuite/btcd v0.23.4 h1:IzV6qqkfwbItOS/sg/aDfPDsjPP8twrCOE2R93hxMlQ= +github.com/btcsuite/btcd v0.23.4/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= +github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k= github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= +github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= +github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= +github.com/btcsuite/btcd/btcutil v1.1.0 h1:MO4klnGY+EWJdoWF12Wkuf4AWDBPMpZNeN/jRLrklUU= +github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= 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/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= 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.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= +github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw= 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 h1:R8vQdOQdZ9Y3SkEwmHoWBmX1DNXhXZqlTpq6s4tyJGc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= +github.com/btcsuite/winsvc v1.0.0 h1:J9B4L7e3oqhXOcm+2IuNApwzQec85lE+QaikUcCs+dk= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= @@ -211,10 +226,13 @@ github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vs github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= +github.com/decred/dcrd/lru v1.0.0 h1:Kbsb1SFDsIlaupWPwsPp+dkxiBY1frcS07PCPgotKz8= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-bitstream v0.0.0-20180413035011-3522498ce2c8/go.mod h1:VMaSuZ+SZcx/wljOQKvp5srsbCiKDEb6K2wC4+PiBmQ= @@ -488,11 +506,13 @@ github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPw github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= 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 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= 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 h1:lQ1bL/n9mBNeIXoTUoYRlK4dHuNJVofX9oWqBtPnSzI= 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.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -517,6 +537,7 @@ 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 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= diff --git a/pkg/crypto/crypto.go b/pkg/crypto/crypto.go index fb8cab1f94f..a2e0ba2e468 100644 --- a/pkg/crypto/crypto.go +++ b/pkg/crypto/crypto.go @@ -13,7 +13,7 @@ import ( "errors" "fmt" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/ethersphere/bee/pkg/swarm" "golang.org/x/crypto/sha3" ) @@ -66,12 +66,16 @@ func GenerateSecp256k1Key() (*ecdsa.PrivateKey, error) { // EncodeSecp256k1PrivateKey encodes raw ECDSA private key. func EncodeSecp256k1PrivateKey(k *ecdsa.PrivateKey) ([]byte, error) { - return (*btcec.PrivateKey)(k).Serialize(), nil + pvk, _ := btcec.PrivKeyFromBytes(k.D.Bytes()) + return pvk.Serialize(), nil } // EncodeSecp256k1PublicKey encodes raw ECDSA public key in a 33-byte compressed format. func EncodeSecp256k1PublicKey(k *ecdsa.PublicKey) []byte { - return (*btcec.PublicKey)(k).SerializeCompressed() + var x, y btcec.FieldVal + x.SetByteSlice(k.X.Bytes()) + y.SetByteSlice(k.Y.Bytes()) + return btcec.NewPublicKey(&x, &y).SerializeCompressed() } // DecodeSecp256k1PrivateKey decodes raw ECDSA private key. @@ -79,8 +83,8 @@ func DecodeSecp256k1PrivateKey(data []byte) (*ecdsa.PrivateKey, error) { if l := len(data); l != btcec.PrivKeyBytesLen { return nil, fmt.Errorf("secp256k1 data size %d expected %d", l, btcec.PrivKeyBytesLen) } - privk, _ := btcec.PrivKeyFromBytes(btcec.S256(), data) - return (*ecdsa.PrivateKey)(privk), nil + pvk, _ := btcec.PrivKeyFromBytes(data) + return pvk.ToECDSA(), nil } // GenerateSecp256k1Key generates an ECDSA private key using @@ -102,8 +106,8 @@ func DecodeSecp256r1PrivateKey(data []byte) (*ecdsa.PrivateKey, error) { // Secp256k1PrivateKeyFromBytes returns an ECDSA private key based on // the byte slice. func Secp256k1PrivateKeyFromBytes(data []byte) *ecdsa.PrivateKey { - privk, _ := btcec.PrivKeyFromBytes(btcec.S256(), data) - return (*ecdsa.PrivateKey)(privk) + pvk, _ := btcec.PrivKeyFromBytes(data) + return pvk.ToECDSA() } // NewEthereumAddress returns a binary representation of ethereum blockchain address. diff --git a/pkg/crypto/dh_test.go b/pkg/crypto/dh_test.go index 1790895d65d..67cb26ebbd2 100644 --- a/pkg/crypto/dh_test.go +++ b/pkg/crypto/dh_test.go @@ -6,13 +6,12 @@ package crypto_test import ( "bytes" - "crypto/ecdsa" "crypto/rand" "encoding/hex" "io" "testing" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/ethersphere/bee/pkg/crypto" ) @@ -66,7 +65,7 @@ func TestSharedKey(t *testing.T) { if err != nil { t.Fatal(err) } - pubkey, err := btcec.ParsePubKey(data, btcec.S256()) + pubkey, err := btcec.ParsePubKey(data) if err != nil { t.Fatal(err) } @@ -76,7 +75,7 @@ func TestSharedKey(t *testing.T) { } dh := crypto.NewDH(privKey) - sk, err := dh.SharedKey((*ecdsa.PublicKey)(pubkey), salt) + sk, err := dh.SharedKey(pubkey.ToECDSA(), salt) if err != nil { t.Fatal(err) } diff --git a/pkg/crypto/signer.go b/pkg/crypto/signer.go index 6a82101eff0..aef6e11f0f6 100644 --- a/pkg/crypto/signer.go +++ b/pkg/crypto/signer.go @@ -10,7 +10,8 @@ import ( "fmt" "math/big" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" + btcecdsa "github.com/btcsuite/btcd/btcec/v2/ecdsa" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethersphere/bee/pkg/crypto/eip712" @@ -59,8 +60,8 @@ func Recover(signature, data []byte) (*ecdsa.PublicKey, error) { return nil, err } - p, _, err := btcec.RecoverCompact(btcec.S256(), btcsig, hash) - return (*ecdsa.PublicKey)(p), err + pbk, _, err := btcecdsa.RecoverCompact(btcsig, hash) + return pbk.ToECDSA(), err } type defaultSigner struct { @@ -135,7 +136,8 @@ func (d *defaultSigner) SignTypedData(typedData *eip712.TypedData) ([]byte, erro // sign the provided hash and convert it to the ethereum (r,s,v) format. func (d *defaultSigner) sign(sighash []byte, isCompressedKey bool) ([]byte, error) { - signature, err := btcec.SignCompact(btcec.S256(), (*btcec.PrivateKey)(d.key), sighash, false) + pvk, _ := btcec.PrivKeyFromBytes(d.key.D.Bytes()) + signature, err := btcecdsa.SignCompact(pvk, sighash, false) if err != nil { return nil, err } @@ -167,6 +169,6 @@ func RecoverEIP712(signature []byte, data *eip712.TypedData) (*ecdsa.PublicKey, return nil, err } - p, _, err := btcec.RecoverCompact(btcec.S256(), btcsig, sighash) - return (*ecdsa.PublicKey)(p), err + pbk, _, err := btcecdsa.RecoverCompact(btcsig, sighash) + return pbk.ToECDSA(), err } diff --git a/pkg/keystore/file/key.go b/pkg/keystore/file/key.go index d6eafaf4326..fbec230f942 100644 --- a/pkg/keystore/file/key.go +++ b/pkg/keystore/file/key.go @@ -16,7 +16,7 @@ import ( "fmt" "io" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/ethersphere/bee/pkg/crypto" "github.com/ethersphere/bee/pkg/keystore" "github.com/google/uuid" diff --git a/pkg/pss/trojan.go b/pkg/pss/trojan.go index 5a901b1086a..14dc8841714 100644 --- a/pkg/pss/trojan.go +++ b/pkg/pss/trojan.go @@ -15,7 +15,7 @@ import ( "fmt" "io" - "github.com/btcsuite/btcd/btcec" + "github.com/btcsuite/btcd/btcec/v2" "github.com/ethersphere/bee/pkg/bmtpool" "github.com/ethersphere/bee/pkg/crypto" "github.com/ethersphere/bee/pkg/encryption" @@ -96,7 +96,7 @@ func Wrap(ctx context.Context, topic Topic, msg []byte, recipient *ecdsa.PublicK // NOTE: only the random bytes of the compressed public key are used // in order not to leak anything, the one bit parity info of the magic byte // is encoded in the parity of the 28th byte of the mined nonce - ephpubBytes := (*btcec.PublicKey)(ephpub).SerializeCompressed() + ephpubBytes := crypto.EncodeSecp256k1PublicKey(ephpub) payload := append(ephpubBytes[1:], ciphertext...) odd := ephpubBytes[0]&0x1 != 0 @@ -259,8 +259,8 @@ func extractPublicKey(chunkData []byte) (*ecdsa.PublicKey, error) { if chunkData[36]|0x1 != 0 { pubkeyBytes[0] |= 0x1 } - pubkey, err := btcec.ParsePubKey(pubkeyBytes, btcec.S256()) - return (*ecdsa.PublicKey)(pubkey), err + pubkey, err := btcec.ParsePubKey(pubkeyBytes) + return pubkey.ToECDSA(), err } // topic is needed to decrypt the trojan payload, but no need to perform decryption with each @@ -312,9 +312,9 @@ func ParseRecipient(recipientHexString string) (*ecdsa.PublicKey, error) { if err != nil { return nil, err } - pubkey, err := btcec.ParsePubKey(publicKeyBytes, btcec.S256()) + pubkey, err := btcec.ParsePubKey(publicKeyBytes) if err != nil { return nil, err } - return (*ecdsa.PublicKey)(pubkey), err + return pubkey.ToECDSA(), err }