The encrypted relay

The relay is a mailbox for opaque encrypted envelopes: it stores and forwards ciphertext, nothing else. It lets a parent's phone reach Parent mode when it is not on the home Wi-Fi. It is built but not online yet.

Pieces. The relay (PHP 8.3 + SQLite, relay/public/api.php); the phone (a PWA, WebCrypto, tunnel in a service worker); the computer (/usr/local/lib/yapuka/parents_relay.py, Python standard library) which replays requests on 127.0.0.1:8787. The phone page is not duplicated: the service worker fetches the computer's own page through the tunnel. Only six routes are reachable: GET /, /api/status, /api/messages, /avatar.svg, /icons/<app>.svg and POST /api; /local/* and /pair never are.

Primitives (built from HMAC-SHA256, which both Python and WebCrypto have): HKDF-SHA256 (RFC 5869) for keys; encryption with HMAC-SHA256 as a PRF in counter mode; encrypt-then-MAC with a 32-byte tag checked in constant time. Envelope (base64url): version 0x01 ‖ seq u64 ‖ nonce 16 ‖ ciphertext ‖ tag 32, with the header and box id authenticated. Separate keys per direction. Test vectors: parents_relay.py --self-test and node relay/test/crypto-test.js.

Updated on