Skip to content

Commit

Permalink
chore: remove use of deprecated crypto/elliptic
Browse files Browse the repository at this point in the history
  • Loading branch information
hacheigriega committed Nov 1, 2024
1 parent a2971b5 commit 8c097d0
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
11 changes: 5 additions & 6 deletions app/utils/seda_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package utils

import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"encoding/hex"
"encoding/json"
Expand Down Expand Up @@ -47,9 +46,9 @@ var sedaKeyGenerators = map[SEDAKeyIndex]privKeyGenerator{
}

var sedaKeyValidators = map[SEDAKeyIndex]pubKeyValidator{
SEDAKeyIndexSecp256k1: func(pubKey []byte) bool {
x, _ := elliptic.Unmarshal(ethcrypto.S256(), pubKey)
return x != nil
SEDAKeyIndexSecp256k1: func(pub []byte) bool {
_, err := ethcrypto.UnmarshalPubkey(pub)
return err == nil
},
}

Expand Down Expand Up @@ -109,7 +108,7 @@ func GenerateSEDAKeys(dirPath string) ([]pubkeytypes.IndexedPubKey, error) {
PrivKey: generator(),
}
pubKey := keys[i].PrivKey.PublicKey
pubKeyBytes := elliptic.Marshal(pubKey, pubKey.X, pubKey.Y)
pubKeyBytes := ethcrypto.FromECDSAPub(&pubKey)
result[i] = pubkeytypes.IndexedPubKey{
Index: uint32(i),
PubKey: pubKeyBytes,
Expand Down Expand Up @@ -164,7 +163,7 @@ func LoadSEDAPubKeys(loadPath string) ([]pubkeytypes.IndexedPubKey, error) {
result := make([]pubkeytypes.IndexedPubKey, len(keys))
for i, key := range keys {
pubKey := key.PrivKey.PublicKey
pubKeyBytes := elliptic.Marshal(pubKey, pubKey.X, pubKey.Y)
pubKeyBytes := ethcrypto.FromECDSAPub(&pubKey)
result[i] = pubkeytypes.IndexedPubKey{
Index: uint32(key.Index),
PubKey: pubKeyBytes,
Expand Down
1 change: 0 additions & 1 deletion proto/sedachain/pubkey/v1/pubkey.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
syntax = "proto3";
package sedachain.pubkey.v1;

import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/sedaprotocol/seda-chain/x/pubkey/types";
Expand Down
1 change: 0 additions & 1 deletion x/batching/keeper/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ func initFixture(tb testing.TB) *fixture {
)

pubKeyKeeper := pubkeykeeper.NewKeeper(
cdc,
runtime.NewKVStoreService(keys[pubkeytypes.StoreKey]),
stakingKeeper,
addresscodec.NewBech32Codec(params.Bech32PrefixValAddr),
Expand Down
1 change: 0 additions & 1 deletion x/pubkey/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func (s *KeeperTestSuite) SetupTest() {
s.mockStakingKeeper = testutil.NewMockStakingKeeper(ctrl)
s.valCdc = addresscodec.NewBech32Codec(params.Bech32PrefixValAddr)
s.keeper = keeper.NewKeeper(
encCfg.Codec,
runtime.NewKVStoreService(key),
s.mockStakingKeeper,
s.valCdc,
Expand Down
1 change: 0 additions & 1 deletion x/tally/keeper/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ func initFixture(tb testing.TB) *fixture {
)

pubKeyKeeper := pubkeykeeper.NewKeeper(
cdc,
runtime.NewKVStoreService(keys[pubkeytypes.StoreKey]),
stakingKeeper,
addresscodec.NewBech32Codec(params.Bech32PrefixValAddr),
Expand Down

0 comments on commit 8c097d0

Please sign in to comment.