Skip to content

[Spec] Distribution tiers, encrypted packages and issued copies #5

Open

Description

@petecleary

Affected sections

In this proposal, "part A" to "part E" are the parts of the proposed change. Spec sections are always named with
their document.

  • Package spec:
    • §1.1 The document set: a row for the new document.
    • §2 Terms: encrypted package, envelope, outline, key provider, issued copy, issuer.
    • §4.1 Properties: distribution, and the key by which a publisher allows issued copies (part C.4).
    • §6.2 What is not part of a package: no change; cross-reference from the new document.
    • §10 Attestations: the issued-copy statement.
    • §11 Capabilities: signed and reviewed on an issued copy.
    • §12 Storage and transport: a pointer to the envelope.
    • §13 Security considerations: §13.2 (stanzas are package data), §13.3 (an encrypted package is the one case
      where a holder cannot read every file), §13.5 (issued copies are not forgeries), §13.6 (new personal data).
    • §14 Versioning: new markers.
  • New document: spec/moca-encrypted-package.md.
  • Attestations:
    • §1 Scope: three statements, not two.
    • New §3a Issued-copy attestations.
    • §4 Review attestations: reviews on changed files.
    • §6 Trust roots: the issued-copy role, added to the closed roles enum.
    • §7 Verifying an attestation: two passes.
    • §8 What attestations do not prove.
  • Reader contract:
    • §3 Opening a package: envelopes and limits.
    • §4 What a Reader must never do: age plugins.
    • §7 Citation records: issued copies; L002.
    • §11 Diagnostics: the E family, the validity rule, L002.
    • §13 Degradation.
    • §14 Demonstrating conformance: optional feature encryption.
  • Reader interface:
    • §3 What the host supplies: the key provider.
    • §4 Reading: the keyProvider option and new result fields.
  • Sidecar index spec: §2 and §5.2, the encrypted index inside an envelope.
  • Schemas:
    • new moca-enc.schema.json and issued-copy-predicate.schema.json;
    • manifest.schema.json (distribution and the issued-copy consent key);
    • trust-root.schema.json (roles);
    • citation-record.schema.json (issued copies).
  • Repository files: conformance/README.md and cases, MIGRATIONS.md, CHANGELOG.md, SECURITY.md.

Problem

Today a package is either handed over in full or kept on a server and quoted. Three cases have no standard way to be
expressed:

  1. Confidential packages. Organisations exchange policies, procedures and regulated material that only named
    people, or holders of an organisation's keys, should be able to decrypt. A lost laptop or a copied file should
    not expose the content to anyone else.
  2. Packages for offline use by one licensee. A publisher wants each copy encrypted for one licensee. The issuer
    wants to be able to mark the copy, so it can recognise the copy later if it leaks unaltered, and the copy should
    still verify as the publisher's.
  3. Packages meant to be read only on a server. Hosts already do this, but a package cannot declare it, so a
    catalogue cannot tell a reader what they will get.

Each host could invent its own encrypted format. An encrypted package from one host would then be unreadable
everywhere else, and the standard would lose the portability that is its point.

Proposed change

Part A. A distribution manifest property

Property Required Meaning
distribution No How the publisher intends the package to be handed out: open (the default), encrypted-only or service-only. A label, not access control (package spec §13.3).
  • open: the package may be handed over in full.
  • encrypted-only: the package is handed over only as an encrypted package (part B). The recipients may be named
    people, an organisation's keys or one licensee. An issued copy (part C) is one use.
  • service-only: the package is meant to be read only by a host that returns citation records, not files.

A Reader reads the package exactly as if the property were absent. It exposes the value in the package result, so
a host or a catalogue can show it, or compare it with how the package was delivered. A Reader never refuses a
package because of it, and it never configures the Reader (package spec §4.5, §13.2). The property is covered by the
digest, so it is the publisher's signed intent. Changing it needs a new version.

An unknown value fails the schema, so the enum is closed. A later value needs a new minor release.

Part B. Encrypted packages (new document: moca-encrypted-package.md)

An encrypted package is a .moca archive inside an envelope. Once opened, it is that .moca archive. Every
rule of the package spec and the Reader contract then applies to it unchanged, and it gives the same digest.
Package spec §12 keeps its three forms and points here.

Sign, then encrypt. Attestations are made over the plain package, as today. They travel inside the encrypted
archive and are verified after decryption, as today.

Encryption gives confidentiality only. It does not show who made the file. Anyone who holds a recipient's
public key can make an envelope that recipient will open. Any recipient of a file can make a new file that the other
recipients will open. Provenance comes only from attestations verified after decryption. A host that opens
envelopes from more than one source SHOULD read with requireSignature.

B.1 Layout

The file is a Zip archive, conventionally named <name>.moca.enc. Every archive rule and limit in Reader contract §3
applies to it, with the same codes. It contains only these entries:

Entry Plain or encrypted Required Contents
moca-enc.json Plain Yes The format marker and the optional outline (B.2), valid against moca-enc.schema.json.
package.age Encrypted Yes The .moca archive, encrypted with age v1 (B.3). Stored, not deflated.
outline/structure.ttl Plain No A byte-for-byte copy of the inner structure.ttl. Opt-in (B.2).
index.age Encrypted No A sidecar index in its Zip form, encrypted with age v1 to the same recipients (B.8). Stored.
  • Directory entries are ignored.
  • Any other entry, including a hidden one, makes the envelope invalid.
  • So does a missing or repeated required entry, or a moca-enc.json with an unknown format. All of these are
    E005_ENVELOPE_INVALID (error).
  • A Zip with both moca.json and moca-enc.json at its root is also E005.

A Reader recognises an envelope by its content, never by its name: a Zip with moca-enc.json at its root and no
moca.json. A host source may supply an envelope only as archive bytes.

B.2 The marker and the outline

{
  "format": "moca-enc-v1",
  "outline": {
    "id": "https://example.com/moca/handbook",
    "version": "3.0.0",
    "title": "Staff handbook"
  }
}
  • format is REQUIRED and is moca-enc-v1. It changes only when this format breaks (package spec §14).
  • outline is OPTIONAL. It may carry any of these inner manifest properties, copied as JSON values: id,
    version, title, description, language, license, publisher, mocaVersion, distribution.
  • A Producer includes only what the publisher chooses. The default, and the minimum that tools write, is id,
    version and title. A Producer MAY write no outline at all.
  • outline/structure.ttl is opt-in. It reveals the package's concept graph.

The outline is unverified until the envelope is opened. Nothing signs it. Before opening, a host MAY show it,
and if it does it SHOULD mark it as unverified. A Reader MUST NOT report signed, reviewed, signers or review
status for an envelope it has not opened.

The outline check. After decryption, the Reader compares each outline property with the same property of the
inner moca.json, as parsed JSON values. A property in the outline that is absent from the manifest, or has another
value, is E004_OUTLINE_MISMATCH (error). So is an outline/structure.ttl that is not byte-for-byte equal to the
inner structure.ttl, or one present when the inner file is not.

B.3 Encryption

  • Format. package.age and index.age are age v1 files (C2SP age).
  • Recipients a Reader unwraps itself. These are X25519 and scrypt. A Reader that implements the
    encryption feature MUST unwrap both, given an identity or a passphrase from the key provider.
  • Other stanzas. Any other stanza type is data. The Reader passes it to the key provider unchanged.
  • No plugins. A Reader MUST NOT run age plugins or any other program (Reader contract §4).
  • Passphrase files. age allows an scrypt stanza only as the single stanza of a file, so a passphrase file has
    exactly one recipient. Its strength is the passphrase's: it can be guessed offline.
  • Work factor. An scrypt stanza names its own work factor. A Reader MUST refuse one above maxScryptWorkFactor
    without running scrypt (B.6).

B.4 The key provider

The host supplies a key provider with the read options (Reader interface §3, §4). A Reader opens an envelope only
through it, and never contacts anything itself.

keyProvider(request) → result, or nothing; MAY be asynchronous
  request: { stanzas: [{ type, args: [string], body: bytes }], outline: object | absent, file: "package" | "index" }
  result:  { identities: [string] }   age X25519 secret keys ("AGE-SECRET-KEY-1…")
         | { passphrase: string }
         | { fileKey: bytes(16) }     a file key the host unwrapped itself
  • The provider may be called once per encrypted entry.
  • Nothing returned, an exception, or no identity that matches a stanza is E001_ENCRYPTED_NO_KEY (error).
  • A key that was supplied but fails is E002_DECRYPTION_FAILED (error). That covers a wrong passphrase, a failed
    stanza unwrap, and a header MAC that does not verify, including against a returned fileKey.
  • An exception is never thrown to the caller.
  • The outline in the request is unverified. A key provider SHOULD choose a key by stanza type and host
    configuration, not by the outline alone.
  • A key provider MUST NOT contact, or send credentials to, an address taken from a stanza or the outline. Key routes
    come only from host configuration (package spec §13.2).

B.5 Opening an envelope

A Reader that implements encryption opens an envelope in this order. The first failure ends the read with its
code.

  1. Outer archive. Apply Reader contract §3 to the outer Zip (T003, P001–P003).
  2. Entries. Check the entry set and moca-enc.json (B.1, B.2) (E005).
  3. age header. Parse the header of package.age. A malformed or unsupported header, an scrypt stanza that is
    not alone, a work factor over the limit, or a header over 64 KiB is E006_AGE_HEADER_INVALID (error).
  4. Key. Call the key provider and unwrap (E001, E002).
  5. Header MAC. Verify it (E002).
  6. Decrypt. Decrypt and authenticate the whole payload, including the final chunk, before using any of it.
    • A failed chunk, a truncated stream or a missing final chunk is E003_PAYLOAD_CORRUPT (error), and no plaintext
      is used.
    • Decrypted bytes count against maxBytes as they are produced (T003).
  7. Inner archive. Read the decrypted bytes as a .moca archive under Reader contract §3 and §5.
  8. Outline check. Compare the outline (B.2) (E004).
  9. Attestations. Verify the inner attestations/ (attestations §7).
  10. Results. Derive capabilities and build the result.

Nothing from the inner archive (manifest, nodes, digest or attestation results) is exposed before step 8 passes.

A Reader that does not implement encryption recognises an envelope (B.1), runs steps 1 and 2, and reports E001.

B.6 Limits

These are added to the Reader contract §3 limits table:

Limit Option Default When exceeded
age scrypt work factor (log2 N) maxScryptWorkFactor 20 E006, without running scrypt
Decrypted bytes maxBytes (existing) 512 MiB T003

B.7 What stays in memory

  • A Reader MUST NOT itself write decrypted bytes to any file, including temporary files. It holds them in memory.
  • Each Reader's own tests check this by reading an envelope with a temporary directory it cannot write to. The
    corpus cannot observe it.
  • Swap, crash dumps, caches and the stores a host feeds are outside the Reader's control (B.9).

B.8 Derived data

Indexes and embeddings can reveal content, and embeddings can be partly turned back into text.

  • A Producer that builds a sidecar index for an encrypted package SHOULD put it in the envelope as index.age,
    encrypted to the same recipients. Only the Producer knows the recipients; a Reader holding one identity cannot
    learn the others.
  • A Reader binds index.age only after opening the envelope, through the same key provider.
  • A host SHOULD keep indexes it builds itself, and chats, summaries, traces and store records made from an encrypted
    package, encrypted at rest.

B.9 What encryption does not do

The new document states this list plainly:

  • Anyone who can decrypt a package can copy its content, re-encrypt it to anyone, or remove the envelope.
  • Removing distribution from a decrypted copy changes the digest, so the publisher's signature no longer verifies.
    The copy is still readable unsigned.
  • The plain part is public: moca-enc.json, the outline if any, outline/structure.ttl if included, and the
    approximate size of the package.
  • age hides who the recipients are, but not how many there are.
  • age cannot withdraw access to a file already delivered. Removing a recipient means a new file. Copies already held
    stay readable.
  • Content shown on a screen or sent to a model is plain on that device (Reader contract §12).

Part C. Issued copies (new predicate)

An issuer may mark a licensee's copy: it changes the body text of some content or media files, so that it can
recognise the copy later. Any change alters file hashes and the package digest. The publisher's package attestation
would then report A008_PACKAGE_DIGEST_MISMATCH, and reviews of those files would stop counting.

The issued-copy attestation binds the copy to the publisher's package. The Reader checks the binding itself.

{
  "_type": "https://in-toto.io/Statement/v1",
  "subject": [
    { "name": "https://example.com/moca/course@2.1.0",
      "digest": { "sha256": "<digest of this issued copy>" } }
  ],
  "predicateType": "https://w3id.org/moca/attestation/issued-copy/v1",
  "predicate": {
    "original": { "sha256": "<digest of the publisher's package>" },
    "changedFiles": {
      "content/lesson-3.md": { "original": "<sha256 of the publisher's bytes>" }
    }
  }
}

C.1 The statement

  • subject.name is the original id@version. The subject digest is the copy's computed digest. It MUST differ from
    original.
  • changedFiles MUST be non-empty. Each key is an NFC package path under content/ or media/. It MUST NOT be
    moca.json, structure.ttl, anything under sources/ or attestations/, a hidden entry, or a file a profile
    defines.
  • An issuer MUST NOT change a node's frontmatter. Frontmatter carries audience, status, validity and evidence, which
    the default policy reads. A Reader cannot check this rule: it never has the original bytes, and a file hash cannot
    be split into parts. So the rule binds issuers, and trusting an issuer means trusting it on this (C.4, C.5).
  • The copy has exactly the same set of paths as the original: no file added, removed or renamed.
  • The statement names no licensee. The issuer keeps its own record of which copy (by subject digest) went to whom.

C.2 Verification (attestations §7, two passes)

Pass 1: the issued-copy attestation. A Reader verifies it with role issued-copy (C.4), then:

  1. its subject matches the copy's id@version and computed digest;
  2. every changedFiles entry obeys C.1, and its current hash differs from its original;
  3. the Reader rebuilds the digest manifest (package spec §6.4), using each changed file's original hash in place
    of its current hash. The result MUST equal original.

Any failure makes that attestation invalid (A002). Several valid issued-copy attestations that disagree on
original or changedFiles are each A002, and none is used.

Pass 2: the publisher's attestations. With exactly one valid issued-copy attestation (or several that agree):

  • package attestations are compared with the rebuilt original digest. A008 applies only to a mismatch with it.
  • signed holds when a package attestation verifies against the rebuilt digest. signers names the publisher.
  • A review subject for a changed file never counts. It is listed in attestedReviews with fileChanged: true. So a
    copy whose reviewed files were marked is not reviewed. Issuers mark files that no review covers.
  • requireSignature is met when signed holds this way.

Without a valid issued-copy attestation, today's rules apply unchanged.

C.3 Results and records

  • Citation record. The record's package gains issuedCopy: { originalDigest, issuers }. issuers lists the
    signers of valid issued-copy attestations. A node from a changed file carries issuedChange: true.
  • Digests. package.digest stays the computed digest of the copy. A host that shares citations outside the
    licensee's own use SHOULD use originalDigest, which is the same for every copy and identifies no one.
  • Libraries (Reader contract §7). A library that holds two packages with the same id@version and different
    digests, both bound by valid issued-copy attestations to the same original, keeps the first and reports
    L002_ISSUED_COPY_DUPLICATE (info). It does not report L001.
  • Package spec §13.5 states that issued copies are the one expected case of two digests for one version, and
    that they are recognised only through a valid issued-copy attestation.

C.4 The issued-copy role

  • Trust roots gain a role, issued-copy. The role is named after the predicate, like package and review.
  • For this role, ids is REQUIRED. An entry with no ids vouches for no package. That is the reverse of package,
    where a missing ids only removes relation authority.
  • The roles enum stays closed and gains issued-copy. 0.6 Readers refuse a trust root that lists it
    (MIGRATIONS.md). This is a breaking change. We accept it before 1.0.
  • Publisher consent. An issued copy is valid only if the publisher allowed it. The publisher's manifest names the
    issuers it allows (by trust-root ids or key) and the paths they may mark (within content/ and media/). The
    manifest is never changed in a copy, so the consent is covered by the publisher's signature and checked in pass 2.
    A copy from an issuer the publisher did not name, or with a change outside the allowed paths, is refused. The
    exact shape of this manifest key will be proposed in a comment on this issue before it goes into the spec text.
  • Issuers SHOULD sign with a DSSE key. Keyless Sigstore signing would put each issue in a public log. An issuer's key
    expiry ends signed on every copy it issued, so issuers re-issue before keys expire, as publishers re-sign.

C.5 What this proves, and what it does not (attestations §8)

  • The Reader proves that the copy differs from the publisher's package only in the listed files, all under
    content/ or media/. moca.json, structure.ttl, sources/ and every other file are the publisher's bytes.
  • It cannot prove that the listed files changed only by marks in the body, nor that the marked text means the same
    as the original. That is the issuer's assertion alone. Every record from a changed file shows issuedChange and
    names the issuer, so an application can tell "the publisher's bytes" from "the publisher's bytes as changed by
    the issuer".
  • Marks may let an issuer recognise a copy that leaks unaltered. They do not survive deliberate removal, especially
    by someone who compares two copies. They are lost in paraphrase or extracted text. They identify a copy, not a
    person.
  • The original hashes in changedFiles let the holder of a copy confirm a guess at the original bytes. Hiding them
    would stop the Reader rebuilding the digest. The trade-off is accepted and stated.
  • How marks are made is out of scope. The spec defines only the binding.

Part D. Diagnostics

The new E family:

Code Severity Meaning
E001_ENCRYPTED_NO_KEY error The envelope was not opened: no key provider, no key returned, or no key matched a stanza.
E002_DECRYPTION_FAILED error A key was supplied, but unwrapping or the header MAC failed.
E003_PAYLOAD_CORRUPT error The encrypted payload failed authentication or was truncated.
E004_OUTLINE_MISMATCH error The outline differs from the decrypted manifest or structure.
E005_ENVELOPE_INVALID error The envelope has a missing, repeated or unexpected entry, an invalid moca-enc.json, or an unknown format.
E006_AGE_HEADER_INVALID error The age header is malformed or unsupported, or breaks the scrypt rules or limits.

Also new: L002_ISSUED_COPY_DUPLICATE (info). Issued-copy failures use A002.

Reader contract §11's validity rule becomes: a package is valid when it has no error in the T, P, M, C or E
families.

For each outcome, the package result is:

  • Not opened (E001): valid: false; envelope: { format, opened: false, outline }. There is no digest, no
    manifest and no nodes.
  • Failed (E002–E006): the same, with the code.
  • Opened: the normal result, plus envelope: { format, opened: true }.

encrypted is not a capability. Capabilities describe what a package contains, and every one needs core.

Part E. Conformance and versions

  • Optional feature encryption (Reader contract §14). Corpus cases that need it say requires: ["encryption"].
    A Reader without it passes the recognition cases (E001) and is run with --without encryption.
  • Issued copies are core attestation behaviour. Every 0.7 Reader implements them, because they are digest
    arithmetic over files the Reader already reads.
  • Version markers (package spec §14):
    • moca-enc-v1, in moca-enc.json;
    • predicate …/issued-copy/v1;
    • schemas stay v1, since every change only widens them.
  • Fixtures. Encrypted fixtures are committed as fixed bytes, made once with a published test X25519 key and a
    test passphrase, and never regenerated by refresh:derived. This is the same approach the Sigstore cases take with
    their self-made test CA.
  • The age test kit. Each Reader's own CI also runs the C2SP age test vectors (CCTV).

Impact

  • No existing package changes meaning. distribution is optional and defaults to open.
  • 0.6 Readers:
    • An envelope has no moca.json at its root, so a 0.6 Reader reports T002_MANIFEST_NOT_FOUND.
    • An issued copy is an ordinary package. A 0.6 Reader ignores the unknown predicate, reports the publisher's
      attestation as A008, and refuses the copy under requireSignature. That fails safe.
    • A 0.6 Reader refuses a trust root that lists issued-copy.
    • A 0.6 Reader ignores the publisher-consent key as an unknown key (package spec §4.5).
  • Readers gain:
    • the distribution value and the envelope result;
    • the E family and the new validity rule;
    • two-pass attestation verification, L002 and the citation-record fields;
    • issued-copy in the closed roles enum;
    • the publisher-consent check on issued copies;
    • optionally, the encryption feature: a key provider, age decryption for X25519 and scrypt, the opening order and
      the new limit.
  • Capabilities: none added. signed and reviewed gain the issued-copy rules (part C.2).
  • Tools:
    • moca-lint learns distribution and moca-enc.json.
    • moca-sign gains encrypt and decrypt (X25519 and passphrase recipients; outline fields by choice), and issue.
      issue compares a marked copy with the original, writes the changedFiles map and signs the statement. It does
      not mark anything.
    • moca-index can write index.age into an envelope.
  • MIGRATIONS.md: the trust-root role, the validity rule, the result fields and the 0.6 behaviour above.
  • Conformance corpus:
    • Envelopes: X25519; passphrase; minimal outline; no outline; structure copy.
    • Failure cases:
      • E001, with no provider and with a wrong-type key;
      • E002, with a wrong key and a wrong passphrase;
      • E003, truncated and with a flipped byte;
      • E004, for the manifest and for the structure;
      • E005, for an extra entry, a missing package.age, an unknown format, and both markers;
      • E006, for an scrypt stanza with another, and for a work factor over the limit.
    • Issued copies:
      • valid;
      • wrong original;
      • a right original with one wrong changedFiles hash;
      • moca.json listed;
      • an unchanged file listed;
      • an empty map;
      • an untrusted issuer;
      • an issuer outside its ids;
      • an issuer the publisher's manifest does not name;
      • a change outside the paths the publisher allows;
      • a package whose manifest allows no issuers;
      • two that conflict;
      • a review on a changed file;
      • L002.
    • The rest: distribution exposed; a trust root with an unknown role is refused.

Evidence

  • Organisations exchanging confidential knowledge (policies, procedures, regulated material) need it unreadable
    without a key. A Zip password is not adequate:
    • ZipCrypto is broken;
    • Zip AES leaves file names visible and allows offline guessing;
    • Zip encryption cannot encrypt to named people or to an organisation's keys.
  • Publishers of courses and other paid knowledge need offline use for one licensee, and a copy that still verifies as
    theirs when it is marked.
  • Without a standard, each host encrypts packages its own way, and an encrypted package stops being portable.

Alternatives considered

  • Zip AES password. Rejected; see Evidence.
  • JWE or COSE as the envelope. Both have one authentication tag over the whole payload. Large archives would need
    a chunking and truncation scheme of our own, which is the risky part to design. COSE encryption also has thin
    library support in .NET and Python. age has authenticated 64 KiB chunks with a final-chunk flag, several
    recipients, a passphrase recipient, a small frozen specification and a public test kit.
  • OpenPGP (RFC 9580, SEIPDv2). It has chunked AEAD and mature libraries. Rejected for its size: legacy modes,
    key-management baggage and many options a Reader would have to refuse.
  • A whole-file .moca.age with no outline. It is simpler, and a host could decrypt and pass bytes to today's
    Readers. Rejected as the only form, because a catalogue or library then cannot show what a file is without the
    key. Writing no outline remains possible (part B.2).
  • A signed outline. Package attestations bind the digest, not the outline, and a separate signature would only
    tell the host who wrapped the file. The outline stays unverified until it is checked against the decrypted
    manifest.
  • Encryption as a profile. Not possible. A profile lives inside the package (package spec §9), and an envelope
    wraps it.
  • distribution outside the package (in a catalogue, or in a detached statement). Possible, and a host may do
    both. Kept in the manifest so that the publisher's intent is signed and travels with every copy.
  • A diagnostic when an encrypted-only package is read plain. Rejected. A Reader cannot tell how a package
    arrived, and a service-only package is always read plain by the service it is meant for. The host compares.
  • Reusing the package role for issuers. Rejected. A package attestation says "I published exactly this". An
    issued-copy attestation lets its signer put another publisher's name on changed bytes, which is a larger power.
    It is granted separately, and scoped by ids.
  • A licensee identifier in the statement. Rejected. It would be personal data travelling in every copy, and
    linkable across one licensee's copies. The copy's digest already identifies it to the issuer.
  • Marks outside the digest (only in attestations or hidden files). Rejected. Anything outside the content can be
    stripped without touching the content.
  • Strong client protection (obfuscation, device attestation). Out of scope for a standard. See part B.9.

Delivery

Parts A and B are planned for 0.7.0. Part C is planned for 0.7.0 too, but is built last. If it is not ready, it moves
to the next minor release, and parts A and B do not change. Linked pull requests use release-0.7.0 branches.

Activity

  1. added
    spec-change
    on Nov 14, 2026
  2. added a commit that references this issue on Nov 14, 2026
  3. petecleary commented on Nov 14, 2026

    @petecleary
    ContributorAuthor

    The spec text for part B (spec/moca-encrypted-package.md, on release-0.7.0) settles five points the proposal left open. None changes the design.

    1. E001 or E002. E001_ENCRYPTED_NO_KEY is for no key provider, a provider that returns nothing or throws, or a kind of key that no stanza in the file uses (for example a passphrase for a file with only X25519 stanzas). E002_DECRYPTION_FAILED is for a key of a kind the file uses that fails: identities that unwrap no stanza, a wrong passphrase, or a header MAC that does not verify, including against a file key from the host.
    2. opened. envelope.opened is true only when the result is the inner package's normal result. Any failure in steps 1–8 of the opening order gives opened: false, including E004 and errors in the inner archive, and nothing inside is exposed. format and outline are in the result only when moca-enc.json is valid.
    3. Two more E005 triggers. E005_ENVELOPE_INVALID also covers a package.age or index.age that is deflated instead of stored, and a moca-enc.json that is not UTF-8 JSON or repeats a member name (the same rule as moca.json).
    4. Only a Zip is an envelope. An envelope is recognised only in a Zip archive given as a path or as bytes. A directory or a host source is never an envelope: one without moca.json is T002, as today.
    5. index.age failures. A Reader opens index.age through the same key provider when it binds the sidecar. A failure is reported by bindSidecar with its E code and makes the sidecar unusable. It does not change the package's validity.

    The corpus also gains cases for 1, 3 and the two-chunk payload: envelope-wrong-key-type, envelope-wrong-file-key, envelope-deflated-package, envelope-large.

  4. petecleary commented on Nov 14, 2026

    @petecleary
    ContributorAuthor

    Two additions to part B: an opt-in plain cover, and translations and tags in the outline.

    A catalogue or library that lists encrypted packages can show the outline's title before the envelope is opened, but
    no picture. #7 adds images to the manifest, with the role cover. This addition lets a Producer leave
    a copy of that cover readable in the envelope, the same way as the structure copy.

    Layout (part B.1). One more optional plain entry:

    Entry Plain or encrypted Required Contents
    outline/cover.png, outline/cover.jpg or outline/cover.webp Plain No A byte-for-byte copy of the inner package's cover image. Opt-in. At most one.
    • The extension gives the type a host may assume before opening: .png is image/png, .jpg is image/jpeg,
      .webp is image/webp. Any other outline/cover.* entry, or more than one, is E005_ENVELOPE_INVALID.
    • The copy obeys the same size limit as any image (maxImageBytes). Over it is E005.

    The outline check (part B.2). After decryption, the copy MUST be byte-for-byte equal to the file of the inner
    manifest's first images entry with role cover, and its extension MUST match that entry's type. Otherwise, or
    when the inner manifest has no valid cover, it is E004_OUTLINE_MISMATCH.

    Unverified until opened. Like the rest of the outline, the copy is not signed. A host that shows it before
    opening SHOULD mark it as unverified. Once the envelope is opened, the check proves it is the publisher's cover.

    What it reveals (part B.9). The cover becomes public, as the outline is. A Producer writes it only when the
    publisher chooses to; tools never write it by default.

    Translations and tags in the outline (part B.2). translations and tags (from the same proposal) become the
    tenth and eleventh properties an outline may carry, opt-in like the others, so a catalogue can show translated
    titles, descriptions and tags without the key.
    It is copied as a JSON value and checked against the decrypted manifest with the same rule as the other outline
    properties: any difference is E004_OUTLINE_MISMATCH. Tools never write it by default.

    Corpus: an envelope with a cover copy that matches; one whose copy differs by a byte (E004); one with a copy
    when the inner package has no cover (E004); one with an outline/cover.gif (E005); an outline whose translated title differs from the decrypted manifest's (E004).

    This depends on the images proposal. If that one does not land in 0.7.0, this addition moves with it.

  5. petecleary commented on Nov 14, 2026

    @petecleary
    ContributorAuthor

    Follow-up to the outline additions above: #7 now adds alt text for images, and the opt-in outline translations carries its per-image alt maps too, checked against the decrypted manifest like the rest (E004).

  6. petecleary commented on Nov 14, 2026

    @petecleary
    ContributorAuthor

    Part C.4: the shape of the publisher-consent key.

    Part C.4 says the publisher's manifest names the issuers it allows and the paths they may mark, and that the exact
    shape would be proposed here first. This is that proposal.

    The key

    "issuedCopies": {
      "issuers": [
        { "publicKey": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEA…\n-----END PUBLIC KEY-----\n" },
        { "sigstore": { "issuer": "https://token.actions.githubusercontent.com",
                        "subject": "https://github.com/example/issue/.github/workflows/issue.yml@refs/heads/main" } }
      ],
      "paths": ["content/lessons/", "media/images/"]
    }
    Member Required Meaning
    issuers Yes The issuers the publisher allows: 1 to 32 entries. Each is one Ed25519 key (publicKey) or one Sigstore identity (sigstore), in the same form as a trust root (attestations §6).
    paths Yes Where an issuer may mark: 1 to 256 entries. Each is a package path to a file, or a directory prefix ending in /, under content/ or media/.

    Rules

    • No key, no issued copies. A package without issuedCopies allows none. An issued-copy attestation for it is
      A002, however it is signed.
    • Both the host and the publisher must agree. The issued-copy attestation must verify against a trust-root
      entry with role issued-copy whose ids cover the package (part C.4), and its signer must be listed in
      issuers. The host decides whom it trusts; the publisher decides whom it allows. Neither alone is enough.
    • Matching a signer.
      • A DSSE key matches a publicKey entry when the two decode to the same Ed25519 key. The Reader compares the key
        bytes, not the PEM text, so line breaks and padding do not matter.
      • A Sigstore certificate matches a sigstore entry under the rule in attestations §6: issuer and subject
        equal, exactly and case-sensitively.
      • Trust-root keyid values are local to a host, so the manifest never uses them.
    • Paths. Every key of changedFiles must equal a file entry in paths, or start with a directory entry. A
      change outside them is A002. Comparison is exact, on NFC paths. The C.1 rules still apply: never moca.json,
      structure.ttl, sources/, attestations/, a hidden entry or a file a profile defines.
    • Signed consent. issuedCopies is in moca.json, which an issuer can never change (C.1). So it is covered by
      the publisher's signature, and the Reader checks it in pass 2 against the rebuilt original digest.
    • Schema. A malformed issuedCopies fails the manifest schema (M002). A paths entry outside content/ or
      media/ fails the schema too.
    • Changing consent needs a new version, signed again, like any manifest change. Copies already issued from the
      old version keep the old version's consent.

    Not a configuration key

    issuedCopies never makes a Reader contact anything or change a setting (package spec §13.2). A Sigstore identity
    in it is matched against a certificate already in the package; a key is compared with the signing key. Nothing is
    fetched.

    Corpus

    • an issued copy by an allowed DSSE issuer, marking an allowed path: signed, with issuedCopy in the record;
    • the same copy, with the issuer not in issuers (A002);
    • a change outside paths (A002);
    • a package with no issuedCopies (A002);
    • an issuer in issuers but not in the trust root with role issued-copy (A003, as for any untrusted key);
    • an issuedCopies with a path under sources/ (M002).

    Alternatives considered

    • Key fingerprints instead of keys (for example sha256: of the key). Shorter, but a new format to define, and
      publishers would copy keys from trust roots anyway.
    • Trust-root keyid values. Rejected: they are names a host chooses, not something a publisher can know.
    • Allow any issuer the host trusts. Rejected: part C.4 requires the publisher's consent.
    • Paths as glob patterns. Rejected: exact files and directory prefixes are enough, and every Reader matches them
      the same way.
  7. added a commit that references this issue on Nov 14, 2026
  8. petecleary commented on Nov 14, 2026

    @petecleary
    ContributorAuthor

    Correction to the publisher-consent comment above: an issued-copy attestation signed with a key the host's trust root does not list is A002, not A003 (attestations §7 step 7). A003 applies only when there is no trust root at all. The corpus case is issued-copy-untrusted-issuer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    spec-change

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions