How PiRC's hosted relay keeps your sessions private
Last updated 30 November 2026
PiRC lets you drive pi, the coding agent, from your phone. Your laptop and your phone can’t usually reach each other directly, so both connect to a relay in the middle, and the relay passes messages between them. You can run that relay yourself, or use the one I run, at relay.pirc.dev.
Encrypting a relay’s traffic is the easy part. The easy way to defeat that encryption isn’t to break it. It’s to tell your computers “here’s another one of your devices”, and have them encrypt everything to the attacker as well. On most relays the server is the one that says who is in your account, which leaves that door open. On PiRC’s it can’t: only your phone can, and your computers check its signature.
When I decided to run a relay for other people, I asked myself what would worry me if it were someone else’s product. I came up with four things:
- Can the relay read my sessions? Is it phoning home?
- What if someone breaks into the relay?
- Is the extension safe to put inside my pi?
- Could any of it leak my data, or do something worse?
This post answers each of them, with what PiRC does, a picture of it, and how you can check it yourself. First, the short version for anyone who reads protocols for a living. The full design is in docs/e2e.md. This describes the relay as it runs on the date at the top. When it changes, I’ll update this post and say what changed.
The short version
There’s no new cryptography in PiRC. Nothing in it is invented here:
| Part | What PiRC uses | Where you’ve seen it |
|---|---|---|
| All the cryptography | libsodium (audited in 2017) | NaCl’s design; Threema |
| Live sessions, phone to pi | Noise IK, 25519_ChaChaPoly_SHA512, fresh keys every connection |
WireGuard’s handshake; WhatsApp’s transport |
| Who’s in your account | One list of public keys, signed (Ed25519) by one phone, with a counter and a hash chain | WhatsApp’s linked devices; SSH’s authorized_keys |
| What the relay stores | libsodium’s crypto_box, sealed by the computer once per device |
Threema’s stored messages |
| Adding a device | QR code with a 256-bit one-time secret, then Noise XXpsk3 |
Signal’s and WhatsApp’s device linking |
| Who may sign up | Apple’s App Attest, Google’s Play Integrity | The stores’ own check that an app is genuine |
And the details people usually ask about:
- Signatures are checked with libsodium everywhere, built so that non-canonical and small-order keys are refused the same way on every platform.
- Everything signed is signed as exact bytes, and checked before it’s parsed. Every signed string starts with its own context (
pirc-e2e-v2 list,… join,… channeland so on) and length-prefixes each part, so no signature can be passed off as another kind. - The relay can’t read, write or add a device. It can still drop, delay or refuse things, and it sees metadata. Sections 1 and 2 list what it can still do.
- Not audited yet. What that means, and what’s PiRC’s own rather than standard, is in “What isn’t settled”.
What this assumes. The relay may be hostile. You trust your phone’s operating system, your computers, pi itself, and Apple and Google to deliver an empty push.
1. Can the relay read my sessions?
No. It can see who is connected and how much they send. It can’t see what’s in it.
Here’s the same message, as your phone gets it and as the relay gets it:
build box · api-server · pi is asking
"I'm about to delete test/fixtures/old/ (214 files). Go ahead?"
Yes · No
9f3a 07c1 e85b 2d4f a611 0b9e 77c3 5e02 c4d8 13fa 90b6 2e7d 48a1 f05c 6b39 d2e4 8c17 3a5f e0b2 91d6 4c8e 07a3 5fb1 c962 1e4d a8f7 3b05 d6c2 ...
| from | a computer's public key, and its pi process |
| to | a phone's public key |
| channel | #4127, opened 14:02:11 |
| size | 412 bytes |
| sent | 14:06:58 |
| wake the phone? | yes |
When you open a session on your phone, the app sets up an encrypted channel with that pi process on your computer. Everything of the session travels inside it: your prompts, pi’s replies, tool calls and their output, images, history. The relay passes the channel’s messages along, in order, without being able to open them.
The channel uses the Noise Protocol Framework, the same framework WireGuard’s handshake is built on and WhatsApp uses for its transport, with the pattern called IK. The keys for each channel are made fresh every time it opens and are never stored. So even someone who recorded all the traffic, and later stole a key from one of your devices, couldn’t open what they recorded.
There’s one thing the relay keeps for you: the session list, so your phone can show your sessions the moment you open the app. Each entry has a session’s name, its folder, its model and pi’s latest question or message. Your computer seals each entry separately for each of your devices, with libsodium’s crypto_box, before it reaches the relay. The relay holds the sealed copies, hands each device only its own, and forgets an entry when its session ends.
What the relay does see, plainly:
- your devices, by their public keys, and whether each is a computer or a phone or browser;
- which are connected, from what address, and when;
- which device opens a channel to which pi session, and when, and each session’s ID, which includes when it started;
- how big each message is and when it’s sent, so roughly when a session is busy;
- when a turn ended or pi asked a question, so it can send the notification;
- how many bytes each account’s devices send and receive each day, the most computers it has connected at once, and how many sessions it opens, kept for 30 days to spot abuse and deleted with the account;
- your app’s attestation and subscription: Apple’s or Google’s confirmation that it’s a real PiRC app on a real phone, and the store’s ID for your subscription. Those tie your account to your Apple or Google account. “No email, no password” doesn’t mean nobody could ever link it to you.
Internet addresses are kept in logs for 14 days, and backups keep a deleted account for up to ten weeks. The privacy policy has the full list and how long each thing is kept.
What it never sees: your prompts, pi’s replies, tool calls and their output, images, session names, folders, models, pi’s questions, or the names of your devices.
Is it phoning home? The relay is home: it’s the one server PiRC uses. Section 3 covers what the extension connects to.
2. What if someone breaks into the relay?
They’d get the metadata above, and nothing more. They couldn’t read your sessions, and, just as important, they couldn’t add a device of their own to your account.
That second part matters most, for the reason at the top: a server that can add a device to your account can read everything, however good the encryption.
PiRC closes it the way WhatsApp’s linked devices do. Your account is a list of devices, and only one device can change it: the phone that created the account. That phone signs each version of the list. Every computer and every other device checks the phone’s signature before believing a list, and only ever accepts a newer one. Try both:
The same check runs at the start of every session: the first thing your phone sends inside a new channel is its newest list, and your computer answers only once it finds that device on a list your phone signed. A device the relay lets in, but your phone never signed, gets nothing from your computers.
Adding a device works like linking WhatsApp to a laptop. Step through it:
- On the new machine you run
/pirc joinin pi. It makes a one-time 256-bit secret and a short lookup, and shows both as a QR code, with the same code as text underneath for when you're in a terminal on your phone. - Your phone reads the code with its camera, or you paste the text. The secret travels from screen to phone, never through the relay.
- The phone finds the machine through the relay by the lookup, and the two run a Noise
XXpsk3handshake with the secret as the pre-shared key. It only completes if both sides hold it. - Before anything is added, the phone tells you in words what you're about to allow, and asks you to confirm you're at the machine that shows this code.
- The phone signs a new list with the machine on it and sends it inside the channel. The machine pins the phone's key from the handshake, and from then on believes only lists that phone signed.
The code expires after ten minutes and works once. Because it lets whoever uses it control that machine, /pirc join says so next to it, and afterwards tells you which phone approved it.
What a relay that’s been broken into can still do:
- It can refuse to carry your messages, or drop or delay them. A dropped message closes the channel and your phone opens a new one.
- If you remove a device, the relay could hide that news from a computer for as long as none of your other devices connects to it. Your phone shows each computer that hasn’t confirmed a removal yet.
- If someone else reads your join code in the ten minutes it’s valid, they could join that machine to their own account. Treat the code like a password while it’s on screen.
- It could show you an older session name or entry until a newer one arrives. It can’t make one up.
3. Is the extension safe to put inside my pi?
The extension makes one connection: to the relay you chose. It opens no port, sends no analytics, and talks to nothing else.
It’s about 6,500 lines of TypeScript, not counting tests, in three folders of the repository: extension/src, relay-client (the relay connection, its only network code) and e2e (the encryption). It depends on four packages: libsodium, Protocol Buffers, a WebSocket client and a QR code drawer, each pinned to an exact version.
Where your copy comes from. Each release is built from a signed git tag, and every download is listed in the release’s SHA256SUMS. The npm package is published by a GitHub Action straight from that release’s archive, byte for byte, with npm’s provenance. SECURITY.md has the commands to check each step, such as:
git -c gpg.ssh.allowedSignersFile=allowed_signers verify-tag vX.Y.Z
npm audit signatures
What it lets your devices do. This is the part to take seriously. A device on your list can do anything pi can do on that computer: send any prompt, approve any question, start a new pi. That’s what PiRC is for, so the security of the whole thing is the security of that list: who is on it, and who can change it. It’s why only your phone can change it, and why your phone tells you, in words, what each new device will be able to do before it’s added. And it’s worth running pi somewhere you’re comfortable with an agent running, PiRC or not.
Old copies can’t be tricked. Versions of the extension from before encryption don’t know how to encrypt. A machine that joined the hosted relay stores its address where old versions don’t look, and puts a placeholder they refuse where they do, so an old copy on the same machine fails to connect instead of talking to the hosted relay in the clear. A test checks this against the last old release.
4. Could it leak my data, or do something worse?
Your conversation leaves your computer only inside channels to your own devices. History stays on the computer and is sent, inside the channel, only when one of your devices asks for it.
Notifications are the one place a third party is involved, since only Apple and Google can wake a phone. So the push carries nothing at all. It only wakes the phone:
- A turn ends. The relay asks Apple or Google to wake your phone. The push has nothing in it.
- Your phone wakes and asks the relay if there's anything for it.
- The relay hands over the notice your computer sealed to this phone.
- The phone opens it and writes the notification itself. Apple and Google saw only that your phone was woken, and when.
A lost or stolen phone, or a stolen key. Pick what was taken:
They get: the notifications. While the phone is locked it holds only the keys a notification needs, so they can read new notices (a session's name and pi's latest question) until you remove the phone.
They don't get: your conversations, or any way to act. The keys that open sessions are behind Face ID or your PIN.
What you do: remove it, from the phone that runs your account. If the stolen one was that phone, run /pirc leave on each computer and start a new account. Your sessions on the computers aren't affected.
They get: nothing they recorded earlier. With the relay's help, they could act as that computer until you remove it.
They don't get: your other computers' sessions. Computers share no keys.
They get: what that device could do: a shell on every computer in the account, until you remove it. Every device you add has this power.
They don't get: conversations recorded before. Each channel's keys are fresh and never stored.
They get: the metadata in section 1, and sealed session lists they can't open.
They don't get: any conversation, any name, or a way into your account. Only your phone signs the device list.
“Something worse”, like your computer running commands nobody sent? Only a device on your phone-signed list can ask pi to do anything, and only through a channel to that one pi process. A request sent to the wrong process is refused. One of your computers can’t read another’s sessions either: they share no keys.
If you use PiRC in a browser
The web app is the one place where the encryption depends on code you didn’t install. A web page runs whatever its server sends, each time it loads. So the page is served on its own, from fixed files on Cloudflare Pages, apart from the relay: someone who breaks into the relay doesn’t get the page. But you are trusting Cloudflare and the deploy of the page, as with any web app. If that’s not a trade you want, use the phone apps, or add browsers only for short spells and remove them after.
What isn’t settled
- No one has audited it independently yet. libsodium was audited, and Noise is a published standard, but PiRC’s use of them hasn’t been reviewed by an outside firm.
- The Noise code is PiRC’s own, about 600 lines each in TypeScript and in Dart on top of libsodium, because there’s no audited Noise library for Dart. Both are held to two independent sets of published test vectors, and run against each other.
- The Dart libsodium package the app uses has one publisher and few users. It’s pinned to an exact version, and its build checks the libsodium source against the official release.
- The stored session list has no forward secrecy. Someone who records the relay and later steals a device’s key can open the session names and notices sealed to that device. Not the conversations.
- The relay sees traffic sizes and timing. Padding messages to fixed sizes could come later.
- If you lose the phone that runs your account, nothing can be added or removed. You start a new account and run
/pirc joinagain on each computer. A recovery code is planned. - No one can show that a store app was built from this source. Apple encrypts each App Store binary for the device it’s installed on, and Google Play re-signs what it serves, so it can’t be compared with a build from source. That’s true of every app in those stores, Signal’s included. The source is public under the GPL, and you can build and install your own.
SECURITY.mdsays more. - Signing up needs a phone that passes Apple’s or Google’s check. Some phones with custom Android systems may not. It’s what stops accounts being made in bulk, and I think it’s worth it, but it is a cost.
- If I stop running the relay. PiRC is one person’s project. If I ever shut relay.pirc.dev down, I’ll give at least 90 days’ notice in the app and here. The relay is open source, and the app and extension work with a relay you run yourself, so you can carry on with your own.
- Your own relay isn’t encrypted end to end. If you self-host, you trust the relay you run. A computer that joined the hosted relay won’t talk to an unencrypted one.
Read the Noise code
The part I’d most like a second pair of eyes on is the Noise implementation: about 600 lines in TypeScript (e2e/noise-core.ts) and about 600 in Dart (app/lib/e2e/noise.dart and noise_core.dart). If you know Noise, please read it. Report anything you find to [email protected] or through GitHub’s private vulnerability reporting. With your permission, I’ll thank everyone who finds a real problem by name, here and in the release notes.
Check it yourself
- The design:
docs/e2e.md. Section 10 says what I considered and rejected (MLS, Matrix, Signal’s protocol, WebRTC) and why. - The Noise code:
e2e/noise-core.tsandapp/lib/e2e/noise.dart, with the test vectors incases/noise/. - The checks every implementation must pass:
cases/e2e/. - Release signatures and checksums:
SECURITY.md.
If you find a problem, please write to [email protected], or use GitHub’s private vulnerability reporting on the repository. I’ll answer, and fixes go out in the next release.
--
Igor