At the moment, I deal with PyNaCl (Docs) and have a question about it:
My situation is that I want to create a server that interacts with clients. Both the server and the client will have a long-term private key/keypair.
So, the situation will be that the client will send an encrypted request to the server and the server decrypt it.
The encryption process (by the client) is relatively easy:
encrypted = client_box.encrypt(message, nonce)
And the server can decrypt it with this way (the Docs say):
plaintext = server_box.decrypt(encrypted)
Now to the question:
For the encryption a 24-byte nonce is used for better security. But what I don't understand: Does the server have to know this 24-byte nonce too? In the Docs the decryption is done without a nonce it seems.
But the Docs say that I can also use a nonce for decryption (link) so that it looks this way:
plaintext = server_box.decrypt(encrypted, nonce)
But in the example in the docs they don't use the nonce in the decryption process.
Can, please, somebody explain me when I have to use the nonce and which nonce I have to use then?