Skip to content

Pairing

  1. The app generates an X25519 identity on first launch and stores it in the secure store.
  2. The user enters a phone number. Supabase Auth sends a six digit SMS code (signInWithOtp).
  3. On verification the app upserts a profiles row with a display name and the public key.

The phone number is the account. One number, one profile, one active pair.

Alice shows, Bob scans. Either role works; the relay does not care who is ‘a’ and who is ‘b’.

Alice Relay Bob
|-- insert invite (sha256 of code) -->| |
| show QR: filocan:pair:<base64> | |
| |<-- rpc accept_invite(hash, --- |
| | bob_pub) |
| | creates pairs row |
|<-- realtime: pairs INSERT (a=me) ---|--- returns pair row ---------->|
| derive pairKey with bob_pub | derive pairKey with alice_pub
| show safety string | show safety string

The QR payload (createInvite in protocol.ts) is under 200 bytes: version, Alice’s public key, her user id, her display name and a 10 minute expiry. The relay stores only the SHA-256 of the full invite text, so a leaked database cannot be used to accept someone else’s invite.

accept_invite is a security definer Postgres function. It checks the invite is unused and unexpired, that Bob is not Alice, and that this couple is not in a cooling-off period, then inserts the pairs row. A partial unique index on the couple (least(a,b), greatest(a,b) where ended_at is null) makes a second live string between the same two people impossible at the database level, and a trigger caps each person at twelve strings.

Alice’s phone learns Bob’s public key from the pairs row (via Realtime, with a 3 second poll as a fallback) and both sides derive the same pair key. Neither key nor the derived secret crosses the network.

The Us tab shows the safety string. Reading it aloud, or comparing screens, confirms there was no man in the middle. Because pairing happens in person by scanning a screen, this is belt and braces, but it costs nothing to show.

Roadmap (the table exists, the flow is not built yet):

  1. The web client generates an ephemeral X25519 key and inserts a linked_devices row.
  2. The phone shows pending devices; the user approves one.
  3. The phone encrypts the pair key to the device key and writes wrapped_key.
  4. The web client unwraps it and can decrypt. The phone can set revoked_at at any time.

The relay sees a wrapped key it cannot open.

end_pair(pair_id) sets ended_at and ended_by, inserts a system message, and upserts a cooling_off row for the couple with until_at = now() + 30 days. Other strings either person holds are untouched. The other phone sees the pairs UPDATE via Realtime and wipes its local state. Messages for ended pairs are deleted by a nightly job (see Operations). Either person can call it; there is no confirmation from the other side and no fee.

Pairing the same two people again before until_at fails inside accept_invite unless skipped is true, which only the payment webhook can set (skip_cooling_off, service role).