Introduction (opening sentences)
When we designed ProxyAuth, performance alone wasn’t enough. Security had to be built in from the ground up — not bolted on as an afterthought. That’s why ProxyAuth relies on cutting-edge cryptographic primitives like ChaCha20-Poly1305, BLAKE3, and HMAC to guarantee both speed and safety. In this post, we’ll take a closer look at how cryptography powers ProxyAuth, why these algorithms were chosen, and how they keep authentication both secure and blazing fast.
Chapter 1: The Cryptographic Core of ProxyAuth
At the heart of ProxyAuth lies ChaCha20-Poly1305 AEAD (Authenticated Encryption with Associated Data) — a stream cipher paired with a robust integrity check. Every token is encrypted using ChaCha20 to ensure confidentiality, while Poly1305 guarantees that nothing can be tampered with along the way. This combination is trusted in modern protocols like TLS 1.3 and WireGuard, making it both fast and battle-tested.
But ProxyAuth doesn’t stop there. Beneath the encryption layer, there’s a BLAKE3 hash chain. This chain is not static: before each validation step, ProxyAuth applies a lightweight XOR rotation to the hash. This small twist ensures that the output is constantly shifting, making it even harder for an attacker to replay or predict values.
Alongside the encrypted payload, ProxyAuth attaches metadata linked to the BLAKE3 hash. When a token is presented, ProxyAuth recalculates the chain. If the provided metadata doesn’t match the expected BLAKE3 output, the token is immediately rejected. In other words, even if someone tried to tamper with the ciphertext, the mismatch in the hash layer would expose the fraud instantly.
This layered approach — encryption plus dynamic hashing — is what makes ProxyAuth resilient against forgery and replay, while keeping performance high.
Chapter 2: Token Lifecycle Explained
The diagram above shows how a token in ProxyAuth is created, transformed, and secured. Let’s break it down step by step:
- Secrets as the foundation
- Every token starts with secrets defined in
config.jsonand additional keys generated during build time. These secrets ensure that even if two ProxyAuth instances run in different environments, their tokens cannot be forged or reused across systems. - BLAKE3 hashing with XOR rotation
- Before encryption, ProxyAuth applies a BLAKE3 hash over the token’s data. This hash is then modified by a bitwise XOR rotation and strengthened by injecting the server-side secret. The result is a unique fingerprint (
AZDMLPOKOP...) that cannot be predicted or forged without access to both the build-time and runtime secrets. - Plaintext data binding
- Alongside the hash, ProxyAuth stores human-readable fields:
tokenidexpire_token(timestamp like2025-12-12 12:35:11)id_username(numeric user reference)
- These values are checked against the BLAKE3 output. If the plaintext metadata does not match the expected hash chain, the token is rejected immediately.
- Final ChaCha20-Poly1305 encryption
- Once the hash and metadata are assembled, the whole structure is encrypted using ChaCha20-AEAD. This ensures confidentiality (nobody can read the token contents) and authenticity (Poly1305 prevents tampering).
In short, ProxyAuth tokens are double-protected: first by a dynamic BLAKE3 + XOR verification chain, and then by strong AEAD encryption. Even if an attacker tried to alter the expiry date or user ID, the mismatch with the BLAKE3 signature would expose the tampering before the token is even decrypted.