spcnvdr/xchacha20 ? reverse-engineered prompt

Reverse engineered prompt

Build me a small C library for XChaCha20, with a simple API that I can drop into another project. I want it to use only a 256 bit key and a 192 bit nonce, with no other sizes allowed, and I want the code to be based on the reference ChaCha approach without lookup tables. Please include a header file and the core source code, plus a tiny test program that checks the output against known good test vectors and prints a clear success or failure message.

I’d like the library to let me create a context, set up the key and nonce, optionally set a starting counter, and then encrypt data by bytes or by blocks. Make sure it’s easy to build with a simple Makefile, and keep the project clean and small. If you need to, look up current docs online for the XChaCha20 draft or compatible test vectors so the implementation matches the expected behavior.