komputing / KEthereum

Kotlin library for Ethereum
MIT License
350 stars 73 forks source link

Prefixed signature support #48

Closed generalpiston closed 5 years ago

generalpiston commented 5 years ago

eth_sign: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign. Signatures derived from eth_sign should take on this form: sign(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))). Seems like something wallet providers should handle.

ligi commented 5 years ago

can you elaborate a bit more what you propose?

ligi commented 5 years ago

closing this for now - please reopen with a more clear description what you have in mind here

generalpiston commented 5 years ago

I had to add it myself in https://github.com/sigillabs/mobidex/blob/3dcd0783c5743268d795a3d8e6f069ad0c229c7e/android/app/src/main/java/io/mobidex/WalletManagerModule.java#L397.

There are two ways that would work:

  1. Add the message to https://github.com/walleth/kethereum/blob/master/crypto/src/main/kotlin/org/kethereum/crypto/Sign.kt#L30 ?
  2. Add a new method ECKeyPair called signMessageWithPrefix?

Idea 2 seems to make the most sense to maintain backwards compatibility.

ligi commented 5 years ago

I think we should go with option 3 - add a new module with functions to support EIP191 - the function you want can be expressed with this. I do not think it should go into the crypto module - I opened #51 for this

generalpiston commented 5 years ago

Perfect! Thank you!