Verify Signature with JavaScript in browser.
I can successfully use this as a PHP sign & verify message on server. But have been attempting to verify the generated signature in browser using ethers.utils.verifyMessage( message , signature ) from ethers.js
I cannot get the signature HEX string, or any combination of r, s, v into a format that verifyMessage will accept.
What I am trying to achieve is:
[BROWSER] Knows wallet address -> User inputs plaintext message in text input. ---> Sends plaintext message to server via AJAX plus Address [SERVER PHP] Signs message with the Private Key for Address and returns Signature to browser. [BROWSER] Verifies message and returns the address which is compared to the original Address They match = success!
Would be grateful for any insight / thoughts...
[UPDATE] I just found that I need to prefix the Signature String with 0x and add 01 at end of the HEX string being the v value. BUT now verifyMessage returns a completely different Address than the Private Key generates when using your ethereum-address library...