chalk

package module
v0.3.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: BSD-3-Clause Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

chalk

A self-hosted group chat: single Go binary, Postgres, browser client. Matrix-green-on-black, themeable, Hack font, Slack-style threading. Passkey-only auth (no passwords).

Crypto status. chalk is end-to-end encrypted. Messages and attachments are encrypted client-side under per-channel space keys (identity-wrapped, native WebCrypto, AES-256-GCM); the server is a blind relay that stores only ciphertext. The encryption stack was rebuilt across phases 22–25 after the earlier MLS implementation was removed in the 21-series rework. See docs/threat-model.md for the guarantees and the metadata the server still sees.

Quick start

Requirements: Go 1.25+, Docker 24+, Bash 5.2+, make, git, Node 18+.

git clone https://github.com/scuq/chalk
cd chalk
make dev          # Postgres + chalkd + SPA, foreground on :8443

Then open http://127.0.0.1:8443/. On first run the server prints an admin bootstrap URL (valid 24h) — open it to register the admin user's passkey. Additional users self-register through the signup flow in the SPA. To test a two-user flow, register a second account in another browser profile (or a private window) and add them as a friend from the first.

Stop with Ctrl-C; make dev-down removes the Postgres container.

Architecture

See docs/architecture.md. In short: a stateless multi-instance Go server using Postgres as both storage and pub/sub bus (LISTEN/NOTIFY), with a Preact browser client over a JSON WebSocket protocol (docs/wire-protocol.md). Each instance holds only in-memory socket state; Postgres is the source of truth.

Cryptography in a nutshell

In one breath: you log in with a passkey (no password), you get a 24-word phrase that is the seed of your cryptographic identity, and that identity locks your messages so only the people in a space can read them. All of it is live — messages and attachments are end-to-end encrypted, and the server stores only ciphertext. Here is every piece in plain language.

Piece What it does, plainly Status
Passkeys (WebAuthn) Log in with your device's fingerprint/PIN instead of a password. Your device keeps the secret key; the server only ever sees a public key. Can't be phished. live
Argon2id The 24-word recovery phrase is never stored — only a slow, salted hash of it is, so a stolen database can't reveal it. live
TLS 1.3 Encrypts the connection between your browser and the server, like every HTTPS site. live
24-word phrase (BIP-39) 256 bits of randomness written as 24 ordinary words, with a built-in checksum so a typo is caught. This is the root of your identity and your way back in on a new device. live
PBKDF2-HMAC-SHA512 Stretches those 24 words into a 64-byte seed (the standard BIP-39 step). live
HKDF-SHA256 Splits that one seed into two separate keys so the signing key and the encryption key are independent. live
X25519 Your encryption keypair. Two people's X25519 keys can agree on a shared secret without ever sending it — that secret wraps the keys that lock a space's messages. live
Ed25519 Your signing keypair. Proves "this identity really is mine," and signs the X25519 key so the server can't quietly swap it (the self-signature). live
Self-signature Your Ed25519 key signs your X25519 key. When someone fetches your identity, they check this signature, so a malicious server can't substitute a fake encryption key undetected. live
Space keys + AES-256-GCM Each space (group) has one shared symmetric key that actually encrypts the messages. It's handed to each member by wrapping it under their X25519 public key. live
Picture-word verification An out-of-band check (you compare the same picture/words with someone) to be sure no one is sitting in the middle swapping keys. live
Phrase rotation + recovery You can roll your phrase to a fresh one; old keys are re-wrapped so you keep your history, with an opt-out for when you're rotating because the old phrase leaked. live

A few deliberate choices worth knowing: every primitive above is native WebCrypto — chalk bundles no cryptography library and ships no WASM. The 24-word phrase is the one and only decryption secret (no extra passphrase), so guard it like a wallet seed: lose it and lose those messages, leak it and leak them. And two things are explicit non-goals, not oversights: forward secrecy (old messages staying safe if a key later leaks) and post-quantum resistance. The full reasoning, threat model, and recovery design live in docs/threat-model.md and docs/design/.

Documentation

The phase-by-phase build history and the current roadmap live in docs/phase-log.md; per-release notes are in CHANGELOG.md. (This README intentionally doesn't track phase status — see those instead.)

License

BSD-3-Clause — see LICENSE.

chalk's licensing has changed over its life: MIT through the 9.x series, then GPL-3.0-or-later in phase 11a to align with the (now-removed) @wireapp/core-crypto dependency, and — with that dependency gone after the 21-series rip-out — back to the permissive BSD-3-Clause. Relicensing was done by the sole copyright holder; commits remain available under whichever license was in effect when they were made.

Documentation

Overview

Package chalk embeds static assets (migrations, web SPA bundle) into the binary.

Index

Constants

View Source
const MigrationsDir = "migrations"

MigrationsDir is the directory name inside the embedded FS. migrate.Load needs both the embed.FS and the directory name.

View Source
const WebDir = "web"

WebDir is the directory name inside the embedded FS. The SPA handler uses this + "/dist" to fs.Sub into the bundle root.

Variables

View Source
var Migrations embed.FS

Migrations holds every .sql file in the migrations/ directory.

View Source
var Web embed.FS

Web holds the SPA's built bundle at web/dist/.

Why dist/ and not the whole web/ tree:

  • web/node_modules can be huge (10s of MB) and would bloat the binary
  • web/src/ is source, not deployable; not needed at runtime
  • the SPA handler navigates into dist/ anyway

Phase 07 introduces web/dist/. Earlier phases shipped a placeholder web/index.html at the web/ root; phase 07 supersedes it with the esbuild output. The Dockerfile's frontend stage produces web/dist/.

For "go build" without a prior `npm run build`, this embed pattern will fail with "pattern web/dist/*: no matching files found". `bootstrap/phase-07-frontend-shell.sh` runs the npm build before `go build` to satisfy this; CI and the Dockerfile follow the same pattern. Local dev: run `cd web && npm run build` once before `go build`.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
chalkctl command
Command chalkctl is the chalk deployment manager.
Command chalkctl is the chalk deployment manager.
chalkd command
Command chalkd is the chalk server daemon.
Command chalkd is the chalk server daemon.
internal
auth
chalk -- phase31-slice31-11 admin bootstrap token.
chalk -- phase31-slice31-11 admin bootstrap token.
chalkctl
Package chalkctl implements the chalk deployment manager's core: config, state, embedded deploy templates, image-signature verification, and the podman bring-up used by `chalkctl init`.
Package chalkctl implements the chalk deployment manager's core: config, state, embedded deploy templates, image-signature verification, and the podman bring-up used by `chalkctl init`.
config
Package config loads chalk's runtime configuration from env and flags.
Package config loads chalk's runtime configuration from env and flags.
friends
Package friends implements the friendship state machine on top of the friendships table.
Package friends implements the friendship state machine on top of the friendships table.
giphy
Package giphy is a minimal server-side client for Giphy's search API (att-4).
Package giphy is a minimal server-side client for Giphy's search API (att-4).
mail
Package mail abstracts outbound email sending for chalk.
Package mail abstracts outbound email sending for chalk.
migrate
Package migrate runs the embedded SQL migrations in order, idempotently.
Package migrate runs the embedded SQL migrations in order, idempotently.
presence
Package presence implements per-device presence with multi-device aggregation, instance heartbeats, dead-instance cleanup, and stale- state demotion.
Package presence implements per-device presence with multi-device aggregation, instance heartbeats, dead-instance cleanup, and stale- state demotion.
proto
Package proto defines chalk's WebSocket wire protocol.
Package proto defines chalk's WebSocket wire protocol.
pubsub
Package pubsub bridges between chalkd instances using Postgres LISTEN/NOTIFY.
Package pubsub bridges between chalkd instances using Postgres LISTEN/NOTIFY.
server
Package server implements chalk's HTTP and WebSocket layers.
Package server implements chalk's HTTP and WebSocket layers.
store
chalk -- phase31-slice31-1 auth_v2 data layer.
chalk -- phase31-slice31-1 auth_v2 data layer.
turncred
Package turncred mints time-limited TURN credentials for coturn's "use-auth-secret" (TURN REST API) scheme (Phase 30, slice 30-1; design §5).
Package turncred mints time-limited TURN credentials for coturn's "use-auth-secret" (TURN REST API) scheme (Phase 30, slice 30-1; design §5).
version
Package version exposes build-time identification.
Package version exposes build-time identification.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL