The Algebra of Encrypted Audiences
From the publisher’s feed, collected in the ZeroLabs newsroom.
Replication is topology. Readability is cryptography.A photo album, three devices, and one wrong assumptionSay you keep a family photo album synced across three machines: your phone, your laptop, and a small server at home that also backs up files for the rest of the household. All three machines end up holding the encrypted bytes of that album — the home server has to, or it couldn’t sync them. But only two people, you and your spouse, should ever be able to see the photos themselves.This is a mundane requirement. It’s also where most storage systems quietly conflate two different things: where data is stored and who can read it.If the album lives in a shared folder with permission bits, “where it’s stored” and “who can read it” are the same fact, enforced by the same mechanism, at the same layer. Move the folder to a new machine, and you’ve also moved — or lost — the access decision. Widen replication for durability, and you’ve widened, by construction, the set of processes that have to be trusted not to leak it.Engineers have spent decades building systems that separate these concerns better: row-level security in databases, IAM policies in cloud storage, capability tokens in distributed filesystems. All of them work by adding a checkpoint — a piece of logic that intercepts a read request and asks “is this caller allowed to see this?” before returning data.That checkpoint is the part worth examining closely, because it has a structural weakness that has nothing to do with how well it’s implemented.The checkpoint problemAn access-control check is external to the data. The bytes sit in storage; a separate system — a permissions table, a policy engine, an IAM role — decides whether a given request may retrieve them. This works exactly as long as every path to those bytes goes through the checkpoint.In practice, it rarely does, forever. A misconfigured storage bucket, a replica spun up without the same policy attached, a backup pipeline that copies data but not its access rules, an administrator with raw filesystem access — each of these bypasses the checkpoint without touching the data at all. The data was never actually protected; only the front door to it was.There’s a second, quieter cost. Replication and access control now have to be kept consistent with each other, across machines, indefinitely. Every new replica needs the policy re-applied. Every policy change needs to propagate to every replica before the old one is considered revoked. This is a distributed consistency problem bolted onto a security requirement, and the two rarely fail gracefully together.The underlying issue is that readability and storage location are being treated as one variable when they are actually two.Two sets, not one.me's model for this — documented in the project as the "Algebra of Contexts" — starts by naming those two variables separately, along with a third:T, the topology set — which machines or processes physically hold a piece of ciphertext.A, the audience set — which principals can actually decrypt it.P, the capability set — what operations, beyond reading, are permitted.These three sets don’t all live at the same layer, and it’s worth being precise about which one the code discussed below actually implements. The kernel — the ME class itself — is where A is concrete: it declares secret scopes, derives per-path key material, encrypts and decrypts, and fails closed on tampering. T is not a data structure inside that kernel at all. The kernel produces snapshots and encrypted branches; a separate layer of the same system decides where those bytes physically end up — replicated to a backup, synced to a second device, served from a particular node. That's an architectural fact, not a detail being glossed over: the album's three-device topology is a real scenario, but it's assembled from the kernel's output plus infrastructure outside the kernel, not modeled as a single T set inside ME. P sits in between — there is real policy metadata attached to wrapped keys, and the DSL has operations that act like capabilities, but there isn't yet a uniform algebra of read/write/delegate/revoke applied consistently across every scope. Treat P, below, as the least finished of the three.What the kernel does implement precisely is the relationship between T and A as a statement, even where T itself lives elsewhere: replicating ciphertext does not, by itself, change who can derive the key for it. A backup server, a CDN edge cache, a second device — all of them can hold copies of the bytes without ever being able to open them. Encryption does not make data disappear from topology. It changes membership in readability. A holder of the ciphertext that doesn’t hold the right key material holds nothing but bytes it cannot open — not because a policy told it no, but because the decryption itself fails.That’s worth being precise about too: this isn’t the absence of a check. Decryption is a check — it’s just one that’s fused into the act of reading, rather than a separate policy consulted before the read happens. What disappears isn’t checking; it’s the external checkpoint that can drift out of sync with the data it’s supposed to govern.Binding audience to a path, not a tableHere is where this stops being an abstract set-theory statement and becomes something concrete in .me's kernel: audience membership is declared as a structural property of a path, at write time, using a single operator: _.me.wallet["_"]("secret");me.wallet.income(100);me("wallet") // undefinedme("wallet.income") // 100 — read inside a kernel/session holding "secret"The call me.wallet["_"]("secret") registers wallet as a secret scope — internally, this commits a "secret"-tagged operation, records a redacted memory entry, and invalidates the relevant key caches, rather than writing the key material into the public memory/index surface. Ordinary values written under wallet afterward are stored through the encrypted branch/value path, using key material derived from that scope secret. me("wallet") itself returns undefined — not because the value was deleted, but because the public index the kernel maintains for ordinary reads deliberately excludes the roots of secret scopes.The second line matters as much as its output. me("wallet.income") returns 100 only because this snippet runs inside the same kernel instance that declared the scope — it already holds "secret" and can derive the matching key, a behavior the kernel's own axiom tests assert directly. A different kernel instance, or the same code running without that input, would get undefined at wallet.income too, exactly as it does at wallet. _("secret") doesn't know who your spouse is, and it doesn't grant her membership by itself. It defines what a member of A must be able to produce. Getting a second principal into A is a separate, deliberate act, and it isn't automatic just because a scope exists: she needs the scope secret, or key material derived from it, transmitted to her through some channel..me includes one concrete mechanism for that transmission, rather than leaving it as "figure it out": wrapping a secret to a specific recipient's public key, using ECDH-ES key exchange, HKDF-SHA-256 for key derivation, and AES-256-GCM for the actual encryption, tested against both correct and deliberately corrupted recipients. A scope secret wrapped this way can be handed to exactly one additional principal — your spouse's device, identified by its public key — without appearing in plaintext anywhere except her endpoint. This wrapping is a separate step from declaring the scope with _; nothing couples the two automatically. That's the difference between "audience" as a description and "audience" as something actually constructed: the algebra says A is whoever can derive the key; the wrapping mechanism is one deliberate way a second principal gets there without the secret passing through anywhere it could leak.Nesting and refinementOnce a scope exists, narrower paths beneath it inherit its requirement rather than needing a separate one:me.wallet.hidden.notes("private note");If wallet.hidden declares its own, tighter scope, wallet.hidden.notes derives its key material by chaining that scope's secret with its ancestor's — the derivation is built from the full lineage of path, scope, and any active noise boundary, not from the leaf's secret alone. The relationship wallet.hidden ⊆ wallet in the path structure produces a corresponding relationship in the audience: whoever can derive the key for wallet.hidden must also satisfy wallet's requirement, but not the reverse. Refining the path and refining the audience are the same operation, expressed once, rather than a path hierarchy and a separate permission hierarchy that have to be kept aligned by hand.Deliberately breaking that inheritanceSometimes two secrets under the same structural path should share nothing. .me provides a second operator, ~, for exactly this — it resets the derivation chain at a chosen boundary.me.wallet["_"]("alpha");me.wallet.hidden.notes("alpha-note");me.wallet["~"]("noise");me.wallet["_"]("beta");me.wallet.hidden.seed("beta-seed");After the ~ call, the kernel locates this active noise boundary and restarts key derivation from it — everything written under wallet afterward derives its key material starting from the noise value instead of continuing the previous chain. wallet.hidden.notes, written before the reset, and wallet.hidden.seed, written after, end up with genuinely different effective secrets — verified directly by the kernel's test suite, which checks that the two computed secrets are unequal. Structurally, both paths sit under the same parent. Cryptographically, they belong to unrelated audiences. The path tree and the audience relationships it implies are related, but the second is not a rigid function of the first — ~ is the escape hatch for the cases where they need to diverge.The cost of doing this at the storage layerNone of this is free, and it’s worth being direct about that, because it’s the part a system like this can’t hide behind good design.Reading or writing inside a secret scope means deriving key material and running actual encryption or decryption on every access, rather than a cheap lookup in a plain index. Benchmarks on the kernel show secret-scope reads running roughly one to two orders of magnitude slower than equivalent public reads at moderate scale — not a rounding error, a real and measurable tax. This is the honest price of making A a cryptographic property of the data instead of a policy decision made once and cached: there is no way to check “is this reachable” without the actual key derivation happening, because the check and the access are the same operation.The corollary is a genuine gain in failure mode. A tampered or corrupted secret blob doesn’t return wrong data — it fails to decrypt at all, and the kernel’s contract tests confirm this explicitly for several tamper scenarios: a flipped bit in a ciphertext, a wrong scope key, a wrong noise boundary. There is no “the check passed, and the data happened to be corrupted” state, because there is no check separate from decryption to pass.The predicates fall out for freeOnce audience and topology are separate, most of the vocabulary usually needed to describe access levels stops being a list of special cases and becomes a small number of statements about set size — with the caveat that only A is something the kernel enforces directly:A public space is one with no encryption at all — A is not a bounded set, because there’s nothing to bound.A private space has A = {self}.A shared space has |A| ≥ 2 — more than one principal, still explicitly bounded, and reached deliberately via key wrapping rather than by declaring a scope alone.A replicated space has |T| > 1 — a fact about the surrounding stack’s storage and sync layer, orthogonal to what A is.A shared, replicated, encrypted space — the family photo album, decryptable by two principals, physically present on three machines — is A = {your key, your spouse’s key} enforced by the kernel, sitting inside a T = {phone, laptop, home-server} arrangement decided above it. Nothing about T being larger than A needs a separate access mechanism; A stays exactly what it was declared to be, regardless of how the surrounding system decides to distribute the ciphertext.What this buys you, and what it costsThe practical consequence of binding audience to the ciphertext rather than to an external checkpoint is that replication and access control become genuinely independent variables — one enforced cryptographically inside the kernel, the other handled by whatever infrastructure moves bytes around it. You can widen T — for durability, for latency, for caching — without an access-control migration, because nothing about growing T touches how A is derived. You can narrow A without moving any bytes. There’s no permissions table that can drift out of sync with the data it’s supposed to govern, because there is no second table — only key material, which either derives the right secret or doesn’t.What you give up is uniform, predictable cost: every read against a member of A does real cryptographic work, every time, rather than a table lookup gated by a cached decision. You also give up convenient administrative override — there is no “admin bypass” for a scope whose key material you don’t hold, which is the point, but it does mean operational tooling has to be designed around the fact that even the person running the system cannot casually read a scope they weren’t given the means to derive.Whether that trade is worth it depends entirely on what you’re building. For data whose replication needs and whose audience needs move independently — backups, multi-device sync, anything shared with a small group but stored somewhere larger than that group — treating audience as an algebraic property of the ciphertext, enforced at the kernel that produces it, removes an entire class of consistency problems by construction, even while the question of where the resulting bytes travel is answered by a different part of the system. For workloads where cheap, uniform access and centralized administrative visibility matter more than that guarantee, the cost of doing real cryptography on every scoped read is a cost you’d be paying for a property you may not need.GitHub - neurons-me/.me: Here we're codependently creating .me while it concurrently creates us.The Algebra of Encrypted Audiences was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.