OTRv4+ – full OTRv4 with post‑quantum crypto (ML‑KEM/ML‑DSA) in a single‑file Python

Posted by cryptocreeping@reddit | Python | View on Reddit | 8 comments

What My Project Does

OTRv4+ is a complete implementation of the OTRv4 protocol that adds post‑quantum cryptography to every layer. It includes:

· Full OTRv4 features: fingerprint trust management, SMP (Socialist Millionaire Protocol), double ratchet with brace key.

· Post‑quantum additions: Triple X448 + ML‑KEM‑1024 for key exchange, Ed448 ring signatures + ML‑DSA‑87 for authentication (making auth PQ‑secure – unlike Signal’s PQXDH), and fresh ML‑KEM‑1024 at every DH epoch for the ratchet.

· Built as a single Python file (\~12k lines) plus three small C extensions (performance‑critical crypto glue).

· Runs on IRC, supports I2P/Tor, and works on Termux (tested on a phone).

· Includes a WeeChat plugin (ready for testing – I haven’t fully tested it yet).

Target Audience

· Security researchers / cryptography enthusiasts who want to experiment with post‑quantum OTR on real IRC networks.

· Termux users looking for a portable, encrypted chat solution on their phone.

· WeeChat users who want end‑to‑end encrypted IRC with post‑quantum protections (beta testers welcome).

· Python developers interested in single‑file protocol implementations, OpenSSL 3.5+ FIPS providers (no liboqs), or auditing a moderately sized crypto codebase.

Not intended for production use yet – it’s a research prototype and testing ground.

Comparison

· vs. Signal’s PQXDH: Signal’s handshake adds ML‑KEM but explicitly states “Authentication in PQXDH is not quantum‑secure”. OTRv4+ uses ML‑DSA‑87 to make authentication post‑quantum as well (trade‑off: loses PQ deniability – a known open problem).

· vs. liboqs‑based solutions: This project uses OpenSSL 3.5+ native FIPS 203/204 providers – no external liboqs dependency.

· vs. other OTR implementations (libotr, etc.): Those are not post‑quantum and don’t implement OTRv4’s modern ratchet. OTRv4+ aims for full spec compliance plus PQ hardening.

· vs. single‑file Python tools: Most crypto protocols are spread across many files. This keeps the whole OTRv4 state machine and PQ logic in one file for easier auditing.

Try it

```bash

git clone https://github.com/muc111/OTRv4Plus

```

Requires Python 3.9+, OpenSSL 3.5+, and a C compiler. Works on Linux, Termux, probably other Unix‑likes. Auto‑detects I2P/Tor/clearnet from hostname.

Feedback, issues, PRs welcome. For commercial licensing, open an issue with label commercial-license.

Cheers!