{"id":50487187,"url":"https://github.com/systemslibrarian/crypto-lab-dilithium-reject","last_synced_at":"2026-06-01T23:04:37.772Z","repository":{"id":352492564,"uuid":"1215339316","full_name":"systemslibrarian/crypto-lab-dilithium-reject","owner":"systemslibrarian","description":"Browser-based demo of ML-DSA (FIPS 204) rejection sampling. Live iteration feed, rejection-reason breakdown, acceptance histograms, and the timing side-channel tradeoff — why variable signing time is a feature, not a bug.","archived":false,"fork":false,"pushed_at":"2026-05-23T13:32:45.000Z","size":960,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-23T15:22:24.685Z","etag":null,"topics":["constant-time","crypto-lab","cryptography","crystals-dilithium","digital-signatures","dilithium","fiat-shamir-with-aborts","fips-204","implementation-security","lattice-cryptography","lattice-signatures","lyubashevsky","ml-dsa","ml-dsa-65","post-quantum-cryptography","rejection-sampling","timing-side-channel"],"latest_commit_sha":null,"homepage":"https://systemslibrarian.github.io/crypto-lab-dilithium-reject/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","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-19T19:36:45.000Z","updated_at":"2026-05-23T13:32:31.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/systemslibrarian/crypto-lab-dilithium-reject","commit_stats":null,"previous_names":["systemslibrarian/crypto-lab-dilithium-reject"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/systemslibrarian/crypto-lab-dilithium-reject","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemslibrarian%2Fcrypto-lab-dilithium-reject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemslibrarian%2Fcrypto-lab-dilithium-reject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemslibrarian%2Fcrypto-lab-dilithium-reject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemslibrarian%2Fcrypto-lab-dilithium-reject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/systemslibrarian","download_url":"https://codeload.github.com/systemslibrarian/crypto-lab-dilithium-reject/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/systemslibrarian%2Fcrypto-lab-dilithium-reject/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33797146,"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":["constant-time","crypto-lab","cryptography","crystals-dilithium","digital-signatures","dilithium","fiat-shamir-with-aborts","fips-204","implementation-security","lattice-cryptography","lattice-signatures","lyubashevsky","ml-dsa","ml-dsa-65","post-quantum-cryptography","rejection-sampling","timing-side-channel"],"created_at":"2026-06-01T23:04:37.096Z","updated_at":"2026-06-01T23:04:37.767Z","avatar_url":"https://github.com/systemslibrarian.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crypto-lab-dilithium-reject\n\nBrowser-based explainer for ML-DSA rejection sampling: the Fiat-Shamir with Aborts loop that makes lattice signatures secure.\n\n[**Live demo →**](https://systemslibrarian.github.io/crypto-lab-dilithium-reject/)\n\n![ML-DSA Rejection Sampling Explorer — dark theme, showing iteration trace and histogram of iterations until acceptance](docs/screenshot.png)\n\n\u003cdetails\u003e\n\u003csummary\u003eLight theme\u003c/summary\u003e\n\n![Light theme: same layout, light palette](docs/screenshot-light.png)\n\n\u003c/details\u003e\n\n\u003e \"Whether therefore ye eat, or drink, or whatsoever ye do, do all to the glory of God.\"\n\u003e 1 Corinthians 10:31\n\n## What It Is\n\nThis project visualizes the signing rejection loop used by ML-DSA (FIPS 204, August 2024). It walks through what happens iteration by iteration: a candidate is drawn, four norm-bound checks are applied, and either the candidate is accepted or one specific check fails and the loop retries.\n\nThe demo targets ML-DSA-65 (NIST level 3) by default and uses strict TypeScript with a browser-only stack (Vite + vanilla CSS, no backend).\n\nHighlights:\n- Live iteration feed with explicit rejection reason (`z_too_large`, `r0_too_large`, `ct0_too_large`, `hint_too_dense`)\n- Histogram of iterations-until-acceptance over many signatures, per parameter preset\n- KS-style distinguishability test for the principle behind sk-independent timing\n- Comparison table across Ed25519, ECDSA, ML-DSA, SLH-DSA, FALCON, LMS\n- Exhibit explaining why each rejection check exists in FIPS 204\n\n## How This Demo Works (Important)\n\nThe iteration feed in Exhibit 1 and the histogram in Exhibit 2 are a **didactic simulation calibrated to ML-DSA's published acceptance distribution**, not a fork of the real signing internals.\n\n- Acceptance per iteration is a coin flip with `p(accept)` set per preset (~0.31 for ML-DSA-44, ~0.26 for ML-DSA-65, ~0.22 for ML-DSA-87). These are **illustrative values calibrated to the order-of-magnitude reported by published ML-DSA implementations**; treat them as the right shape of the distribution, not as measurements. The calibration is asserted by `src/instrumented-sign.test.ts`, which fails the build if mean iterations drift more than ±15% from `1/acceptance`.\n- When a candidate is rejected, the specific reason is sampled from the published mix (z dominates, r0 next, ct0 and hint rare). The displayed `||z||∞`, `||r0||∞`, `||c·t0||∞` values are positioned above/below their thresholds to be consistent with that reason; they are not computed from a live `y + c·s1` etc.\n- The actual signature shown as \"valid\" is produced by [`@noble/post-quantum`](https://www.npmjs.com/package/@noble/post-quantum)'s real ML-DSA implementation. The verification check uses the same library. That part is real.\n- `src/mldsa-primitives.ts` contains real implementations of `infinityNorm`, `highBits`/`lowBits`, `hintWeight`, and a SampleInBall variant; it is wired into the demo for the per-check explanation exhibit but does not drive the iteration feed.\n\nThis separation is deliberate: instrumenting `@noble/post-quantum`'s signing loop from outside the library would require patching internals, while the goal here is pedagogical clarity. The simulation is faithful to the *shape* and *reasons* — not the bit-exact arithmetic — of FIPS 204 § 6.\n\nIf you need bit-exact internal traces of real ML-DSA signing, use a reference implementation that exposes per-iteration hooks (e.g. NIST's C reference) rather than this demo.\n\n## When to Use It\n\nUse this demo when you need to:\n- teach why ML-DSA signing time is variable by design\n- explain Fiat-Shamir with Aborts in lattice signatures\n- show that rejection is a security feature, not an implementation bug\n- discuss timing side-channel risk tradeoffs in post-quantum signatures\n- compare ML-DSA timing behavior with other signature families\n\nDo not use this project as production signing code. For production, use maintained, hardened libraries and platform-specific side-channel countermeasures.\n\n## Install and Run\n\n```bash\nnpm install\nnpm run dev       # local dev server with hot reload\nnpm run build     # type-check + production build to ./dist\nnpm run preview   # serve the built bundle\n```\n\nRequires Node 22+. The build is a static bundle; the GitHub Pages workflow (`.github/workflows/deploy.yml`) publishes `./dist` to `gh-pages` on each push to `main`.\n\n## Live Demo\n\nhttps://systemslibrarian.github.io/crypto-lab-dilithium-reject/\n\n## What Can Go Wrong (in real deployments)\n\n- Variable signing time can become a side-channel if deployment hardening is weak.\n- Worst-case retries matter operationally; FIPS 204 permits bounded loops with failure return.\n- Rejection-loop timing is not the only leak source; arithmetic and memory access patterns also matter.\n- Deterministic mode has reproducibility benefits but different timing-privacy tradeoffs.\n- Different ML-DSA parameter sets shift acceptance distributions; the histogram preset selector illustrates this.\n\n## Real-World Usage\n\nFiat-Shamir with Aborts was introduced by Vadim Lyubashevsky (ASIACRYPT 2009) and is the core idea behind practical lattice signatures like CRYSTALS-Dilithium and standardized ML-DSA.\n\nNIST selected Dilithium in 2022, then published FIPS 204 in 2024. The standardized ML-DSA design keeps rejection as a deliberate mechanism to preserve signature security, while implementations must manage the operational and side-channel consequences of variable-time signing loops.\n\n## License\n\nMIT — see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystemslibrarian%2Fcrypto-lab-dilithium-reject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsystemslibrarian%2Fcrypto-lab-dilithium-reject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsystemslibrarian%2Fcrypto-lab-dilithium-reject/lists"}