Initial commit

This commit is contained in:
2026-11-16 20:49:40 +02:00
commit eed5a36dd4
32 changed files with 621 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
# Architecture
## Components
1. Android client owns device identity, private keys, call secrets, media encryption and audio capture/playback.
2. Go API handles account registration, device registration and public directory operations.
3. Go signaling forwards authenticated, size-limited call setup messages. It is not a media server.
4. Key directory distributes public identity/prekey bundles. It cannot create or recover private keys.
5. coturn provides STUN/TURN traversal and relays encrypted packets only.
6. PostgreSQL stores account/device metadata and public key material.
## Media security boundary
WebRTC DTLS-SRTP protects each transport leg. It is not by itself sufficient for endpoint-to-endpoint confidentiality when a media intermediary terminates a leg. SFrame (RFC 9605) is the intended end-to-end media protection layer. The SFrame key-management protocol and sender authentication must be designed and tested separately.
## Call flow (target)
1. Caller obtains callee public device/prekey bundle.
2. Caller validates device identity or presents an explicit unverified warning.
3. Endpoints run a maintained PQXDH-compatible handshake and authenticate the transcript.
4. Endpoints derive fresh, directional SFrame sender keys using a reviewed key schedule.
5. SDP/ICE negotiation is forwarded by signaling.
6. Media flows directly or through coturn; SFrame ciphertext is opaque to relays.
7. Network changes trigger ICE restart/recovery without reusing key/nonce pairs.
## Explicit non-goals for MVP
- PSTN/SIM voice-call interception or encryption
- Group calls and video
- Desktop clients
- Server-side media recording
- Phone-number identity
+24
View File
@@ -0,0 +1,24 @@
# Cryptography implementation decisions
## Status: selection gate open
The target is a maintained Signal-protocol implementation supporting the exact PQXDH suite selected by the project, including ML-KEM where supported by that implementation. Do not assume that a standalone ML-KEM library plus X25519 automatically implements PQXDH.
Before selecting a dependency, record:
- upstream project and exact version/commit
- license and maintenance status
- supported Android ABIs and API levels
- PQXDH version and exact ML-KEM parameter set
- wire-format compatibility and test vectors
- security audit history
- key storage and zeroization behavior
- interoperability test results
## Media
Use an RFC 9605-compatible SFrame implementation integrated at the WebRTC encoded-frame boundary. Confirm Android native API support and verify that every audio sender has independently authenticated key material. Do not reuse a symmetric group key as proof of sender identity.
## Key schedule
The final protocol document must define domain-separated derivation for call ID, transcript hash, direction, sender/device ID, epoch and SFrame context. It must define rotation, counter/nonce handling, replay windows, teardown and recovery. This scaffold intentionally contains no cryptographic implementation.
## Passwords
Use a vetted Argon2id implementation with calibrated parameters and per-user salts. Do not use passwords as encryption keys for call media.
+9
View File
@@ -0,0 +1,9 @@
# Development deployment
1. Install Docker Engine and Compose plugin.
2. Copy `.env.example` to `.env` and set unique secrets.
3. Start with `docker compose --env-file .env -f infrastructure/compose/docker-compose.yml up --build -d`.
4. Check `curl http://localhost:8080/healthz` and `curl http://localhost:8081/healthz`.
5. View logs with `docker compose --env-file .env -f infrastructure/compose/docker-compose.yml logs -f`.
This Compose file is for local development. It intentionally does not publish coturn relay ports or configure production TLS. Before Internet deployment, configure DNS, TLS, firewall/relay port range, coturn shared-secret authentication, database backups, secret management, monitoring and rate limits. Do not use example credentials in production.
+24
View File
@@ -0,0 +1,24 @@
# Milestones
| ID | Goal | Exit criteria |
|---|---|---|
| M0 | Architecture/library research | Approved threat model; audited crypto and SFrame integration candidates selected |
| M1 | Repo and local infrastructure | Go tests pass; Compose health checks pass |
| M2 | Accounts and device directory | Registration, authentication, device and public-key APIs tested |
| M3 | Android foundation | Compose app builds; registration/login and Keystore identity skeleton work |
| M4 | PQ key agreement | Two devices interoperate with selected PQXDH implementation and identity verification |
| M5 | Basic WebRTC audio | Two Android devices exchange Opus audio in a test environment |
| M6 | SFrame E2EE | Encoded audio encrypted/decrypted at endpoints; relay cannot decrypt |
| M7 | Cellular resilience | CGNAT/TURN and network-change test matrix passes |
| M8 | Background calling | Core-Telecom and FCM incoming call flow works on supported devices |
| M9 | Security validation | MITM, replay, revocation and server-compromise tests pass; review completed |
| M10 | Release | Reproducible deployment, documentation and signed Android release |
Indicative effort for one experienced developer: roughly 15–22 weeks, with cryptographic and Android WebRTC integration uncertainty. This is a planning estimate, not a delivery commitment.
## Immediate work order
1. Verify candidate PQXDH library and Android SFrame encoded-frame support (M0).
2. Bring up Go services and PostgreSQL locally (M1).
3. Build Android shell and device identity storage skeleton (M3 foundation).
4. Implement API and public device directory (M2).
5. Only then integrate call setup and media.
+22
View File
@@ -0,0 +1,22 @@
# Network design
## Target transports
- IPv4 and IPv6
- ICE host and server-reflexive candidates
- TURN over UDP as preferred relay
- TURN over TCP/TLS as restrictive-network fallback
- Direct peer connectivity where possible
## Initial ports
- API/signaling HTTPS/WSS: TCP 443 (or 8080/8081 in local development)
- STUN/TURN: UDP/TCP 3478
- TURN TLS: TCP 5349
- TURN relay range: configure a bounded UDP range and open it in the firewall
Port 443 cannot be shared blindly between HTTPS and TURN-TLS. Use a dedicated IP/listener or explicit routing architecture. TURN credentials must be short-lived and generated using the coturn REST shared-secret mechanism.
## Recovery
Observe Android network callbacks and WebRTC ICE state. On network changes or failed ICE, perform a controlled ICE restart. Preserve the authenticated call session only while its cryptographic state remains valid. Never reset packet counters under an unchanged key; rekey if required by the media protocol.
## Test matrix
LTE/LTE, 5G/5G, Wi-Fi/Wi-Fi, Wi-Fi/LTE, IPv4-only, IPv6-only, dual-stack, CGNAT, UDP blocked, TCP/TLS relay, airplane-mode interruption and handover.
+22
View File
@@ -0,0 +1,22 @@
# Signaling protocol (draft)
WebSocket endpoint: `/ws/v1/signaling` over TLS.
Every message must be authenticated, versioned, size-limited and bound to a call ID and registered device ID. The draft message envelope:
```json
{
"version": 1,
"message_id": "random-unique-id",
"call_id": "random-call-id",
"sender_device_id": "device-id",
"recipient_device_id": "device-id",
"type": "CALL_REQUEST",
"sent_at": "RFC3339 timestamp",
"payload": "base64-encoded authenticated protocol payload"
}
```
Initial message types: `CALL_REQUEST`, `CALL_ACCEPT`, `CALL_REJECT`, `CALL_CANCEL`, `CALL_END`, `SDP_OFFER`, `SDP_ANSWER`, `ICE_CANDIDATE`, `KEY_CONFIRMATION`, `KEY_ROTATION`, `PING`, `PONG`.
This is a draft envelope, not a finalized wire protocol. Before implementation, specify canonical serialization, signature/MAC coverage, replay windows, message ordering, idempotency, maximum payload sizes, device authorization and error behavior. Never trust client-supplied sender IDs without binding them to the authenticated session.
+22
View File
@@ -0,0 +1,22 @@
# Testing strategy
## Go
- Unit tests for validation and state transitions
- API integration tests with disposable PostgreSQL
- WebSocket authentication, authorization and replay tests
- Fuzz tests for message parsing and size limits
## Android
- Unit tests for repositories and call state machine
- Instrumentation tests for Keystore and lifecycle
- Device tests for audio routing and background calling
## Security release gates
- Identity substitution and MITM attempts fail closed
- Replayed signaling and media packets are rejected
- TURN and signaling captures contain no decodable audio
- Server/database compromise does not expose media keys
- Device revocation blocks subsequent call setup
- Key rotation and ICE restart do not reuse key/nonce pairs
No security claim should be made based only on a successful encrypted packet capture. Verify endpoint authentication and actual decryption boundaries.
+32
View File
@@ -0,0 +1,32 @@
# Threat model
## Assets
Device identity private keys, prekey private material, call session secrets, SFrame sender keys, microphone audio, account credentials and contact relationships.
## Adversaries
- Malicious or compromised signaling/API server
- Compromised TURN relay
- Network operator observing traffic metadata
- Active network attacker modifying or replaying signaling
- Stolen or rooted endpoint
- Malicious registered contact
## Protected properties
- Confidentiality and integrity of audio between authenticated endpoints
- Authentication of the remote device
- Forward secrecy properties provided by the selected audited handshake/session protocol
- Replay resistance and device revocation
## Limitations
The mobile operator can observe that the device communicates, timing, IP/network metadata and approximate traffic volume. Endpoint malware, a compromised OS, microphone permissions abuse and social engineering are outside the guarantee of network E2EE. Push providers may observe opaque notification delivery metadata.
## Required mitigations
- QR/safety-number verification
- Signed identity/prekey bundles
- One-time prekey atomic consumption
- Strict transcript binding and replay protection
- Directional media keys and nonce uniqueness
- Short-lived authenticated TURN credentials
- Minimal server logs and retention
- Secure local storage and device revocation
- Independent cryptographic review before release