php-secp256k1 icon indicating copy to clipboard operation
php-secp256k1 copied to clipboard

Verify Signature with JavaScript in browser.

Open CerebrallyPerplexed opened this issue 2 years ago • 0 comments

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...

CerebrallyPerplexed avatar May 09 '23 19:05 CerebrallyPerplexed