trustwallet / wallet-connect-swift

WalletConnect Swift client SDK
MIT License
102 stars 130 forks source link

eth_sign behavior is not compatible with JSON RPC spec and other wallet implementations. #32

Open dvush opened 4 years ago

dvush commented 4 years ago

When using JSON-RPC method "eth_sign" as described here https://eth.wiki/json-rpc/API user is asked to sign hex of the message instead of the actual message.

This behavior in inconsistent with other wallets such as metamask, geth, argent, etc.

On the other hand "personal_sign" with the same arguments (in different order) works as expected.

hewigovens commented 4 years ago

do you have sample request/response? or you just mean the UI in Trust wallet?

dvush commented 4 years ago

I don't have sample request response, because it depends on particular private key and I think it easy to generate sample request response, since "personal_sign" works as expected. (and they have the same arguments but in different order).

I used very convoluted sample page that I set up for debugging this particular issue and I think it would be easier for developers of the Trust Wallet to setup simple test that will compare outputs of "personal_sign" [1] and "eth_sign" [2] with the same arguments.

I don't think there are any problem with UI, because in UI when I use "personal_sign" I see human readable message and resulting signature is correct, but when I do "eth_sign" I see correct hex representation of this message and signature is incorrect, that is why I think that "eth_sign" signs hex of the message, but I never checked this explicitly.

  1. https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
  2. https://eth.wiki/json-rpc/API#eth_sign