ChaCha20 Inner State Stepper
Step through the 4×4 state matrix of ChaCha20 quarter-round by quarter-round. Set key and nonce, watch which cells change in each of the 320 sub-ops.
chacha20 · stream-cipher · rfc-7539
Step through the 4×4 state matrix of ChaCha20 quarter-round by quarter-round. Set key and nonce, watch which cells change in each of the 320 sub-ops.
chacha20 · stream-cipher · rfc-7539
ChaCha20's beauty is in its simplicity: 16 32-bit words, ARX operations (add–rotate–xor), 20 rounds. The entire mystery lives in a 4-line quarter round and a column → diagonal swap.
This lab decomposes the algorithm at sub-op granularity. Each click applies exactly one line of ARX; you can randomize the key/nonce and auto-play at 1× / 4× / 16×. 320 sub-ops = 80 quarter rounds = 10 double rounds = full ChaCha20.
Educational only. RFC 7539 inner permutation görselleştirmek için TS'te yeniden yazıldı — WebCrypto round state vermiyor. Üretimde crypto.subtle veya @noble/ciphers kullan.
—617078653320646e79622d326b20657403020100070605040b0a09080f0e0d0c13121110171615141b1a19181f1e1d1c00000000090000004a00000000000000Counter'ı değiştir — keystream tamamen değişir, ciphertext da değişir. Aynı key/nonce çifti ile farklı counter her zaman farklı bir 64-byte blok üretir. Aynı XOR hem encrypt hem decrypt yapar.
Each cell of the 4×4 grid represents a different role, color-coded:
"expand 32-byte k" — 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574. Never change (at the start), identical across every ChaCha20 instance.0, 1, 2, ... to distinguish blocks.Four sub-ops in one line:
a += b; d ^= a; d = ROTL(d, 16)c += d; b ^= c; b = ROTL(b, 12)a += b; d ^= a; d = ROTL(d, 8)c += d; b ^= c; b = ROTL(b, 7)
Only add, XOR, left-rotate — constant-time, branchless, hardware-friendly.
In one double round:
QR(0,4,8,12), QR(1,5,9,13), QR(2,6,10,14), QR(3,7,11,15)QR(0,5,10,15), QR(1,6,11,12), QR(2,7,8,13), QR(3,4,9,14)10 double rounds = 20 rounds. At the end, the working state is added to the initial state and serialized little-endian → 64-byte keystream block.
This implementation is for visualisation only — it conforms to RFC 7539 but is not timing-attack resistant or side-channel hardened.
For real encryption:
crypto.subtle (Node 19+ included) — ChaCha20-Poly1305 may not be supported; use AES-GCM@noble/ciphers or @stablelib/chacha20poly1305crypto.createCipheriv('chacha20-poly1305', ...) (OpenSSL underneath)