Skip to content

Commit

Permalink
update pubkey
Browse files Browse the repository at this point in the history
  • Loading branch information
dungtt-astra committed Feb 24, 2023
1 parent 2b29e0a commit 90661ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
17 changes: 0 additions & 17 deletions account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
ethermintHd "github.com/evmos/ethermint/crypto/hd"
ethermintTypes "github.com/evmos/ethermint/types"
"github.com/pkg/errors"
"strings"
)

type Account struct {
Expand All @@ -25,22 +24,6 @@ func NewAccount(coinType uint32) *Account {
return &Account{coinType: coinType}
}

func importPubkey(pk string) (*ethsecp256k1.PubKey, error) {

if strings.ContainsAny(pk, "{") {
pk = strings.Split(strings.Split(pk, "{")[1], "}")[0]
}

key, err := hex.DecodeString(pk)
if err != nil {
return nil, err
}

return &ethsecp256k1.PubKey{
Key: key,
}, nil
}

//Create new an Account

func (a *Account) CreateAccount() (*PrivateKeySerialized, error) {
Expand Down
8 changes: 5 additions & 3 deletions account/pubkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ type PKAccount struct {
publicKey ethsecp256k1.PubKey
}

func NewPKAccount(pubkey string) *PKAccount {
func NewPKAccount(pubkey string) (*PKAccount, error) {
pubkey = strings.Split(strings.Split(pubkey, "{")[1], "}")[0]

key, err := hex.DecodeString(pubkey)
if err != nil {
panic(err)
return nil, err
}

return &PKAccount{
publicKey: ethsecp256k1.PubKey{
Key: key,
},
}
}, nil
}

func (pka *PKAccount) PublicKey() cryptoTypes.PubKey {
Expand Down

0 comments on commit 90661ad

Please sign in to comment.