Skip to content

[EPIC] Client-Side File Encryption for Zero-Knowledge Architecture #143

@kevalyq

Description

@kevalyq

🎯 Vision

Implement end-to-end client-side file encryption for files shared via Share Target API before upload to backend, ensuring zero-knowledge architecture where the backend cannot decrypt file contents.


📋 Sub-Issues & Work Plan

Implementation Phases


🎯 Success Criteria

  • End-to-End Encryption: Files encrypted client-side before upload
  • Zero-Knowledge Backend: Server cannot decrypt file contents
  • Web Crypto API: Browser-native AES-GCM-256 encryption
  • Secure Key Management: HKDF-based key derivation from Secret's master key
  • Integrity Verification: SHA-256 checksums before/after encryption
  • Comprehensive Tests: ≥80% coverage, known test vectors validated
  • Security Audit: Final review pending (Phase 5)
  • Documentation: Final documentation pending (Phase 5)

📚 Technical Architecture

Encryption Flow

1. User shares file via Share Target API
   → File stored in IndexedDB (unencrypted, temporary)

2. User selects/creates Secret
   → Derive file encryption key from Secret's master key (HKDF)

3. Encrypt file client-side (Web Crypto API)
   → AES-GCM-256 with random IV (12 bytes)
   → Generate auth tag (16 bytes)
   → Calculate SHA-256 checksum

4. Upload encrypted blob + metadata to backend
   → Backend stores encrypted file as-is (no decryption)
   → Metadata (filename, size, type) encrypted separately

5. Download: Fetch encrypted blob
   → Decrypt client-side with Secret's key
   → Verify checksum
   → Display/download decrypted file

Key Features

Core Encryption:

  • AES-GCM-256 with 128-bit auth tag
  • Random IV per encryption operation (12 bytes)
  • HKDF-based key derivation (secure, deterministic)
  • Non-extractable CryptoKeys (never leave secure storage)

Integrity Protection:

  • SHA-256 checksums (before/after encryption)
  • GCM auth tag (automatic tampering detection)
  • Checksum verification enforced on download

Security:

  • Zero-knowledge architecture (backend blind to contents)
  • Keys never logged or exposed
  • Known test vectors validated (NIST)
  • Forward secrecy ready

🔗 Dependencies

Requires (All Complete):

Part of:

Blocks:

  • Full zero-knowledge architecture ✅ READY
  • Public beta release (awaiting Phase 5 security audit)

📊 Implementation Timeline

Phase 1: Crypto Utilities ✅ COMPLETE (19.11.2025)
Phase 2: ShareTarget Integration ✅ COMPLETE (19.11.2025)
Phase 3: Upload Integration ✅ COMPLETE (21.11.2025)
Phase 4: Download & Decryption ✅ COMPLETE (21.11.2025)
Phase 5: Security Audit & Documentation ⏳ IN PROGRESS

Total Estimated Effort: 2 weeks
Current Progress: 80% (Phase 1-4 complete, Phase 5 in progress - 21.11.2025)


🔒 Security Considerations

  • NEVER log or expose encryption keys - VERIFIED
  • ✅ Use secure key derivation (HKDF, not simple hash) - IMPLEMENTED
  • ✅ Verify file integrity (checksum before/after) - ENFORCED
  • ⏳ Handle key rotation carefully - TO BE REVIEWED (Phase 5)
  • ✅ Test against known encryption test vectors (NIST) - VALIDATED
  • ⏳ Consider forward secrecy for future implementations - DOCUMENTED

🚫 Non-Goals (Future Work)

  • File compression (handle separately)
  • Chunked encryption for large files (>10MB)
  • Multi-party encryption (shared Secrets)
  • Key escrow/recovery mechanisms
  • Client-side key backup

📚 References


Type: Epic
Priority: High (Security-Critical)
Target Milestone: v0.3.0
Status: 80% Complete (Phase 1-4 done, Phase 5 final - 21.11.2025)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsecuritySecurity-related changes or vulnerabilities

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions