Yes yes I know "don't invent your own protocols unless you're an expert". No need to yell at me I just want to know if there's a flaw in this idea and if not has anyone done it before.
The motivation here is I want to be able to authenticate users. I know that the standard solution is to salt and hash passwords. But I don't like the fact that the password itself must be sent to the server to check it. What if someone listens in? The client side can encrypt and send the password, but I don't like that either because maybe my decryption key leaks and someone who recorded previous web traffic can deduce all the passwords. Authentication is not a novel problem so I won't dwell any further on the pros and cons of the usual solutions.
My idea
For each user (a) the server stores a public key (g^x_a) and the password encrypted with that public key (g^{x_a} * p_a). The associated private key was either promptly destroyed or (better still) never calculated. The group generator g is held on to for future key generation. The usual relation applies g^a * g^b = g^{a+b}. The authentication process is as follows
The user Alice asks to be authenticated
The server Bob generates a new temporary public key g^t (again without an associated private key). Bob multiplies this temporary public key on his Alice data. This results in g^t * g^{x_a} = g^{t + x_a} = g^{x_a}' and g^t * g^{x_a} * p_a = g^{t + x_a} * p_a = g^{x_a}' * p_a. Bob disposes of the temporary public key leaving him only with a new public key (g^{x_a}') and Alice's password encrypted with this key. He sends the new key to Alice.
Alice takes the key given by Bob uses it to encrypt her password. She sends the encrypted value to Bob.
Bob authenticates Alice if the value given matches with the encrypted data calculated in step 2.
To recap
At no point in time can the server (or a database hacker) decrypt the password. With the private keys gone the public key encryption effectively works like a hash.
Since each user is encrypted with a different key, the passwords are effectively salted. A rainbow table would not work here.
A hacker with a previous image of the database cannot deduce future values of g^x_a * p_a by listening in on web traffic since that would require deducing the temporary key (which requires solving discrete log). Thus a leaked database image does not allow an attacker to impersonate users.
Neither the server nor the client has any private keys to manage. Only the client needs to keep secret information and the secret information can be human readable.
(drawback) an attacker has a small window of time between steps 2 and 4 where he can penetrate the server and impersonate a user using the data he found.