Building Privacy-First Sync: Lessons from Password Managers
Date: January 28, 2025 Author: Idiomark Team Read time: 12 min Tags: engineering, security, architecture, sync
The Challenge
We're building a sync system for Idiomark files — portable personality profiles that contain:
- Communication style and voice
- Gaming identities across platforms
- Social media connections
- Professional credentials
- Personal values and preferences
This is sensitive data. More sensitive than passwords, in some ways. Your password can be changed. Your personality is who you are.
We need a sync architecture that:
- Encrypts everything before it leaves your device
- Never exposes private keys to our servers
- Handles conflicts gracefully when multiple devices update simultaneously
- Scales to millions of users without centralized bottlenecks
- Works offline as much as possible
Fortunately, we're not the first to face this challenge. Password managers have solved it. Here's what we learned.
Core Principles from 1Password and Bitwarden
1. Client-Side Encryption, Always
Rule: Data is encrypted before it leaves your device. Our servers never see plaintext.
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Device A │ │ Our Cloud │ │ Device B │
│ │ │ │ │ │
│ Plaintext │─────▶│ Encrypted │─────▶│ Plaintext │
│ Idiomark file │ │ blobs only │ │ Idiomark file │
│ │ │ │ │ │
└─────────────┘ └─────────────┘ └─────────────┘
Encrypts Decrypts
locally locally
Implementation:
- Encryption key derived from user's master password (Argon2)
- Data encrypted with ChaCha20-Poly1305 (fast, secure)
- Only encrypted blobs sent to cloud
- Server cannot decrypt even if it wants to
2. Zero-Knowledge Architecture
Rule: Our servers verify that you are who you say, not what your data is.
Your Idiomark file might contain:
- Steam ID:
76561198012345678 - Twitter:
@yourhandle - Personality: formal=0.7, warm=0.8
Our servers see:
base64(AES-256-GCM(encrypted_blob, nonce), auth_tag)
We can't search it. We can't read it. We can't profile you. We just store it.
3. Local-First, Cloud-Backup
Rule: Your device is the source of truth. Cloud is just backup and sync.
Benefits:
- Works offline (mostly)
- Faster — no network latency for reads
- Privacy — sensitive data stays local
- Resilience — you have your data even if we go down
Trade-offs:
- Storage limits on mobile devices
- Initial sync takes longer
- Conflict resolution more complex
We accept these trade-offs for privacy.
Sync Architecture
The Data Model
Each Idiomark file has:
- Immutable content hash — SHA-256 of the file contents
- Monotonic version — incrementing integer
- Device identifier — which device made this change
- Timestamp — when the change was made
{
"meta": {
"version": 47,
"content_hash": "sha256:a1b2c3d4...",
"device_id": "desktop-macos-abc123",
"timestamp": "2025-01-28T10:30:00Z",
"prev_version": 46
},
"data": { /* encrypted Idiomark contents */ }
}
Sync Flow
┌─────────────────────────────────────────────────────────────────┐
│ SYNC ARCHITECTURE │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 1. Device A creates change (version 47) │
│ │ │
│ ▼ │
│ 2. Encrypt + upload to cloud │
│ │ │
│ ▼ │
│ 3. Cloud stores blob, updates "latest version" pointer │
│ │ │
│ ▼ │
│ 4. Device B polls (or receives WebSocket push) │
│ │ │
│ ▼ │
│ 5. Device B downloads version 47 │
│ │ │
│ ▼ │
│ 6. If local version < 47, merge or replace │
│ │
└─────────────────────────────────────────────────────────────────┘
Conflict Resolution
Scenario: Device A and Device B both make changes while offline. Both upload version 47.
Approaches:
| Approach | How It Works | When To Use |
|---|---|---|
| Last-Write-Wins | Most recent timestamp wins | Simple data, low conflict rate |
| CRDT Merge | Conflict-free replicated data types | Complex data, frequent conflicts |
| Application-Level Merge | Smart merge based on semantics | Structured data with clear merge rules |
For Idiomark: We use application-level merge because:
- Identity claims add, don't conflict (adding Steam ID doesn't conflict with adding Xbox ID)
- Personality updates are cumulative (most recent data wins)
- Version history is preserved (you can always rollback)
Conflict Example:
Device A: updates voice.warmth from 0.7 to 0.8
Device B: updates voice.formality from 0.6 to 0.7
Result: merge both changes
voice.warmth = 0.8 (from A)
voice.formality = 0.7 (from B)
Conflict Example 2:
Device A: updates voice.warmth from 0.7 to 0.8
Device B: updates voice.warmth from 0.7 to 0.75
Result: most recent wins (0.8, assuming A's timestamp is later)
Performance Optimizations
1. Differential Sync
Problem: Idiomark files can be large (100KB+ with identity claims, history, etc.)
Solution: Only send what changed.
{
"patch": {
"personality.voice.warmth": 0.8,
"identity_claims.steam.achievements": "+3"
},
"base_version": 46
}
2. Compression
Problem: JSON is verbose.
Solution: Compress before encrypt.
Original: 128 KB
Gzip: 32 KB (75% reduction)
Encrypt: 32 KB (compressed)
Upload: 32 KB
3. Background Sync
Problem: Sync shouldn't block the UI.
Solution: Web Workers in browser, background threads in native apps.
┌─────────────────┐ ┌─────────────────┐
│ Main Thread │ │ Worker Thread │
│ │ │ │
│ UI operations │ │ Encryption │
│ │ │ Network I/O │
│ │ │ Decryption │
└─────────────────┘ └─────────────────┘
▲ │
└──────────notify─────────┘
Security Considerations
Key Derivation
Master Password (user-provided)
│
▼
Argon2id (memory-hard KDF)
│
▼
Encryption Key (256-bit)
│
▼
Encrypt/Decrypt Idiomark file
Why Argon2id?
- Memory-hard (resists GPU attacks)
- Configurable time/memory cost
- Industry standard for password-based key derivation
Key Storage
Never store the encryption key. Store a verifier instead.
During registration:
1. Derive encryption key from master password
2. Generate random salt
3. Compute verifier = Argon2id(master_password, salt)
4. Store salt + verifier on server
During login:
1. Retrieve salt + verifier from server
2. Compute challenge = Argon2id(master_password, salt)
3. Send challenge to server
4. Server compares challenge == verifier
5. If match, derive encryption key locally
6. Server never sees encryption key
Replay Prevention
Each sync request includes:
- Timestamp (must be within ±5 minutes)
- Nonce (random, never reused)
- Device signature (Ed25519)
Server rejects replayed requests.
Implementation Status
✅ Currently Working (Phase 1)
- Basic CLI with extract/generate
- Local Idiomark file storage
- Manual file transfer between devices
🚧 In Development (Phase 2 - Q2 2025)
- Encrypted cloud storage API
- WebSocket-based real-time sync
- Browser extension with sync
- Mobile SDKs (iOS/Android)
📋 Planned (Phase 3 - Q3 2025)
- Conflict resolution UI
- Version history with diff viewer
- Selective disclosure sync (sync gaming identity without social)
- Recovery mechanism (social recovery, hardware keys)
For Developers
Integrating Idiomark Sync
import { IdiomarkSyncClient } from '@idiomark/sync'
const client = new IdiomarkSyncClient({
apiKey: process.env.IDIOMARK_API_KEY,
encryptionKey: await deriveKey(masterPassword)
})
// Listen for updates
client.on('update', (idiomarkFile) => {
console.log('Personality updated:', idiomarkFile.personality)
})
// Push local changes
await client.push(idiomarkFile)
// Pull latest changes
const latest = await client.pull()
// Handle conflicts
const resolved = await client.resolveConflict(local, remote, {
strategy: 'merge' // or 'local-wins', 'remote-wins', 'custom'
})
Running Your Own Sync Server
The sync protocol is open source. Self-host if you want:
git clone https://github.com/your-org/idiomark
cd packages/sync
docker-compose up
Learn More
- Spec: Idiomark Sync Protocol
- Security: Security Whitepaper
- GitHub: Source Code
Next: The Market Opportunity for Universal Identity