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

Add EVM builtin function to get ed25519 address mapped to secp256k1 address #1498

Open
enlight opened this issue Sep 24, 2019 · 2 comments
Open
Assignees
Labels
EVM feature-request Nice to haves, ideas, requests etc.

Comments

@enlight
Copy link
Contributor

enlight commented Sep 24, 2019

We should provide access to account mappings within Solidity contracts so devs can verify signed messages. Currently the address returned by ecrecover in a Solidity contract can't be matched to any DAppChain account (nor msg.sender).

It would look something like this:

// get the address matching the secp256k1 private key that signed the message
address signer = ecrecover(_message, _v, _r, _s);
// get the DAppChain address of the signer
address account = loom_native_api.mappedAccount('eth', signer);

This would need to be implemented as a precompiled EVM contract, we've got an example of doing so in

func TestPrecompiles(t *testing.T) {
and of course ecrecover and friends https://github.com/ethereum/go-ethereum/blob/master/core/vm/contracts.go

@enlight enlight added EVM feature-request Nice to haves, ideas, requests etc. labels Sep 24, 2019
@enlight
Copy link
Contributor Author

enlight commented Sep 30, 2019

Going the other way (DAppChain address -> Eth address) would also be useful:

// lookup the mapping of the DAppChain address of msg.sender to an Eth address
address ethAccount = loom_native_api.mappedAccount('loom', msg.sender, 'eth')
address signer = ecrecover(_message, _v, _r, _s);
// can now compare ethAccount to signer to verify msg.sender signed the message

@Sriep
Copy link
Contributor

Sriep commented Nov 8, 2019

Implemented in #1526

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EVM feature-request Nice to haves, ideas, requests etc.
Projects
None yet
Development

No branches or pull requests

2 participants