Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow using sr25519 addresses for evm send and other funcs #1605

Merged
merged 5 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions evmrpc/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"math/big"
"time"

"github.com/cosmos/cosmos-sdk/crypto/hd"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/codec/legacy"
Expand Down Expand Up @@ -197,6 +199,10 @@ func getAddressPrivKeyMap(kb keyring.Keyring) map[string]*ecdsa.PrivateKey {
// will only show local key
continue
}
if localInfo.GetAlgo() != hd.Secp256k1Type {
fmt.Printf("Skipping address %s because it isn't signed with secp256k1\n", localInfo.Name)
continue
}
priv, err := legacy.PrivKeyFromBytes([]byte(localInfo.PrivKeyArmor))
if err != nil {
continue
Expand Down
8 changes: 8 additions & 0 deletions x/evm/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"strconv"
"strings"

"github.com/cosmos/cosmos-sdk/crypto/hd"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
Expand Down Expand Up @@ -95,6 +97,9 @@ func CmdAssociateAddress() *cobra.Command {
if !ok {
return errors.New("can only associate address for local keys")
}
if localInfo.GetAlgo() != hd.Secp256k1Type {
return errors.New("can only use addresses using secp256k1")
}
priv, err := legacy.PrivKeyFromBytes([]byte(localInfo.PrivKeyArmor))
if err != nil {
return err
Expand Down Expand Up @@ -585,6 +590,9 @@ func getPrivateKey(cmd *cobra.Command) (*ecdsa.PrivateKey, error) {
if !ok {
return nil, errors.New("can only associate address for local keys")
}
if localInfo.GetAlgo() != hd.Secp256k1Type {
return nil, errors.New("can only use addresses using secp256k1")
}
priv, err := legacy.PrivKeyFromBytes([]byte(localInfo.PrivKeyArmor))
if err != nil {
return nil, err
Expand Down
Loading