crypto: refactor for stargate (#559)

* changelog

* update changelog

* crypto: refactor for stargate

* fixes

* fix keys

* changelog
This commit is contained in:
Federico Kunze
2020-10-06 20:57:55 +02:00
committed by GitHub
parent e7a19a1c0a
commit 4e01da905a
32 changed files with 165 additions and 146 deletions
+3 -3
View File
@@ -8,14 +8,14 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/ethermint/crypto"
"github.com/cosmos/ethermint/crypto/ethsecp256k1"
evmtypes "github.com/cosmos/ethermint/x/evm/types"
tmcrypto "github.com/tendermint/tendermint/crypto"
)
func init() {
crypto.RegisterCodec(types.ModuleCdc)
ethsecp256k1.RegisterCodec(types.ModuleCdc)
}
const (
@@ -76,7 +76,7 @@ func sigGasConsumer(
meter sdk.GasMeter, _ []byte, pubkey tmcrypto.PubKey, _ types.Params,
) error {
switch pubkey.(type) {
case crypto.PubKeySecp256k1:
case ethsecp256k1.PubKey:
meter.ConsumeGas(secp256k1VerifyCost, "ante verify: secp256k1")
return nil
case tmcrypto.PubKey:
+3 -3
View File
@@ -12,7 +12,7 @@ import (
"github.com/cosmos/ethermint/app"
ante "github.com/cosmos/ethermint/app/ante"
"github.com/cosmos/ethermint/crypto"
"github.com/cosmos/ethermint/crypto/ethsecp256k1"
ethermint "github.com/cosmos/ethermint/types"
evmtypes "github.com/cosmos/ethermint/x/evm/types"
@@ -60,7 +60,7 @@ func newTestStdFee() auth.StdFee {
// GenerateAddress generates an Ethereum address.
func newTestAddrKey() (sdk.AccAddress, tmcrypto.PrivKey) {
privkey, _ := crypto.GenerateKey()
privkey, _ := ethsecp256k1.GenerateKey()
addr := ethcrypto.PubkeyToAddress(privkey.ToECDSA().PublicKey)
return sdk.AccAddress(addr.Bytes()), privkey
@@ -95,7 +95,7 @@ func newTestEthTx(ctx sdk.Context, msg evmtypes.MsgEthereumTx, priv tmcrypto.Pri
return nil, err
}
privkey, ok := priv.(crypto.PrivKeySecp256k1)
privkey, ok := priv.(ethsecp256k1.PrivKey)
if !ok {
return nil, fmt.Errorf("invalid private key type: %T", priv)
}