Add Grain: hide an AES-256-GCM-encrypted file inside a PNG - #36
Merged
Conversation
Client-side only — PBKDF2 key derivation, AES-256-GCM encryption behind a passphrase, then least-significant-bit steganography to write the ciphertext into a carrier PNG's pixels. Nothing is ever uploaded; grain.html sets connect-src 'none'. Sixth argued exception to the JS-file rule, alongside js/ask.js, js/game.js, js/mocap.js, js/mocap-retarget.js and js/iris.js (AGENTS.md). scripts/check_grain.py pins the header format, KDF and ciphertext against committed fixtures generated with Node's webcrypto and a from-scratch stdlib PNG encoder, since stdlib Python has no AES-GCM to verify the encryption itself against.
All Human-evidence acceptance criteria have now been run against a real browser: encode/decode round trip, wrong passphrase, tampered image, undersized carrier, out-of-range KDF header, connect-src 'none' holding even against the page's own blob URLs, keyboard traversal, and a Lighthouse audit in both colour schemes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
grain.htmlsetsconnect-src 'none'.grain.html,css/grain.css,js/grain.js,scripts/check_grain.py(+ fixtures),.claude/rules/grain.md,specs/F07_GRAIN.md.sitemap.xml,AGENTS.md(sixth JS-file exception + new verification step),specs/PRD.md(architecture diagram, F07 section, verification table),index.html(colophon link),.github/workflows/ci.yml(new CI step).check_htmx.py,check_corpus.py,check_palette.py,check_repo.py,check_grain.py,gen_game_data.py --check,build_game.sh --check.Decisions that differ from the brief
ctLenis computed asplaintext.length + 16before encrypting (singlecrypto.subtle.encrypt()call), rather than encrypting twice to measure ciphertext length — AES-GCM ciphertext length depends only on plaintext length, not onadditionalData.grain--payload-nameandgrain--stego-namestatus paragraphs: the visually-hidden file inputs clip the native "chosen file" text, so these are the only place a file selection is confirmed to screen readers and sighted users alike.filename.txtfixture alongside the other committed fixtures..grain--pageuses ordinary block layout, not thedisplay: contentshide/show pattern#iris--pageuses — both encode and decode sections are always visible here, so there's nothing to toggle.index.htmllinking to Grain. Investigated whether the existing "First-party JavaScript / One module,js/ask.js" colophon readout was stale now that Grain adds a sixth site-wide JS file — it isn't: that readout is scoped toindex.html's own script usage specifically, which is unchanged.specs/PRD.md's "Out of scope" section (it already omittedjs/iris.jsbefore this PR) while updating the JS file count for Grain.What's NOT done yet
connect-src 'none'holds), keyboard/focus traversal, both colour schemes, all three breakpoints, Lighthouse.specs/F07_GRAIN.md(F07-AC01, AC02, AC03's live half, AC04, AC05, AC06's live half, AC07, AC09) are still open.specs/F07_GRAIN.md: measured stego-PNG size and PBKDF2 timing on real hardware.Test plan
scripts/check_grain.pypasses (regression pin against committed fixtures — not a proof; stdlib Python has no AES-GCM to verify the real encryption against)check_htmx.py,check_corpus.py,check_palette.py,check_repo.py,gen_game_data.py --check,build_game.sh --checkall pass