ENCRYPTED SYNC · GESH

The relay moves your vault.
It never gets to read it.

Skald encrypts notes and attachments on your device, sends only opaque events through GESH, and resolves application conflicts itself. GESH is a relay, not Skald's backend.

Skald sees plaintextencrypts · validates · merges
GESH sees ciphertextauthenticates · stores · relays
Your devices hold the keynever uploaded to the relay
01 · THE BOUNDARY

Two systems with deliberately different jobs.

GESH authenticates roots and devices, stores immutable encrypted event blobs, exposes an incremental feed, and deletes events after every active device has collected them. Skald owns encryption, key management, serialization, path validation, conflict resolution and local durability.

Skald deviceserialize → AES-256-GCM
GESHopaque immutable events
Other Skald devicedecrypt → validate → apply
Zero knowledge here means something concrete: the server must never require plaintext application data. A compromised relay can expose ciphertext and metadata, but it does not possess Skald's content key.
02 · PAIRING

One QR code carries two halves of trust.

The relay supplies a short-lived, single-use enrollment code. Skald appends the vault content key to the URI fragment locally. URI fragments are not sent in HTTP requests, so the QR code can contain both halves while GESH only receives one.

FIRST DEVICE
Pair another device

The pairing URI

?s=https://gesh…&c=79T54-26AJX

Relay URL + enrollment code. GESH knows this half.

#k=<base64url content key>

Appended locally by Skald. GESH never receives this fragment.

Not in the vault:
device token, root authority token and content key are kept in OS-protected secret storage, not beside Markdown that may be copied or committed.
SECOND DEVICE
Scan & redeem

Gets its own device credential and imports the content key.

Root token

The authority credential. It enrolls and revokes devices. Daily syncing does not need it.

Device token

A per-device sync credential. Revoking one device does not force every other device to re-pair.

03 · EVERY SYNC PASS

Pull first. Acknowledge only after disk.

The ordering is intentionally strict because acknowledgements are destructive. Once every active peer has acknowledged an event, GESH may erase it.

01Pull

Page from the persisted opaque cursor, skip this device's own events, download ciphertext.

02Apply

Decrypt, fully revalidate, merge operations, then write notes or staged attachments to disk.

03Acknowledge

Only after the changes are durably committed. Never ack merely because a blob downloaded.

04Push

Diff the current vault against agreed state, encrypt new events, record only what successfully shipped.

04 · WHAT ACTUALLY TRAVELS

Events are encrypted frames, not remote database rows.

A fresh 96-bit nonce seals each event. Notes travel as operations in the JSON header. Binary attachments travel as raw body bytes so files do not pay base64's roughly one-third size penalty.

Encrypted frame before sealing
JSON HEADER
RAW BODY BYTES

delta / snapshot: header only
blob: one binary attachment in the body

{
  "v": 1,
  "kind": "delta",
  "device": "desktop_…",
  "ops": [
    {
      "op": "put",
      "path": "Projects/Skald.md",
      "rev": 4,
      "hash": "…",
      "content": "…"
    }
  ]
}

Paths are hostile input after decrypt

Every path is validated again before it becomes a filename. Anything escaping the vault, hiding in .skald/, or using reserved platform names is refused.

Attachments are atomic

Incoming files are staged under .skald/ and published by rename so readers never see a half-written attachment.

05 · CONFLICTS

Converge automatically. Keep the loser.

Merge decisions use each path's logical revision first, then device id as the deterministic tiebreak. Wall-clock time is not trusted for ordering.

DEVICE AProject.md · rev 7

Different local content

DEVICE BProject.md · rev 8

Wins deterministically

Before overwrite, Skald captures the losing note into local history.
So conflict resolution can be automatic without pretending the losing human edit never existed. Deletion also carries a logical clock, preventing stale events from resurrecting deleted notes.
06 · RETENTION

The feed is not an eternal backup.

GESH deliberately garbage-collects. An old device can miss events after it has been offline beyond retention, so Skald uses full-vault snapshot events when provisioning and before handing out a pairing code.

Event TTL
7 days
Uncollected events expire by default.
Device TTL
30 days
Silent devices stop holding events alive.
Tombstone TTL
30 days
Erased event ids remain reserved temporarily.
Republish everything sends a fresh snapshot. This is how a newly paired or long-offline device gets a current baseline instead of depending on a feed that intentionally forgets old history.
07 · DEVICE CONTROL

A lost device can lose access without resetting the household.

Each paired device has its own credential. The root authority can list and revoke a single device; every other device credential remains valid. A revoked credential receives authorization failure and Skald stops automatic retries instead of hammering the relay forever.

Desktopdevice token A
Phonerevoked token B
Tabletdevice token C
08 · FAILURE BEHAVIOR

Failures should degrade, not silently corrupt.

The sync engine treats several network and data failures differently because pretending every error is retryable is how distributed systems become haunted.

401

Stop automatic syncing. A revoked or invalid credential will not heal itself on a timer.

429

Honor Retry-After. Do not spin or mint fresh pairing codes to evade lockout.

Bad encrypted event

Warn and skip rather than wedge the entire feed forever.

Oversize attachment

Name it in sync status and continue syncing everything else. Current Skald does not chunk files across events.

09 · FOR DEVELOPERS

The portable half is intentionally boring.

Skald keeps protocol, cryptography, pairing, payload validation and merge logic under src-shared/ using web-platform primitives. Desktop-specific code mainly supplies storage and OS secret handling, making the same sync model reusable by mobile.

Skald encrypted sync · visual guide · Back to complete guide