Attention! Read before use!

This is an end-to-end encrypted chat application with an option to perform a manual DH key exchange. The DH implementation is based on RFC 7919 and it is the most basic modular arithmetic version. Therefore it is NOT quantum resistant. A future quantum computer might be able to break it in minutes if your exchange is observed by an attacker. As of 2023, we're very far away from doing that. You can still perform an in-person exchange of keys, which if not observed by a third party will be secure (you will then only input the symmetric key before starting the conversation, skipping the key exchange part). The encryption is carried out using ChaCha20 implemented in JavaScript as in RFC 7539. The authentication is performed using Poly1305, according to the very same RFC 7539. Argon2 is used for key derivation. Along with ChaCha20 and Poly1305, they are mostly unaffected by quantum computers. Therefore the part below the key exchange should remain secure for a long time, if ever broken at all.
The ChaCha20-Poly1305 implementation was verified against https://datatracker.ietf.org/doc/html/rfc7539 test vectors. These tests can be run using the Tester class' static methods in console. For your own testing and further information, visit https://chacha.kotol.cloud where you can try the encryption and authentication yourself. It also has much nicer visuals than this one. For the technical users out there, you can also inspect the WebSocket traffic and plug the messages directly into the other site. They are compatible with each other. To view the source code, use your DevTools, it is not minified nor obfuscated.

Logging
What is being logged by the server or the client:
What is NOT being logged by the server or the client:
Understanding the above, go ahead and enjoy the mini project :)

Manual Diffie-Hellman key exchange

Public generator G
Public modulus p
Your secret a:
Your public G^a:

Your secret a
Their public G^a (G^b for us)
The shared secret:
The derived shared symmetric key:
Key hash, safe to publish (verify that you have the same over a different channel to ensure your public values were not changed by an attacker on the way):

Join a room

Room name
Symmetric key

Chat

The upload mechanism is quite primitive. A full file is always buffered into the RAM before any operation (encrypt, upload, download, decrypt) is performed. Please, don't upload files over 300 MB in size, it will likely lag/crash your tab (encryption is synchronous and JS-only, coming in at just around 15 MB/s). The server is also set up to reject files over ~300 MB in size.