Offline-first keys for mesh-native sync

Daochi

Device-created account keys, post-quantum proof of account authority, encrypted records, and remote events for native and web apps. Server-assisted today, built toward a mesh-native network.

Offline-first keys

Clients create the durable ML-DSA-44 account key locally. The relay sees the public key, account hash, and signatures, not the private key.

Post-quantum account authority

The durable account key is ML-DSA-44. Clients prove control with short-lived challenges before receiving operational bearer tokens.

App-owned records

Applications keep ownership of their data while the relay stores versions, opaque encrypted payloads, and shared projections.

Remote events

WebSocket events wake clients when fresh sync data is available without exposing bearer tokens through URLs.

Trusted mesh

Signed pairing, local discovery, scoped replication, and trust-space names keep approved app data available through home and neighbor nodes.

Key creation starts offline. A device can create its account key before the first network request; first login registers the public key, and later logins prove control with fresh signatures.

Private records stay client encrypted. Daochi validates metadata and versions ciphertext, but plaintext and record encryption choices remain with clients and apps.

The post-quantum proof is account authority. Daochi uses ML-DSA-44 signatures for identity and account authorization; app manifest keys and token issuer keys are separate Ed25519 authorities.

Implementation guides

Encrypted record profile

Recommended private-record envelope, nonce rules, AAD, key rotation, and test-vector shape.

Developer quickstart

Shortest path from account key to login, signed app manifest, encrypted sync, and diagnostics.

Small node operations

Low-resource deployment targets, trust inspection checklist, and rollout checks for home or modest nodes.

API surface

Protocol v5 makes encrypted records the primary private-data surface while legacy typed rows remain available for compatibility. Protocol v1 through v5 remain valid through 2027-09-01.

GET/api/v1/apps

Lists registered apps, collection prefixes, visibility classes, and capabilities.

POST/api/v1/apps

Registers or updates an app when the admin token is set and X-Daochi-Admin matches it. X-Ksync-Admin remains accepted for compatibility.

GET/api/v1/sync/challenge?user_id=<sha256-public-key-hex>

Issues a single-use 32-byte challenge nonce encoded as lowercase hex.

POST/api/v1/sync/login

Verifies the challenge signature and returns a cacheable bearer token plus server clock time.

GET/api/v1/sync/ws

Upgrades to a WebSocket event stream authenticated with Authorization: Bearer <token>, or browser subprotocols daochi-sync-v1, bearer.<token>.

POST/api/v1/sync

Applies typed local changes or stores an encrypted envelope, then returns remote changes newer than the requested server version.

GET/api/v1/sync/diagnostics

Returns bearer-authenticated sync state, table counts, compaction position, legacy client hints, and recent sync audit metadata.

POST/api/v1/node/pairing/invites

Creates a short-lived signed pairing payload with explicit replication scope.

POST/api/v1/node/pairing/accept

Verifies and consumes a pairing invite, then pins the peer identity and approved scope.

POST/api/v1/node/pairing/complete

Authenticates the accepting node back to the inviter and completes reciprocal trust.

GET/api/v1/node/peers

Lists paired nodes and their approved addresses and replication policies.

POST/api/v1/namespaces

Creates a local trust-space authority for signed mesh-native names.

POST/api/v1/namespaces/claims

Signs or updates a name claim in a locally controlled trust space.

GET/api/v1/namespaces/resolve

Resolves a trust-space name to signed service endpoints.

POST/api/v1/node/mesh/export

Exports policy-filtered signed app manifests, encrypted records, deletion tombstones, and names to an authenticated peer node.

POST/api/v1/node/mesh/import

Verifies and imports policy-filtered app manifests, encrypted records, deletion tombstones, and names from an authenticated peer node.

GET/api/v1/tokens/issuer

Returns the configured token issuer key.

GET/api/v1/tokens/products

Lists configured token products and direct payment prices when direct purchases are enabled.

GET/api/v1/tokens/balance

Returns the bearer-authenticated account's token balance computed from signed ledger events.

GET/api/v1/tokens/activity

Returns the account's Dew balance and full newest-first activity history across every app for the profile's Dew screen.

POST/api/v1/tokens/spend

Debits tokens with app policy and idempotency enforcement.

POST/api/v1/tokens/gifts

Sends Dew to a friend; the debit and the friend's credit commit together.

GET/api/v1/rewards

Lists the game rewards the node gives and their Dew.

POST/api/v1/rewards

Claims a game reward for the account; each reward credits an account once.

POST/api/v1/tokens/purchases/monero/invoices

Creates a bearer-authenticated invoice for a configured token product.

GET/api/v1/tokens/purchases/monero/invoices/{id}

Returns invoice status and settles a confirmed payment against the authenticated account.

GET/api/v1/tokens/purchases/monero/address

Returns the authenticated account's permanent Monero purchase address.

GET/api/v1/tokens/purchases/monero/address/{recipient}

Resolves an alias or public ID and returns the recipient's permanent Monero gift address.

GET/api/v1/tokens/purchases/monero/deposits

Returns the authenticated account's detected and credited Monero deposits.

GET/POST/api/v1/account/app-grants

Lists or creates bearer-authenticated grants for sharing registered app collection prefixes across apps.

GET/api/v1/account/app-records

Returns encrypted records from a granted collection prefix for cross-app use.

GET/POST/api/v1/friends

Bearer-authenticated friend requests, accepted friends, and app-neutral shared profile stats.

GET/POST/api/v1/publications

Publishes level collections and finds the newest public ones or the ones an author lets the caller see.

GET/DELETE/api/v1/publications/{id}

Fetches a visible publication with its document, or lets its author unpublish it.

POST/api/v1/account/delete

Deletes all remote data for the signed sync account without uploading the private key. It is kept on hold for 30 days, restorable with the same key, then deleted permanently.

DELETE/api/v1/account

Legacy signed deletion endpoint kept for older clients.

POST/api/v1/account/delete-with-key

Deletes all remote data for the sync account after verifying exported account key text, with the same 30-day hold.

Signed Message

daochi-sync-v1
<HTTP_METHOD>
<HTTP_PATH>
<sha256 hex of exact raw request body bytes>
<challenge nonce hex>

Signed requests use X-Daochi-User, X-Daochi-Signature, and Content-Type: application/json. The older Ksync and Inbe signature headers remain accepted for shipped clients.