When the host dies, the commons dies with it
For years, people have been able to donate their loop data to research through hosted data commons — you upload, an institution holds it, studies draw on it. Those pathways keep disappearing: a grant ends, a project winds down, priorities shift, and the commons goes dark with its host. That isn't bad luck — it's the design.
diaswarm is built so that can't happen. The commons isn't a place you upload to — it's a set of keys. The data lives, encrypted, on the devices of the people in it. No server to fund, no company to acquire, nothing to defund. A research project is just someone you hand a key to, and stop handing keys to when you're done.
The community already generates some of the richest health data in the world. It should outlive whoever happens to be hosting it this year.
One gesture. Every scale.
Sharing your glucose with your mum and feeding a global research cohort are the same act — seal data, hand a key to whoever you chose. Watch it scale.
One person, one key
A reading is sealed on your phone and a key is handed to one reader. That's the whole idea — everything else is this, repeated.
The same gesture, three scopes
Hand that key to a parent, a clinic, or a study. The gesture doesn't change — only the scope of the key does. A clinic's opens a 90-day window; a study gets rows, not a person.
Zoom out: it's a commons
Thousands of people doing the same thing, and every phone quietly carrying a little of everyone else's sealed data — able to read none of it. The more people, the stronger it gets.
There was never a middle
Picture the server every other system puts here. Now take it away. Nothing to run, nothing to capture, nothing anyone can switch off.
The person with diabetes
Your phone seals its own history and publishes it. You hold the keys; nobody reads a byte unless you hand them one.
running · AAPSA parent or partner
Handed a key one at a time, and cut off one at a time — not the all-or-nothing shared password every server forces on you.
running · AyniA clinic
Granted a window the key itself enforces — older data is unreadable to them, not merely hidden.
protocol today · app nextA study
A granted member on the swarm side, standard research formats (CSV, Parquet, FHIR) on the other. The donation role, re-homed where it can't be defunded.
specced · next buildEvery device, carrying
Each phone holds a share of others' sealed data it can't read, so a sleeping phone stays reachable — and it self-heals as people come and go.
running · the substrateBoth connect through the exact same key mechanism — the only difference is the scope of the key and the shape at the edge. A clinic's key opens a bounded window. A study's data is translated into research formats on the granted reader's own device, so even the exporter never becomes a custodian. No new trust model, no new server, at either end.
Everything the Diabetes Data Rights Charter is asking for, running on a phone
People with diabetes spent seven roundtables across 16 countries writing down what control of their data should mean — the Diabetes Data Rights Charter. They described a system that doesn't exist in the commercial world. diaswarm is a working demonstration that it can be built: running code, not a policy asking a manufacturer to behave.
Consent & control that's real
Per person, by key, and withdrawable without asking a server's permission. Revoking one follower doesn't revoke everyone.
Privacy by design, in the strongest form
The people holding your data cannot read it — structurally, not as a policy they could quietly change.
Access with no vendor in the chain
Sensor to open source to your chosen reader. Nobody's cloud in the middle.
The project keeps a public, unflinching self-assessment against all eight principles, including where it still falls short and what would close each gap. That document is itself the kind of transparency the Charter is asking industry to adopt. → docs/rights.md
You can't buy the middle, because there is no middle
Every company circling this space is selling the same thing: a place in the middle — the server you rent, the account they gate, the data they broker, the lock-in that keeps you. Centralised platforms can be monetised because there's a chokepoint to own.
What a custodian charges for
- The host and the database the data lives in
- The account and directory that gate who's who
- The API that reads and writes it
- Brokering the aggregate data onward to third parties
- The friction of migrating off — lock-in
Each is a chokepoint someone owns.
What diaswarm leaves
- No server to meter — data is ciphertext on participants' devices
- No custodian holding the data to broker
- No directory — you can't even search for a person, by design
- Access is key custody; withdrawing asks no server's permission
- AGPL, no APK sold, no account to lock in
No chokepoint to charge rent on.
The same thing that means nobody can sell it means nobody can capture it, subpoena it out of an operator, or pull its funding — because there's no operator and no funding to pull. It's AGPL, it's the community's, and it stays that way. The honest cost, said out loud: there's no company behind it either. What keeps it alive is the people who build and run it.
The questions change
Most worries about a system like this come from a lifetime of thinking in servers. Take the server away and the questions don't get harder — they change.
None of these are things diaswarm fails to do. They're things the server made you expect in a shape that was never quite true. Same guarantees, told honestly — and, in the ways that actually protect you, stronger.
A role for Nightscout: seed the swarm, hold nothing
Keeping the network available isn't only on the users being followed. Anyone who wants to support it can strengthen it — at very low cost and effort. A single always-on device that carries a share of the swarm and serves it onward makes everyone's data more reachable, whether or not you follow a single person yourself.
Availability gets stronger the more always-on devices sit in the pool. A handful of seed boxes — funded by the Foundation and scattered around the world — would make it structural rather than a matter of how many followers happen to be awake. Each carries a share of the swarm's sealed data and can read none of it. A seed box breach is not a data breach.
Runs on anything
A small Rust binary. An old phone, a Raspberry Pi, a spare NAS, a retired laptop — mains power and a network connection is the whole spec. No battery, no Doze, so it's simply always there.
Costs next to nothing
A pool share is tens of megabytes a year and a trickle of bandwidth. Run one on hardware you were about to throw out, for roughly the electricity of a nightlight.
Holds nothing it can read
Every byte on a seed is ciphertext for people it was never granted. The Foundation strengthens the commons without ever becoming a custodian, a data controller, or a breach target.
Nothing central
Seeds don't coordinate and none is privileged — they just add always-on shoulders under the pool. Lose one and the arithmetic heals.
The pool has so far only run on a handful of phones. A dozen funded seed boxes wouldn't just harden availability — they'd be the first real test of the swarm at scale, the one thing the project most needs and can't fake with three devices. Funding the seeds is funding the proof.
It's the cleanest role there is for an organisation that cares about this community's data: make it more available to everyone, while holding none of it, reading none of it, and being liable for none of it.
Where it stands
Everything above the line runs. Everything below is a known next step with a design already written — which is exactly where a project invites the people who want to shape it.
Running on real hardware — sealing, granting, revoking, the swarm, phone-to-phone across different networks, on a live closed loop.
shippedThe follower app (Ayni) — a real Android app that shows someone's glucose.
shippediOS — the core is platform-neutral Rust; no iOS follower yet. The obvious next build, and where the Trio community comes in.
openThe research gateway — the export formats that make the commons a commons are specced, not written.
nextThe clinic app — the protocol enforces scoped windows today; the provider UI is still to build.
nextSecurity review — standard primitives, composed by hand, no third-party audit yet. We say so everywhere and we'd welcome it.
honest gapHow a reading actually moves
The mechanism under all of that, step by step — the record format, the encryption, the logs, the network, and what each party can and can't see.
The walkthrough
Eleven steps. Each one names the algorithm, the identifier or the interval involved, and links to the code that does it.
-
A record, made canonical
The AAPS plugin drains new rows and writes one canonical NDJSON line per event. Keys are sorted, glucose is in mg/dL, time is UTC milliseconds. Two implementations produce byte-identical lines, so streams can be hashed and diffed.
- format
- NDJSON, sorted keys, no nulls
- order
(t, k), ties by the canonical line- epoch
- one day, cut at the subject's fixed UTC offset
- spec
- spec/records.md
-
Sealed under the group's current secret
New records are encrypted as a delta segment under the latest group secret. Each segment names the secret it used, so a reader can open it without having opened any other segment.
- AEAD
- XChaCha20-Poly1305 (p2panda-encryption
encrypt_data) - nonce
- 24 bytes, random per segment
- segment
{epoch, secret_id, nonce, ciphertext}- compression
- none
- cadence
- every 60 s, or sooner at 32 KB of backfill
- code
- crates/diaswarm-keys/src/lib.rs
-
Signed and appended to the subject's log
The segment becomes a p2panda operation in log 0 of the subject's Ed25519 key. Each operation is signed and hash-chained to the one before it, so any holder can check it without being able to read it.
- log 0
- segments, one author per log
- header
SegmentArgs{epoch, secret_id, nonce}- body
- ciphertext
- integrity
- Ed25519 signature, backlink,
seq_num - code
- crates/diaswarm-keys/src/wire.rs
-
Peers find each other
On the same network, peers find each other over mDNS. Across networks, both sides connect to the iroh relay named in the invite. It introduces them, and drops out of the path once they hole-punch a direct QUIC connection. Each peer counts the pool from the presence topic.
- transport
- iroh QUIC, ALPN
diaswarm/6 - gossip
- iroh-gossip (HyParView) via p2panda-net
- discovery
- mDNS on the LAN; relay URL carried in the invite
- presence
SHA-256("diaswarm-presence-v1")- code
- crates/diaswarm-net/src/swarm.rs
-
A grant is group membership
Sharing adds the reader to the subject's encryption group. A welcome message, sealed to the reader's X25519 key bundle, carries the group secrets. Grants go in a separate control log and name members by a tag only the two parties can compute.
- log 1
- control: create, add, remove, update, welcome
- reader key
- p2panda
LongTermKeyBundle(X25519) - member tag
HKDF-SHA256(ECDH(subject, reader), "diaswarm-grant-tag-v1" ‖ purpose)- access
- holding the secret; the log is for accountability
- code
- crates/diaswarm-keys/src/group.rs
-
Every peer picks the same three holders
A subject falls in the bucket given by the top bits of its hash. Every peer ranks every other peer for that bucket by a rendezvous hash and takes the top three. Nobody coordinates: the same peer list gives every peer the same answer.
- depth
- ⌈log₂(pool size)⌉
- bucket
- top
depthbits ofSHA-256(subject) - holders
- top 3 by
SHA-256(peer ‖ "\0bucket\0" ‖ bucket) - topic
SHA-256("diaswarm-bucket-v1" ‖ depth ‖ bucket)- code
- crates/diaswarm-net/src/pool.rs
-
Holders replicate what they can't read
Holders catch up on the subject's logs with p2panda log sync, then receive new operations live over gossip. They verify signatures and store ciphertext. They hold no group secret, so they can't open anything.
- catch-up
LogSync/TopicLogSync- live
- gossip on the subject's topic, pushed as each entry is appended
- store
- operations in SQLite (
keys.sqliteon the desktop peer) - size
- ~13 MB/yr per subject at 5-min CGM; ~55 MB/yr at 1-min
- code
- crates/diaswarm-net/src/replicate.rs
-
The subject can be offline
The reader syncs every two minutes while its phone is awake, from whichever holder answers. The subject's phone doesn't need to be reachable. When the reader's phone sleeps, Android Doze can stretch the interval.
- interval
- 120 s (
SyncWorker.EVERY_SECONDS); measured 105 s and 123 s - age on screen
- 63 s, measured across CGNAT and home wifi
- source
- any peer holding the subject's logs
- code
- follower/…/SyncWorker.kt
-
The reader opens it
Ayni opens the welcome addressed to it, then replays later control messages to pick up each rotation. It decrypts every segment with the secret that segment names. Records are deduplicated and drawn with their age. At 15 minutes old, a reading counts as stale.
- join
- find our welcome in log 1, replay what follows
- read
- walk back from the log tip until the days asked for are covered
- errors
not_oursandlostreported separately- stale
- ≥ 15 min; stale readings never alert
- code
- crates/diaswarm-keys/src/follow.rs
-
Stopping sharing rotates the secret
Removing a reader rotates the group secret. The next segment is sealed under secret #2, which the reader never receives. Holders still carry it and the reader can still fetch it, but can't open it. Anything sealed under a secret the reader already holds stays readable to them.
- operation
Group::remove, then a new secret- control
- a
removemessage in log 1 - schedule
- the plugin also rotates every 24 h, so grants can be scoped by day
- not recalled
- anything under secrets the reader already holds
- code
- Vault::revoke in diaswarm-keys
-
What the network can still see
No holder and no relay can read a record. The relay does see which node ids talk to each other, from which IP addresses, and when. Holders can see how many grants there are and when they happened. Publication is permanent, and a leaked secret opens everything sealed under it.
- relay
- n0's by default; run
iroh-relayand put your URL in the invite - forward secrecy
- none
- reads
- not observable by anyone
- review
- custody layer not yet independently reviewed
- more
- README: The trade · SECURITY.md
Latency and availability
Two questions people who run Nightscout ask first: how old is the number when a follower sees it, and what happens when the phone that has the data is unreachable. Here is what the code does, what has been measured, and what hasn't.
How old a reading is on the reader's screen
Worst case with both phones awake, counted from when AAPS has the reading. Drawn to scale. The measured mark is the age the reader showed on screen.
- Subject
- The plugin seals and publishes every 60 s, or sooner once 32 KB of backfill is waiting (
SHADOW_SEAL_INTERVAL_MS). - Holders
- Pushed to over gossip as each entry is appended. There is no polling interval on this hop.
- Reader
- Polls every 120 s while awake. Measured at 105 s and 123 s between unattended refreshes.
- Measured
- 2026-09-11: subject on mobile data behind CGNAT, reader on home wifi. Each refresh showed the newest reading as
0m old, and the screen read 9.4 mmol/L, 63 seconds old.
The reader isn't pushed to, by design. The subject doesn't know who follows them: the grant log names nobody, and a fetch doesn't say who is fetching. So the reader has to ask (D17).
In a pocket, Android sets the interval. Doze batches background work, so a reader phone that isn't excused from battery optimisation refreshes much less often. A held-open subscription would help while the app is open, but Doze closes sockets in the background either way. That's why every reading is drawn with its age, and counts as stale at 15 minutes.
When something is unreachable
What a reader gets in each case. The tags say how far each claim has been tested.
The subject's phone is off or out of signal
Readers fetch from the three holders, which verify and serve identical ciphertext. Nothing new arrives until the phone is back.
A holder leaves the pool
Every peer recomputes the pool size, bucket depth and top three holders on its next pass. Survivors pick up the gap. There's no repair process and nothing to elect.
Every holder is a phone, and they're all asleep
Doze, and Android killing the foreground service after about six hours, can leave no holder serving. A desktop peer is mains-powered and has neither problem, so one in the pool removes this case.
diaswarm-peer) is released for this.The pool is smaller than three
With fewer than three peers, every peer holds every bucket, so there are as many copies as there are peers.
depth_for(2) is 1, so both peers hold both buckets on every run.The relay is unreachable
Phones on the same network still find each other over mDNS. Across networks, phones behind NAT can't find each other without a relay. It's the single third party in the design. The relay URL travels in the invite, so you can run your own.
The reader's phone has been quiet for hours
Ayni shows every reading's age. It tells "held but can't open" apart from "nothing sent" and reports which peers it couldn't reach. Nothing yet warns that the silence has gone on too long.
Read the source
Where to start, depending on what you want to check.
Record format
The frozen contract every later stage encodes against, with the mistakes that shaped it.
spec/records.mdKeys vault
Segments, group secrets, grants, rotation and the follower's read path.
crates/diaswarm-keysNetworking
Swarm setup, topics, bucket assignment and replication on p2panda-net and iroh.
crates/diaswarm-netWhat we won't claim
The sentences this project may never say, and the true version of each.
docs/feasibility.md §11Roles
Who each layer is, what they may truthfully be told, and the honest limit on each.
docs/roles.mdData rights
The full per-principle assessment against the Charter, with the evidence that would change each verdict.
docs/rights.md