M.F. Miller Supply Co.
Back to Open Works
libraryMIT OR Apache-2.0 LicensePublished

homeberry-sync

End-to-end encrypted, local-first CRDT collaboration engine and zero-knowledge relay in Rust — powering live household collaboration and offline sync in Homeberry.

Architecture

homeberry-sync lets peers edit rich block documents offline inside a local yrs (Yjs) CRDT and converge seamlessly over a zero-knowledge relay that never sees plaintext documents, cursors, or encryption keys. It is extracted directly from and used in production inside Homeberry.

  • Zero-knowledge by construction: Channel IDs are derived as SHA-256(capability_secret). Mailbox authorization tokens and ChaCha20-Poly1305 content keys are domain-separated via HKDF-SHA256 so the relay can authenticate writes without ever being able to decrypt a single byte.
  • Memory-safe key hygiene: RootKey and ChannelKeys automatically wipe key material from memory on drop via zeroize.
  • True offline-first CRDTs: Built on yrs (Yjs v1 binary format) with ordered UUID blocks, character-level concurrent text merging, state-vector diffs, and bounded payload limits.
  • Live encrypted presence: Ephemeral 15-second TTL presence rooms carry encrypted cursors, typing indicators, and block drag states without persisting presence history.
  • Embeddable or standalone: Mount homeberry_sync_relay::router(state) inside any Axum server (as Homeberry Hub does in production), or run homeberry-sync-relay as a single self-hosted binary alongside homeberry-relay.

Workspace Crates

  • homeberry-sync-core: RootKey, HKDF-SHA256 capability derivation, HBSYNC01 ChaCha20-Poly1305 envelopes, and wire DTOs.
  • homeberry-sync-crdt: Generic block-oriented CRDT document engine built on yrs.
  • homeberry-sync-relay: Embeddable Axum zero-knowledge relay, SQLite mailbox store, PresenceHub, and standalone CLI server.
  • homeberry-sync-client: Async Rust client for encrypted mailbox sync, long-poll wakeups, and live encrypted presence.

Quickstart

Run the bundled two-peer encrypted collaboration example (spins up an in-process zero-knowledge relay, pairs two peers with a shared 256-bit RootKey, performs concurrent offline edits, syncs HBSYNC01 envelopes, exchanges encrypted cursor presence, and verifies convergence):

cargo run -p homeberry-sync-client --example two_peer_collab

Or run the standalone self-hosted relay server:

cargo run --release -p homeberry-sync-relay -- --bind 0.0.0.0:8787 --db ./relay.sqlite

For an interactive browser-side introduction to local-first causal clocks and conflict handling, explore the illustrative Local-First Sync & Conflict Simulator in the Interactive Lab.