Hi,
You get the address with JS and send it back to PHP (is it secure)?
That’s right.
First you send the client (user) a message to be signed, then the client sends back the signature and their address.
Now you have the signature from the user, you re-create the message that was signed, server-side, to make sure there’s no foul play, you send both of those (the signature and the plain message) to the JS service, and the service responds with the address that was extracted.
Then you check if the address which was extracted matches that which the client sent you.
There’s 2 points of risk (that I can think of):
1. The signature of the message could be signed somewhere else and then get re-used on your website. We’re using 5 minute nonces to make that difficult. Still, leaves room for improvement.
2. Then there’s the JS service, and the 3rd party version *could* be compromised (unlikely, but still). That’s why, in EthPress version 0.6.0, there’s a also PHP version for the signature verification if you have PHP extensions. Otherwise, you ought to host it yourself.
As for that #1, there’s 2 plans to improve the replay problem:
1. Use databased nonces, as described here. That would make the message change every time, not just every 5 minutes. But that isn’t perfect, either. In fact, that’s hardly an improvement, as explained below.
2. Use zero-knowledge proof. This would be something nicer, brought to my attention by another EthPress user, and would get around the susceptibility phishing scam that we currently have.
A phishing scammer has to fish the signature out of you to log in, so they’d host a website gets the signature from your website, instead of their own, and then maliciously use that signature to log into your website with their “stolen” signature.
This really isn’t that much different from regular phishing, hosting a lookalike website with a login form, but the issue is that people might not yet understand to not sign every message that comes their way, even though they’ll understand not to enter their username/password on every website.
The zero-knowledge proof would not have that issue, but I’m yet unclear on how to implement that, if possible.
I ended up writing a whole bunch. Hope that helps.