0010. Private repos gated by a LEZ membership program
Status: proposed (2026-10-27). Prototype built and run end-to-end — see vpavlin/backpack-access.
Extends: 0009 — Private repos: a read key in the link (unchanged below the read key).
Context
ADR 0009 made a repo private by putting one 32-byte read key in the backpack:// link: the link
is a capability — share the link, share the repo. That is simple and needs no server, but it has hard
limits:
- No revocation. Anyone who ever saw the link reads the repo forever.
- No paid or time-bound access. There is no notion of "a current, paying member."
- No per-reader control. The key is the same for everyone and travels out of band.
We want a repo whose read key is delivered only to whoever is a paid, current member, with access that can lapse — while the content itself stays encrypted on Logos Storage exactly as in ADR 0009. The membership and payment should be verifiable by anyone, on-chain, on a Logos Execution Zone (LEZ).
The constraint that shapes everything
A LEZ program cannot keep a secret. On-chain state is public (any getAccount reads it); even a
private LEZ account is encrypted only to its own owner. So a program cannot hold the read key and
hand it out.
The realization that dissolves the problem: a wrapped key is already ciphertext. If the daemon encrypts the read key to a member's public key, the resulting blob is safe to publish in the clear — only that member's private key unwraps it. So the chain never needs to carry a secret at all.
Decision
Split the system into an on-chain membership registry and off-chain key wrapping.
-
On-chain: a SPEL membership program (
backpack_access). A public, verifiable registry.ConfigState(anchor):admin,treasury,price_per_epoch,epoch_len_ms.MembershipState(one PDA per member):x25519_pubkey,paid_through_ms,tier,owner.register(x25519_pubkey, epochs)— the member signs, paysprice_per_epoch * epochsto the treasury in the same transaction (a chained native-token transfer), and the program setspaid_through_ms = clock.now + epochs * epoch_len_ms.renew(epochs)extends it.- Expiry is a derivation, not a transaction:
active = paid_through_ms > now. No keeper. - The program holds no key and no secret. It only answers "is this pubkey a paid member, through when."
-
Off-chain: the publisher's daemon wraps keys. Each epoch it reads the registry, computes the active set, and wraps that epoch's read key to every active member's X25519 pubkey. It publishes the wrapped blobs openly in a key-bundle file on Logos Storage; the encrypted index header points at that file's CID. A lapsed member is simply not wrapped for the next epoch.
-
Phone (reader). Derives its X25519 keypair from its Loam identity, fetches the key-bundle, finds its entry, and unwraps → the epoch read key. From there it is exactly ADR 0009: decrypt the index, read each file's key, decrypt the APK. No secret ever touches the chain.
Wrap format
Over the 32-byte read key, using Backpack's AES-256-GCM house cipher (ADR 0009):
ephemeral X25519 keypair
shared = ECDH(eph_sk, member_pk)
key = HKDF-SHA256(ikm = shared, salt = none, info = "backpack/keywrap/1")[0..32]
nonce = 12 random bytes
aad = repo_key (32) || member_pk (32) || epoch (u64 little-endian) # binds the blob to repo + member + epoch
ct = AES-256-GCM(key, nonce, read_key, aad)
blob = eph_pk (32) || nonce (12) || ct (32 + 16 tag) # 92 bytes
Key-bundle on Storage: { "v": 1, "epoch": N, "repo_key": "<b64url>", "wrapped": { "<member_pk b64url>": "<blob b64url>", … } }.
The AAD binds the repo key, the member key, and the epoch: a blob cannot be replayed to another repo,
another member, or another epoch.
Epochs align with read-key rotation
Backpack already rotates a repo's read key by re-encrypting the index (ADR 0009, --rotate-read-key).
Tie the membership epoch to that rotation: each epoch has its own read key, and the daemon only wraps
epoch N's key for members active in epoch N.
Consequences
- Forward exclusion is the security model. A member who lapses keeps the keys for epochs they paid for (old content they could already read), but is not wrapped for future epochs — so new content, encrypted under the new epoch key, is out of reach. There is no cryptographic clawback of already-seen content; that is inherent to any key-epoch scheme.
- The publisher's daemon must be online to wrap for a newly-registered member; access latency is one wrap cycle. (Removing this needs threshold / proxy re-encryption — see Alternatives.)
- Membership is public by default (the registry is on-chain). Registering under a pseudonymous X25519 pubkey not linked to identity gives reasonable unlinkability without any private state.
- No secret is ever on chain; publishing wrapped blobs openly is correct, not a leak.
- Payment and revenue live on LEZ (native asset to the treasury); the publisher can read who paid.
- Everything below the read key is unchanged from ADR 0009 (index/file encryption,
bpe1chunking, signing, the plaintext checks). This ADR changes only how the read key reaches a reader.
How it works operationally (who is online, who waits for what)
-
The publisher's daemon is a periodic job, not a 24/7 hot server. It must run often enough to (a) add wrapped keys for newly registered/renewed members and (b) publish each epoch's key-bundle. If it is down, existing members holding the current read key keep reading current content; only new members and new epochs are delayed until it runs again.
-
Communication is index-and-publish, not per-member delivery. The daemon polls the LEZ membership program's
MembershipStateaccounts (no SPEL event emission at this rev), computes the active set, wraps the epoch read key for each active member, and writes a key-bundle file to Logos Storage. The encrypted index header points at that file's CID, and the pointer is announced over Delivery (ADR 0009). Keys are pull-from-Storage files, never pushed to each member. -
The member never has to be online at a particular moment — the flow is pull-based:
- Register/renew on LEZ and pay (online once, briefly).
- The daemon, on its next cycle, adds the member's wrapped key to the bundle — latency = one daemon cycle; the member can be offline for this.
- Read anytime: fetch the current bundle, unwrap the member's entry, decrypt the index and files.
- On epoch rotation (new read key / new content), the daemon publishes a new bundle; the member picks it up whenever it next syncs — no need to be online at rotation time.
The only wait is the one-time gap between registering and the daemon's next wrap cycle; after that it is ordinary pull-based sync.
Do LEZ private transactions help?
Mostly no for this design, and in part they conflict with it:
- What a member reads is already private. The chain never sees which repo/app is decrypted; reading is a Storage fetch of the key-bundle + CIDs and a local unwrap. "What you access" is private regardless of private execution.
- What is public is the membership record and the payment (the member's X25519 pubkey + its
paid_through_ms, and a payment to the treasury). The cheap privacy lever is to register under a pseudonymous pubkey unlinked to identity — this hides who the member is, with no private execution. - Private LEZ execution conflicts with the daemon model. The daemon must read the membership
registry to know whom to wrap for; a membership held in a private (owner-encrypted) account is
invisible to it. To make the subscription itself unlinkable (hide that a payment/membership
happened),
registerwould have to prove a shielded payment — a ZK proof binding a hidden payment to the membership. That is possible in principle but heavy, and is deferred (the anonymous-credential / threshold direction). - Net: a pseudonymous pubkey covers most of the practical privacy need today; fully private pay/subscribe is an open research item, not a quick win.
Funding privacy — what v0.2.5 actually provides (measured 2026-10-27)
Validated live on v0.2.5-rc2 (a shield → deshield-to-fresh → register run, inspect-verified at each hop):
- v0.2.5 has a real, Zcash-style pooled shielded layer — one global commitment Merkle tree and a
shared nullifier set across all private accounts; a private account's id is never written on-chain
(only opaque nullifier / root / commitment / ciphertext tuples, padded to 7 slots per tx to hide even
the count of real private actions). It's reached from the ordinary
wallet auth-transfer sendby usingPrivate/prefixes on--from/--to. The full flow works: shield public→private, deshield to a brand-new public account, then a normal publicregisterfrom it. - But the shield and deshield public legs are cleartext and co-transacted. In the run, exactly 500000000 left a public account at block 501 and exactly 500000000 arrived at a fresh public account at block 506 — trivially correlatable by amount + timing, no matter how well the pool hides the private intermediary. This is inherent to any shield/deshield boundary (Zcash's t↔z legs have it too), not a LEZ flaw.
- Consequence for the optional funding-privacy path: a naive "shield X → immediately deshield X to a
fresh account → register" leaks the link by amount+timing — false privacy. To make it real the funding
path MUST (a) use standard denominations — deshield a fixed round amount decoupled from
price*epochsso the amount doesn't fingerprint — and (b) add a delay / batching between shield and deshield so timing doesn't correlate. Build it deliberately, or don't advertise privacy. - Net: the pool genuinely hides who and how many members exist; it does not by itself hide a lone, same-amount, same-moment shield→deshield.
- Caveat: a dev-mode (
RISC0_DEV_MODE=1) functional run — the privacy guarantee ultimately rests on a real ZK proof, which this run did not generate.
Alternatives considered
- Read key in the link (ADR 0009). Kept for public-ish sharing; it just can't do revocation or paid, time-bound access. This ADR is the paid/revocable path, not a replacement.
- Write the wrapped key into the member's own (private) LEZ account. Unnecessary — the wrapped blob needs no privacy. Private LEZ accounts would only hide the membership list, which is complex and uncertain on current LEZ; a pseudonymous pubkey is the cheaper privacy lever.
- Threshold / proxy re-encryption by a committee. Removes the online-publisher requirement (the committee re-wraps for new members without the publisher's key online). Heavier; deferred.
Open questions
- Membership-list privacy (beyond pseudonymous pubkeys).
- Offline publisher via proxy re-encryption.
- Tiers, grace period, refund-on-close, over-payment handling.
- Structured on-chain events once the SPEL macro layer exposes emission (today the daemon polls
MembershipState— the SPEL macros expose no author-facing event emission at spel v0.7.0-rc.3, even though rawlee_corehasProgramEvent+ indexergetEvents). - Production LEZ version: the prototype runs on v0.2.5 (where the signer-claim trap that bit v0.2.4 is fixed, so a fresh member registers and pays in one tx); the v0.4 actor model is the later target.
Prototype
vpavlin/backpack-access — wrap-demo/ (off-chain wrap/unwrap, runs) and program/ (the
backpack_access SPEL program, built + deployed + run end-to-end on LEZ v0.2.5, with the generated CLI
and a full transcript). Inspect-verified: a fresh default-owned member registered and paid 3000 to the
treasury in one transaction and got its MembershipState PDA; renew extended expiry by exactly two
epochs.
A gotcha the prototype encodes
A chained call must declare every account it touches as an instruction account — not merely read it from another account's data. Naming an undeclared account as a chained-call pre-state produces a transaction that reports "confirmed" but is a silent no-op (nonce bumped, fee charged, zero state change). On LEZ, "confirmed" ≠ "did anything"; verify by reading state back.