Curve25519 - Alice can decrypt her own message to Bob? I'm developing an application with multiple clients and one server.  All clients will have the same hard-coded Curve25519 key pair as well as the server's public key.  The server will have its own key pair as well as the clients' public key.

The idea was to allow communication between server and clients without any concern that the data from one client could be intercepted and decrypted by an attacker possessing the client key pair, nor could they originate messages that appeared to be from the server in order to control other clients.

I'm using libsodium and the crypto_box functions, and noticed that the following scenario works, which really puzzles me:

Alice has a key pair, pKa and sKa.
Bob has a key pair, pKb and sKb.
Each also have each other's public key (pKa and pKb)

Alice wants to send a message to Bob, so she passes pKb and sKa to crypto_box.
Bob can decrypt the message by passing pKa and sKb to crypto_box_open.
However, Eve has a copy of Alice's key pair and intercepted the outgoing message.  She uses crypto_box_open and passes in pKb and sKa, the same keys that were used to encrypt the message. This yields the plain text message.  She changes the message, re-encrypts it, and sends it on to Bob.

I'm relatively new to crypto, so I'm sure I must be doing something wrong or just misunderstanding the application of the technology.  If someone could help me out, that would be awesome.
However, Eve has a copy of Alice's key pair and intercepted the outgoing message.  She uses crypto_box_open and passes in pKb and sKa, the same keys that were used to encrypt the message. This yields the plain text message.  She changes the message, re-encrypts it, and sends it on to Bob.


As you correctly observed, Eve having Alice's private key is insecure. It allows Eve to decrypt and replace messages with arbitrary contents. In any public key encryption system it would allow Eve to at least replace messages, though some would not allow decryption.

An equally serious issue would be for messages going the other way. If Bob sends Alice a message, Eve who has Alices keys would be able to read and modify the message.

In short, private keys must be kept private. You cannot share a key-pair between multiple users unless they all trust each other completely. In your situation, the normal thing to do would be for each client to have their own key pair.