chalk

package module
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 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 logo

chalk

A self-hosted, end-to-end-encrypted group chat: one Go binary, Postgres, and a browser client. Matrix-green-on-black by default (thirteen themes, four bundled monospace fonts), Slack-style threading, Discord-style voice/video rooms.

Accounts are password + TOTP; passkeys are an optional convenience on top, never a bypass of the second factor.

Crypto status. chalk is end-to-end encrypted. Messages, edits, reactions 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. See docs/threat-model.md for the guarantees and the metadata the server still sees.

What's in it

  • Messaging — channels, DMs and threads; replies; @mentions; per-user unread tracking with a new-messages divider, synced across your devices.
  • Message actions — react with emoji, edit your own message within 15 minutes (marked (edited)), and delete under per-channel rules: your own words are always yours to retract, someone else's are the channel owner's call in dictator mode or a vote in democratic mode.
  • Attachments & GIFs — encrypted uploads with encrypted previews, drag-drop / clipboard paste, and Giphy behind a per-user opt-in.
  • Voice & video — voice channels with a WebRTC mesh, coturn as the mandatory relay, screen/game sharing and adaptive quality. Off by default (CHALK_VOICE_ENABLED).
  • Governance — each channel is dictator or democratic; membership changes, deletions and mode changes can run as proposals the members vote on.
  • Accounts — password + mandatory TOTP, optional passkeys, two separate 24-word phrases (one resets your login, one is your encryption identity), and multi-device onboarding by re-entering the encryption phrase.
  • Client — desktop and mobile layouts, installable as a PWA, thirteen themes, per-device font and text-size settings (Hack, JetBrains Mono, Fira Code and Cascadia Code all bundled), per-user nick colours.
  • Ops — chalkctl deploys and updates a whole host from cosign-verified container images.

Screenshots

The default theme (six more in settings), on a dev instance:

The same channel with the thread panel open on the right, showing two replies and their own composer

Quick start (development)

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

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/ and sign up: pick a handle, set a password (at least 20 characters across 4 character classes), scan the TOTP QR code, and write down both 24-word phrases. 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.

To take the reserved admin account, set CHALK_ADMIN_USERNAME, CHALK_ADMIN_EMAIL and CHALK_ADMIN_BOOTSTRAP_TOKEN before starting, then open /?admin_token=<token> and complete signup. The claim is one-shot: once the admin account has credentials, the URL does nothing.

Deploying it

chalkctl is the deployment manager — one binary that installs and runs a whole chalk host:

chalkctl init      # verify + pin the image, render config, bring everything up
chalkctl status    # deployed version, digest, service states
chalkctl update    # verify, swap, health-check, roll back on failure

It renders podman Quadlet units for chalkd, Postgres and coturn, sets up Caddy for TLS, verifies GHCR pulls with cosign, and installs a weekly update timer. See docs/deployment.md.

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.

Accounts and cryptography in a nutshell

In one breath: you log in with a password and a 6-digit TOTP code, you hold a separate 24-word phrase that is the seed of your cryptographic identity, and that identity locks your messages so only the people in a channel 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
Password + Argon2id Your password never leaves the browser. It is stretched with Argon2id (256 MiB, 3 passes) into a master key; the server only ever sees a derived proof value, and stores only a hash of that. live
TOTP (RFC 6238) A 6-digit code from your authenticator, required on every login — including the passkey path. Mandatory, not optional. live
Passkeys (WebAuthn) Optional convenience: unlock with your device's fingerprint/PIN instead of typing the password. Still asks for the TOTP code, so a stolen device is not an account. live
Recovery phrase (24 words) Your way back into the account if you forget the password. It resets your login rather than logging you in, and the server stores only a slow Argon2id hash of it. live
Encryption phrase (24 words, BIP-39) A second, separate phrase: 256 bits of randomness with a checksum, and the root of your cryptographic identity. Never leaves your browser; it is what lets a new device read your history. live
PBKDF2-HMAC-SHA512 Stretches those 24 words into a 64-byte seed (the standard BIP-39 step). live
HKDF-SHA256 Splits one seed into independent keys, so the signing key and the encryption key never overlap. 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 channel'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 channel has one shared symmetric key that actually encrypts the messages, edits, reactions and attachments. It's handed to each member by wrapping it under their X25519 public key, and rotated when someone is removed. 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 encryption 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
Signed voice fingerprints In a call, each peer's DTLS fingerprint is signed with their Ed25519 key and checked against their published identity. A mismatch aborts that peer instead of degrading to an unverified call. live
TLS 1.3 Encrypts the connection between your browser and the server, like every HTTPS site. live

A few deliberate choices worth knowing: every primitive above is native WebCrypto — chalk bundles no cryptography library and ships no WASM. The encryption phrase is the one and only decryption secret, 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

Release-by-release notes in plain language are in CHANGELOG.md; the phase-by-phase engineering history is in docs/phase-log.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).
linkpreview
Package linkpreview is chalkd's server-side page fetcher for sender-built link previews (phase 57, docs/PHASE-57-LINKPREVIEW.md).
Package linkpreview is chalkd's server-side page fetcher for sender-built link previews (phase 57, docs/PHASE-57-LINKPREVIEW.md).
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