Skip to content

Commit 75bbcb4

Browse files
docs(e2ee): add Argon2id table, canonicalization spec (JCS), and Mermaid diagrams for key flows
1 parent 5c41c00 commit 75bbcb4

4 files changed

Lines changed: 57 additions & 1 deletion

File tree

DESIGN-E2EE.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ Owner: Kyaw
1616
- Out of scope initial: traffic analysis resistance; plaintext content scanning; hardware tamper beyond platform enclaves.
1717

1818
## 3. Cryptographic Primitives and Libraries
19+
20+
### 3.1 Argon2id Parameters (desktop vs mobile)
21+
- Desktop/Web: m=64 MiB, t=3, p=1 — balances user-perceived latency with robust GPU/ASIC resistance for key wrapping. Typical derivation latency ~200–500 ms on contemporary laptops.
22+
- Mobile: m=32 MiB, t=3, p=1 — reduces memory pressure and thermal impact while keeping meaningful resistance. Target latency ~300–700 ms depending on device class.
23+
- Salt length: 16 bytes (random per vault). Output length: 32 bytes (KEK).
24+
- Rationale: Memory-hardness is the dominant cost lever; t=3 provides reasonable compute amplification without excessive energy draw on battery devices.
25+
1926
- Ed25519 (signing) for identities and devices.
2027
- X25519 (ECDH) for key agreement; sealed boxes for key wrapping (HPKE-ready abstraction).
2128
- Messaging: Signal/Double Ratchet via libsignal-client (WASM) for 1:1/small groups.
@@ -47,6 +54,12 @@ Transitions:
4754
- Group sender keys: per-room sender key rotated on membership change and every 7 days; per-recipient key wraps.
4855

4956
## 6. File Encryption and Sharing
57+
See also Mermaid diagrams in docs/diagrams for provisioning, file-share, and rekey flows.
58+
59+
### 5.1 Canonicalization (signatures & tokens)
60+
- Manifest signing: Canonical JSON per RFC 8785 (JSON Canonicalization Scheme, JCS). Remove the `sig` field before canonicalization; sign the result with device Ed25519. Verification recomputes canonical JSON and verifies the signature.
61+
- PASETO payload normalization: When computing or verifying detached request signatures or audit hashes, canonicalize the JSON payload using the same JCS rules and sort header fields if applicable. Avoid including transient fields (e.g., `iat` skew-adjusted values) in hash commitments.
62+
5063
### 6.1 Streaming Encryption
5164
- Per-file random DEK (256-bit).
5265
- Chunk size 512KB–2MB (adaptive). Max single-object size: 5 GB (resumable uploads).
@@ -67,7 +80,7 @@ chunks:
6780
blake3: <hex>
6881
- ...
6982
key_wraps: omitted in manifest; stored adjacent by object_id
70-
sig: ed25519(signing_device_pubkey, canonical_json(manifest_without_sig))
83+
sig: ed25519(signing_device_pubkey, JCS(manifest_without_sig))
7184
```
7285

7386
### 6.3 DEK Sharing

docs/diagrams/file-share.mmd

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
sequenceDiagram
2+
autonumber
3+
participant C as Client
4+
participant O as Object Store
5+
participant S as Server
6+
7+
C->>C: Generate DEK
8+
loop Encrypt chunks
9+
C->>C: nonce_i = HKDF(DEK, "file-chunk"||i)[0..12]
10+
C->>C: c_i = AES-GCM(plaintext_i, nonce_i)
11+
C->>C: blake3_i = BLAKE3(c_i)
12+
end
13+
C->>C: blake3_file = BLAKE3(c_*) ; manifest+sig
14+
C->>O: PUT chunks + manifest (ciphertext only)
15+
par share DEK
16+
C->>S: POST key_wrap(device_pkX, sealed_box(DEK))
17+
and for each recipient
18+
C->>S: POST key_wrap(device_pkY, sealed_box(DEK))
19+
end

docs/diagrams/provisioning.mmd

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
sequenceDiagram
2+
autonumber
3+
participant ND as New Device
4+
participant TD as Trusted Device
5+
participant S as Server
6+
7+
ND->>ND: Generate Ed25519_sign_D, X25519_D, nonce N, ts
8+
ND->>TD: Display QR: base64url(JSON{device_pubkeys, N, ts, sig=Sign_D(N||ts)})
9+
TD->>TD: Compute SAS = hash(identity_pub, device_pubkeys, N, ts) -> 7 emojis
10+
ND-->>TD: Human verifies SAS matches
11+
TD->>S: POST /devices/attest(attestation=Sign_T{identity_pub, device_pubkeys, N, ts})
12+
S-->>TD: 200 OK
13+
S-->>ND: WS event device-verified

docs/diagrams/rekey.mmd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
sequenceDiagram
2+
autonumber
3+
participant A as Admin
4+
participant S as Server
5+
participant C as Clients (room)
6+
7+
A->>S: Update membership
8+
S-->>C: WS membership-change
9+
C->>C: Rotate sender key; rewrap DEKs
10+
C->>S: POST new wraps
11+
S-->>C: Ack; old wraps invalidated

0 commit comments

Comments
 (0)