cosmos-sdk
cosmos-sdk copied to clipboard
EVM Address Support
trafficstars
Although the basic public type used in both Ethereum and Cosmos is secp256k1, the address derivation is different so Ethereum and Cosmos addresses are not the same for the same public key.
here are my thoughts:
- Issues with coin types and HD derivation paths are purely a wallet issue and completely opaque to state machines. As long as the desired Ethereum wallets support custom HD paths, it should be possible to import existing private keys and derive the same public key.
- The general design of having two address spaces makes a lot of sense and is the conclusion we previously came to regarding supporting multiple VMs - basically when you're in the Cosmos world a pubkey gets a
cosmos1address and when you're in the EVM world the same pubkey should get a different0xaddress - We do need to address more than just
secp256k1public keys. They are less common, but there are other address types that are supported in Cosmos. In particular, all chains have synthetic module account addresses which are sometimes 32 bytes long. We need a mechanism to derive an EVM address for all account types. - Creating a separate account type such as
ETHAccountis the right instinct, but overloadingAccountIis somewhat problematic in general. If all accounts should actually have an EVM address, then I believe a better solution is to actually have a map in state fromCosmos address->EVM Address(ex.collections.Map[sdk.AccAddress, EVMAddress]).