{"id":50486867,"url":"https://github.com/systemslibrarian/crypto-lab-chacha20-stream","last_synced_at":"2026-06-01T23:02:43.391Z","repository":{"id":351099800,"uuid":"1204603779","full_name":"systemslibrarian/crypto-lab-chacha20-stream","owner":"systemslibrarian","description":"Browser-based ChaCha20 stream cipher — quarter-round stepper, keystream visualizer, nonce reuse attack demo, and encrypt/decrypt playground. ARX design, no AES-NI required. Part of crypto-lab.","archived":false,"fork":false,"pushed_at":"2026-04-13T15:03:58.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-13T17:22:11.039Z","etag":null,"topics":["arx-cipher","browser-demo","chacha20","crypto-lab","cryptography-education","nonce-reuse","poly1305","stream-cipher","typescript","vite"],"latest_commit_sha":null,"homepage":"https://systemslibrarian.github.io/crypto-lab-chacha20-stream/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/systemslibrarian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-08T06:47:42.000Z","updated_at":"2026-04-13T15:04:02.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/systemslibrarian/crypto-lab-chacha20-stream","commit_stats":null,"previous_names":["systemslibrarian/crypto-lab-chacha20-stream"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/systemslibrarian/crypto-lab-chacha20-stream","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemslibrarian%2Fcrypto-lab-chacha20-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemslibrarian%2Fcrypto-lab-chacha20-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemslibrarian%2Fcrypto-lab-chacha20-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemslibrarian%2Fcrypto-lab-chacha20-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/systemslibrarian","download_url":"https://codeload.github.com/systemslibrarian/crypto-lab-chacha20-stream/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemslibrarian%2Fcrypto-lab-chacha20-stream/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33797128,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arx-cipher","browser-demo","chacha20","crypto-lab","cryptography-education","nonce-reuse","poly1305","stream-cipher","typescript","vite"],"created_at":"2026-06-01T23:02:40.330Z","updated_at":"2026-06-01T23:02:43.386Z","avatar_url":"https://github.com/systemslibrarian.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crypto-lab-chacha20-stream\n\n[![Deploy to GitHub Pages](https://github.com/systemslibrarian/crypto-lab-chacha20-stream/actions/workflows/pages.yml/badge.svg)](https://github.com/systemslibrarian/crypto-lab-chacha20-stream/actions/workflows/pages.yml)\n\n## What It Is\n\nChaCha20 is a 256-bit stream cipher designed by Daniel J. Bernstein, standardized in RFC 8439. It encrypts data by XORing plaintext with a pseudorandom keystream generated from a 256-bit key, a 96-bit nonce, and a 32-bit block counter. The cipher uses an ARX construction (Add-Rotate-XOR) that operates entirely with constant-time instructions, providing confidentiality without relying on hardware acceleration. This demo implements the full ChaCha20 block function from scratch for visualization and uses `@noble/ciphers` for production encrypt/decrypt operations.\n\n## When to Use It\n\n- **Mobile and IoT encryption without AES-NI** — ChaCha20 runs 2–3× faster than software AES on devices lacking hardware AES instructions, which includes most ARM chips before ARMv8 Cryptography Extensions.\n- **Side-channel-resistant symmetric encryption** — The ARX design has no S-box table lookups, eliminating the cache-timing attacks that plague software AES implementations.\n- **TLS and QUIC cipher suites** — ChaCha20-Poly1305 is a first-class cipher suite in TLS 1.3 and the default in QUIC on devices without AES-NI.\n- **High-throughput stream encryption** — ChaCha20 produces 64 bytes of keystream per block with simple 32-bit operations, making it efficient for bulk data encryption.\n- **Do NOT use ChaCha20 alone for authenticated encryption** — ChaCha20 provides confidentiality only. Always pair it with Poly1305 (or another MAC) to get integrity and authenticity in production systems.\n\n## Live Demo\n\n**[Launch Demo →](https://systemslibrarian.github.io/crypto-lab-chacha20-stream/)**\n\nThe demo includes four interactive sections: an encrypt/decrypt playground where you can generate keys and nonces, type plaintext, and see ciphertext in real time; a keystream visualizer showing 64 bytes as a color-coded grid that changes completely when you regenerate the nonce; a quarter-round stepper that walks through all 80 quarter-round operations of the ChaCha20 block function showing the 4×4 state matrix at each step; and a nonce reuse attack demo that encrypts two messages with the same key+nonce and reveals how XORing the ciphertexts recovers the XOR of the plaintexts.\n\n## What Can Go Wrong\n\n- **Nonce reuse (two-time pad)** — Encrypting two messages with the same key and nonce produces identical keystreams, so XORing the ciphertexts yields the XOR of the plaintexts. The demo's Section D demonstrates this directly.\n- **Missing authentication** — ChaCha20 is malleable: an attacker can flip bits in the ciphertext and the corresponding plaintext bits flip predictably. Without Poly1305 or another MAC, tampered ciphertext decrypts without any error.\n- **Counter overflow** — The 32-bit block counter limits a single key+nonce pair to 2³² blocks (256 GB). Exceeding this wraps the counter and reuses keystream, silently breaking confidentiality.\n- **96-bit nonce collision risk** — With a 96-bit nonce, randomly generating nonces becomes unsafe after roughly 2³² messages per key (birthday bound). For random nonces, use XChaCha20 with its 192-bit nonce instead.\n\n## Real-World Usage\n\n- **TLS 1.3 (RFC 8446)** — ChaCha20-Poly1305 is a mandatory-to-implement cipher suite, used as the preferred cipher when AES-NI is unavailable.\n- **Google QUIC / HTTP/3** — Google chose ChaCha20-Poly1305 for QUIC transport encryption on Android devices lacking AES hardware support.\n- **WireGuard VPN** — Uses ChaCha20-Poly1305 as its sole symmetric cipher for tunnel encryption, chosen for its speed and simplicity.\n- **OpenSSH** — Supports `chacha20-poly1305@openssh.com` as a transport cipher, widely deployed as the default on many distributions.\n- **NaCl / libsodium** — The `crypto_secretbox` API uses XSalsa20-Poly1305 (closely related to XChaCha20), and libsodium also exposes ChaCha20-Poly1305 directly.\n\n---\n\n### Cross-links\n\n- [AES Modes](https://systemslibrarian.github.io/crypto-lab-aes-modes/)\n- [Shadow Vault](https://systemslibrarian.github.io/crypto-lab-shadow-vault/)\n- [Ratchet Wire](https://systemslibrarian.github.io/crypto-lab-ratchet-wire/)\n- [Noise Pipe](https://systemslibrarian.github.io/crypto-lab-noise-pipe/)\n- [crypto-lab home](https://systemslibrarian.github.io/crypto-lab/)\n\n---\n\n\"So whether you eat or drink or whatever you do, do it all for the glory of God.\" — 1 Corinthians 10:31\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystemslibrarian%2Fcrypto-lab-chacha20-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsystemslibrarian%2Fcrypto-lab-chacha20-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystemslibrarian%2Fcrypto-lab-chacha20-stream/lists"}