Consensys / eth-lightwallet

Lightweight JS Wallet for Node and the browser
MIT License
1.47k stars 503 forks source link

[Question] How can I use eth-lightwallet to verify a signature? #105

Closed thiagodelgado111 closed 8 years ago

thiagodelgado111 commented 8 years ago

I have the following message: '0xdeadbeefdeadbeefdeadbeef' and I'm using eth-lightwallet to sign it like this:

signedMsg = lightwallet.signing.signMsg(keystore, pwDerivedKey, '0xdeadbeefdeadbeefdeadbeef', '0xd5311ad626f09d0f9d1b1f7cdb84fdd600efbc1d');

It gives me this back: 0x348bdaeacdc93823b136f7d4f87a1c10be001de19a844c2d6751647a0c7fe5ee5451791e9696e08f815d851ad840c5a10a96cae9a5735d7c920bbfb39dfd30041c. How can I verify a signed msg later? Using recoverAddress? is there an example of how to do that?

danielnovy commented 8 years ago

Take a look at the testing code here: https://github.com/ConsenSys/eth-lightwallet/blob/master/test/signing.js#L81

thiagodelgado111 commented 8 years ago

oh, that will do the trick! :) thanks, @danielnovy!

thiagodelgado111 commented 8 years ago

I'm trying to use it together with the web3.js web3.eth.sign method but I can't figure out what I'm doing wrong. It should give me back the address I used to sign the message, right?

[EDIT]: I was erroneously passing a web3.sha3 as the first parameter for recoverAddress instead of the message, fixed that and it is working like charm! sorry for bothering! :)