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:

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.

  1. 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, pays price_per_epoch * epochs to the treasury in the same transaction (a chained native-token transfer), and the program sets paid_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."
  2. 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.

  3. 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

How it works operationally (who is online, who waits for what)

Do LEZ private transactions help?

Mostly no for this design, and in part they conflict with it:

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):

Alternatives considered

Open questions

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.

Rendered from REPORT.md. Raw evidence alongside: timeline.txt, log.jsonl, sequencer-rejections.log, harness/.