rpc, evm: secure tx signing (#20)

* rpc, evm: secure signing

* evm, ante: test signer

* tests
This commit is contained in:
Federico Kunze
2021-05-12 09:08:31 -04:00
committed by GitHub
parent decd0748ac
commit 65453e4aa0
13 changed files with 439 additions and 201 deletions
+6 -1
View File
@@ -17,9 +17,11 @@ import (
"github.com/cosmos/ethermint/app"
ante "github.com/cosmos/ethermint/app/ante"
"github.com/cosmos/ethermint/crypto/ethsecp256k1"
"github.com/cosmos/ethermint/tests"
ethermint "github.com/cosmos/ethermint/types"
evmtypes "github.com/cosmos/ethermint/x/evm/types"
"github.com/ethereum/go-ethereum/common"
ethcrypto "github.com/ethereum/go-ethereum/crypto"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
@@ -102,7 +104,10 @@ func newTestSDKTx(
func (suite *AnteTestSuite) newTestEthTx(msg *evmtypes.MsgEthereumTx, priv cryptotypes.PrivKey) (sdk.Tx, error) {
privkey := &ethsecp256k1.PrivKey{Key: priv.Bytes()}
if err := msg.Sign(suite.chainID, privkey.ToECDSA()); err != nil {
signer := tests.NewSigner(privkey)
msg.From = common.BytesToAddress(privkey.PubKey().Address().Bytes()).String()
if err := msg.Sign(suite.chainID, signer); err != nil {
return nil, err
}