Teaching site for cryptography — 34 algorithm lessons from RSA to Argon2id, grouped into guided journeys. Live at https://cloak.moosha.org. Catalog and open ideas: docs/roadmap.md.
python3.12 -m venv .venv
.venv/bin/pip install -r requirements.txt
cp .env.example .env
# edit .env if needed
.venv/bin/python manage.py migrate
.venv/bin/python manage.py loaddata algorithms/rsa/fixtures.json
.venv/bin/python manage.py runserver
Visit http://localhost:8000/.
.venv/bin/pytest # Python tests
node --test static/algorithms/*/tests/*.test.js # JS tests
JS-Python parity is enforced in tests/test_parity.py.
The artifact is docker-compose.yml + the web image (built from Dockerfile).
-
On the server, clone the repo and write
.env(setDJANGO_DEBUG=False, realDJANGO_SECRET_KEY, real Postgres credentials). -
make up→ web container binds127.0.0.1:8000; Postgres lives in a sibling container. -
Add a stanza to the host's Caddyfile:
cloak.moosha.org { reverse_proxy 127.0.0.1:8000 } -
Reload Caddy.
The web container handles migrate, loaddata algorithms/*/fixtures.json, collectstatic, then runs gunicorn — see entrypoint.sh.
The framework is data-driven. To add foo:
- Create
algorithms/foo/fixtures.json(Algorithm + Lesson + Step rows; PK convention: algorithm/lesson PK = catalog order, step PK = lesson PK × 10 + step order). - Create
static/algorithms/foo/{validators.js, codegen.js}plus tests instatic/algorithms/foo/tests/— the validator keys named in the fixture must be exported byvalidators.js, andcodegen.jsmust exportfull_script(state). (The original RSA lesson also has Python mirrors inalgorithms/rsa/; newer lessons are JS-only.) - Interactive steps with custom UI additionally need: a template branch in
core/templates/core/lesson.htmland slug registrations instatic/core/wizard.js(hasCustomInputBranchSLUGS,MULTI_INPUT_SLUGSif the validator takes an object,EXPLORATORY_SLUGSif the branch renders its own Continue button). make loadalgos(or rebuild the image — the entrypoint reloads all fixtures on every container start).
Plain info-step lessons need no core code changes.