# OIP-0008: Signature envelope, algorithm register and crypto agility

| Field | Value |
|---|---|
| Status | DRAFT |
| Function | none added (the register keeps exactly twelve); the change is cross-cutting: §4 (objects and identifiers) and §8 (security model), used by `join`, `correct`, `orchestrate`, `prove` and `admit` |
| Affects | §4.1, §4.2, new §4.4 (SIG-1 to SIG-8), §8, §13; new schemas `signature-envelope` and `key-record`; `attestation-result` and `correction-notice` migrated to the envelope; new register `registers/algorithms.yaml` with its layout schema and validator group `algorithms`; `registers/relations.yaml` (EXT-RFC8785 extended, EXT-COSE, EXT-JWK, EXT-PQC-SIG); test vectors `conformance/vectors/signatures/`; cases CT-SITE-004 to CT-SITE-007, CT-NODE-010, CT-PROVIDER-004 |
| Protocol version | obsp/0.1 |
| Relates to | the proposals that close G-ORCH-1 (plan signing) and G-PROVE-1 (proof verifier) adopt this envelope for `plan`, `system-pack` and `proof-receipt`; OIP-0001 and OIP-0005 touch some of the same files (see `README.md`) |
| Last call | 90 days (new capability that every signing participant implements) unless the editors rule otherwise |

## Problem

The specification requires signatures in many places (the bootstrap bundle in §5.1, the plan in §5.8, the proof
receipt in §5.11, supply-chain evidence in §5.2 and §6) but defines no signature. Two schemas carry a signature
member today, and neither can be verified:

| Schema | Field today | Why it cannot be verified |
|---|---|---|
| `attestation-result` | `signature`: `algorithm` (`ED25519`, `ECDSA_P256_SHA256`, `ECDSA_P384_SHA384`), `signatureDigest`, `keyRef` (`key://` or `secret://`), `signerRole` | carries a digest of a signature, not the signature; no signed-bytes rule; `keyRef` is a local path, not a resolvable key id; the algorithm list is fixed in the schema, so a new algorithm needs a schema change |
| `correction-notice` | the same `Signature` definition | the same |

Survey of every schema in `schemas/json/` for signature-like fields (all 36 at the base of this proposal):

| Schema | Field | Plan |
|---|---|---|
| `attestation-result`, `correction-notice` | `signature` | migrated to the envelope by this proposal |
| `supply-chain-receipt` | `provenance.envelope` (`DSSE`), `provenance.ref`, `provenance.digest` | kept: SLSA provenance stays a DSSE-signed in-toto statement (SIG-7); a receipt that needs its own signature takes the envelope with `format` `DSSE` in a later revision |
| `attestation-evidence` | `rootOfTrust.secureElement.attestationSignatureDigest` | out of scope: the digest of the attester's hardware attestation signature, appraised by the verifier under RFC 9334, not a protocol signature |
| `plan`, `system-pack` | none (a `signature` member is refused today: `additionalProperties` is false) | the proposal that closes G-ORCH-1 adds the member; register class `plan`, marked `planned` |
| `node-bootstrap-bundle` | none | a later proposal for §5.1 adds the member; class `root`, `planned` |
| `proof-receipt` | none | the proposal that closes G-PROVE-1 adds the member; class `receipt`, `planned` |
| `observed-state-receipt`, `decommission-record` | none | later proposals for §5.8 and §5.12; class `receipt`, `planned` |
| `observation-record`, `event-envelope` | none | optional member when a node profile requires signed observations; class `observation`, `planned` |
| all other schemas | none | not signed objects |

There is also no algorithm register, so no way to deprecate an algorithm, to introduce post-quantum signatures, or to
say which objects need which strength.

## Change

### Normative text (new §4.4 "Signatures and algorithms", summarised; the exact text is in `patches/spec.patch`)

Every signed object carries one envelope as its top-level `signature` member, defined once in
`signature-envelope.schema.json` and copied unchanged into each schema that uses it.

1. **SIG-1 Coverage.** A participant conforming to `OBSP-SITE` or `OBSP-GRID` MUST sign every object it issues whose
   register class is consequential (`root`, `plan`, `receipt`) and whose schema carries the member; a receiver MUST
   NOT act on such an object without a valid signature. Observations SHOULD be signed.
2. **SIG-2 Envelope and canonical form.** COSE_Sign1 (RFC 9052 §4.2) with a detached payload. The payload is the
   RFC 8785 (JCS) canonical form of the object without its top-level `signature` member; `payloadDigest` is the
   digest of those bytes. The protected header is a deterministically encoded CBOR map (RFC 8949 §4.2.1) with label 1
   (alg, the register's code point) and label 4 (kid, the UTF-8 bytes of `kid`); the signature is over Sig_structure
   (RFC 9052 §4.4) with empty external data.
3. **SIG-3 Register.** `alg` names a row of `registers/algorithms.yaml`; label 1 carries its fully-specified code
   point (RFC 9864). Verifiers MUST reject unknown (`OBS-SIG-0001`) and deprecated (`OBS-SIG-0002`) algorithms, and
   provisional ones unless enabled for testing (`OBS-SIG-0007`).
4. **SIG-4 Minimum per object class.** The algorithm MUST be one the object's class accepts (`OBS-SIG-0006`). From
   `obsp/0.5`, `root` and `plan` objects MUST use a composite algorithm. Observations MAY use Ed25519 or ES256.
5. **SIG-5 Key ids.** `kid` is a key record UNI (`uni:key:...`) or the RFC 7638 SHA-256 thumbprint as an RFC 9278
   URI; a key record binds one key to one algorithm; verifiers resolve it inside their own trust domain (SOV-1) and
   reject unresolvable, revoked or algorithm-mismatched keys (`OBS-SIG-0003`).
6. **SIG-6 Agility.** Algorithms are configuration; changing the signing algorithm needs no schema change; every
   verifier verifies the `required` algorithms (Ed25519, ES256).
7. **SIG-7 Supply chain.** SBOM and SLSA provenance MAY stay DSSE-signed in-toto statements; an envelope with
   `format` `DSSE` references the DSSE envelope and follows SIG-3 to SIG-5. No other object is DSSE-signed.
8. **SIG-8 Rejection.** Verifiers MUST reject a digest mismatch (`OBS-SIG-0004`), a failed signature
   (`OBS-SIG-0005`) and a malformed or inconsistent protected header (`OBS-SIG-0008`), and report the code.

Also: §4.1 gains the rows "Algorithm id" and "Key id"; §4.2 gains SignatureEnvelope and KeyRecord; §8 gains a "Signatures" row; §13 replaces "a hybrid post-quantum mode is on the roadmap" with
the SIG-4 requirement; the header's Registers row names `registers/algorithms.yaml`.

### Contract: `signature-envelope` (schemaVersion of the enclosing object)

| Property | Required | Shape |
|---|---|---|
| `format` | yes | `COSE_Sign1` or `DSSE` |
| `alg` | yes | algorithm id (pattern only; the register, not the schema, lists the ids, so SIG-6 holds) |
| `kid` | yes | `uni:key:<local>` or `urn:ietf:params:oauth:jwk-thumbprint:sha-256:<43 base64url>` |
| `canonicalization` | yes | `JCS` |
| `payloadDigest` | yes | Digest |
| `protected`, `signature` | with `COSE_Sign1` | unpadded base64url |
| `dsse` | with `DSSE` (and refused otherwise) | `{uri, digest}` |
| `x5chain` | no | base64url DER certificates (RFC 9360), informative |
| `receipt` | no | `{format: SCITT, uri, digest}` |
| `signerRole` | no | protocol role, advisory and unprotected; `attestation-result` requires `VERIFIER` as before |

`attestation-result` and `correction-notice` replace `$defs.Signature` with `$defs.SignatureEnvelope` and require
`format` `COSE_Sign1`.

### Contract: `key-record`

`keyUni`, `alg` (one algorithm), `publicKeyJwk` (OKP Ed25519, EC P-256 or P-384, or AKP ML-DSA per RFC 9964 §3; private
members refused), optional `thumbprint`, `controller` (`role`, `uni`), `objectClasses`, `custody`, `status`
(`ACTIVE`, `ROTATED`, `REVOKED`; `REVOKED` needs `revokedAt`), `validFrom`, `validUntil`, `testOnly`, `recordedAt`.
The schema binds the JWK type to the algorithm.

### Register `registers/algorithms.yaml`

| Id | Family | Status | COSE code point carried (label 1) | Standard | Vectors |
|---|---|---|---|---|---|
| `ed25519` | classical | required | -19 Ed25519, fully specified (RFC 9864 §2.2); polymorphic -8 EdDSA refused | RFC 8032 §5.1 | yes |
| `es256` | classical | required | -9 ESP256 (RFC 9864 §2.1); polymorphic -7 ES256 refused | FIPS 186-5, P-256 | yes (verify-only) |
| `es384` | classical | allowed | -51 ESP384 (RFC 9864 §2.1); polymorphic -35 refused | FIPS 186-5, P-384 | no |
| `ml-dsa-44`, `ml-dsa-65`, `ml-dsa-87` | post-quantum | allowed | -48, -49, -50 (RFC 9964) | FIPS 204, pure, empty context | ML-DSA-65 (verify-only) |
| `slh-dsa-sha2-128s` | post-quantum | provisional | none recorded | FIPS 205 | no |
| `ml-dsa-65-ed25519` | composite | provisional | none recorded | IETF LAMPS composite ML-DSA draft (not checked) | no |
| `rs256` | classical | deprecated | -257 (RFC 8812) | RFC 8017 §8.2 | rejection vector only |

Object classes: `root` (`node-bootstrap-bundle`) and `plan` (`plan`, `system-pack`) accept classical, ML-DSA and
composite algorithms and require the composite family from `obsp/0.5`; `receipt` (`attestation-result`,
`correction-notice`, `proof-receipt`, `observed-state-receipt`, `decommission-record`) accepts classical and ML-DSA;
`observation` (`observation-record`, `event-envelope`) accepts `ed25519` and `es256`. Each schema row says whether its
signature member is `present` or `planned` (with the proposal that adds it). Every row has a `sunset` field; the
classical rows carry a proposed deprecation at the end of 2030 and disallowance at the end of 2035 (basis: the NIST IR
8547 initial public draft, `checked: not checked`), for the editors to confirm or change.

Validator group `algorithms` (in `tools/validate.py`, tested): layout against `registers/algorithms.schema.json`;
unique ids and COSE code points; composites with one classical and one post-quantum component; required and
recommended rows have vectors; object classes accept only registered, non-deprecated ids and at least one of a
required family; every listed schema exists and its `present`/`planned` mark matches the schema; every schema with a
`signature` member uses `$defs/SignatureEnvelope` and is listed; every copy of the envelope (and of the `Digest` and
`ProtocolRole` definitions it uses) equals `signature-envelope.schema.json`.

### Test vectors (`conformance/vectors/signatures/`)

Four test keys derived from public labels (Ed25519 ×2, P-256, ML-DSA-65 from a FIPS 204 seed), published with their
private parts in `keys.json` and marked `testOnly` everywhere. Each vector gives the object, its JCS bytes, the
protected header (bytes and diagnostic form), Sig_structure, the tagged detached COSE_Sign1, and the expected result:

| File | Valid | Invalid (code) |
|---|---|---|
| `ed25519.json` | correction notice; attestation result (deterministic, exact bytes) | tampered payload (0004); tampered with digest recomputed (0005); wrong kid (0005); unresolvable kid (0003); polymorphic code point (0008); header kid mismatch (0008); classical signature on a `plan` at `obsp/0.5` (0006) |
| `es256.json` | correction notice, thumbprint kid (RFC 6979 nonces; verify-only) | tampered (0005); key bound to another algorithm (0003) |
| `ml-dsa-65.json` | correction notice (hedged signing; verify-only) | tampered (0005); ML-DSA on an `observation` (0006) |
| `algorithms.json` | none | deprecated `rs256` (0002); unknown id (0001); provisional composite not enabled (0007) |

The installed `cryptography` 50 provides ML-DSA-44/65/87, so ML-DSA-65 vectors are real. No composite vector is
published: the composite draft and its code points are not final, so the register row is a provisional placeholder.

`obsp signatures check-vectors` (run by `make check`) recomputes every published byte string and checks each result.
The reference verifier (`sdk/python/src/obsp/signatures.py`) implements CBOR, Ed25519 and ECDSA P-256/P-384 in plain
Python, so the required algorithms need no cryptographic package; ML-DSA is verified through the optional
`cryptography` package and reported as skipped, never passed, without it. `tools/gen_signature_vectors.py` regenerates
the vectors and the example signatures and is idempotent.

## Compatibility

Breaking for two objects: `attestation-result` and `correction-notice` documents with the old `signature` summary no
longer validate (negative fixture `attestation-result.legacy-signature-summary`). The old summary held no verifiable
signature, so no verification is lost; producers re-sign under the envelope. Under §10 a breaking contract change needs
a new `schemaVersion`; the patches keep `3.1.0` for review and the editors decide whether this change waits for, or
sets, the next `schemaVersion` (Open questions). Everything else is additive: two new schemas, a new register, new
cases. No function is added.

## Tests

| Requirement | Case | Kind |
|---|---|---|
| SIG-1, SIG-2, SIG-8 | CT-SITE-004 (SITE, GRID) | invariants `consequential-objects-signed`, `signature-envelope-binding`, `signature-verifies` over the example attestation result (Ed25519, UNI kid) and correction notice (ES256, thumbprint kid) |
| SIG-3, SIG-4 | CT-SITE-005 | invariant `signature-algorithm-registered` |
| SIG-5 | CT-SITE-006 | invariant `signature-key-resolvable` over the example key records |
| SIG-3, SIG-6, SIG-8 | CT-SITE-007 | manual: every vector gives its result; signing algorithm switched by configuration |
| SIG-3, SIG-5, SIG-8 (node side) | CT-NODE-010 (NODE, SITE, GRID) | manual: the node's verifying path accepts and refuses the vectors before any state change |
| SIG-7 | CT-PROVIDER-004 | manual: DSSE envelopes with registered algorithms and resolvable key ids |
| SIG-2 to SIG-5, SIG-8 | `obsp signatures check-vectors` | 18 vectors: 4 valid, 14 invalid |

Negative fixtures: `signature-envelope.cose-without-protected`, `.cose-without-signature`, `.padded-signature`,
`.kid-not-a-key`, `.missing-payload-digest`, `.not-jcs`, `.unknown-format`, `.inline-private-field`,
`.dsse-with-cose-fields`; `key-record.private-key-included`, `.revoked-without-time`, `.algorithm-key-mismatch`,
`.unknown-object-class`, `.kid-not-key-uni`; `attestation-result.legacy-signature-summary`;
`correction-notice.dsse-envelope`. The 16 existing negative fixtures of the two migrated schemas are re-signed and still
fail only for their own rule. Unit tests: 22 in `sdk/python/tests/test_signatures.py` (CBOR known answers from RFC 8949
Appendix A, plain verifiers against an independent library, vectors, checker faults, each invariant failing on one
fault) and 9 validator tests in `tests/test_validate.py`.

## Open questions

1. `schemaVersion`: does the migration of `attestation-result` and `correction-notice` bump `schemaVersion` now, or
   ride with the next breaking release?
2. Sunset dates for the classical rows (2030 deprecation, 2035 disallowance) follow the NIST IR 8547 initial public
   draft as read from secondary knowledge (`checked: not checked`). The editors set or remove them.
3. Composite target: the LAMPS composite ML-DSA draft, its ML-DSA-65 with Ed25519 combination and any COSE code point
   are not final (`checked: not checked`). Should `obsp/0.5` instead accept ML-DSA alone for roots and plans if the
   composite is not final by then?
4. Should a verifier accept the polymorphic code points (-8, -7, -35) for interoperability with existing COSE stacks?
   This draft refuses them, following their Deprecated mark in the IANA COSE Algorithms registry.
5. Key records: is `key-record` the right home for key resolution, or should SIG-5 point to the identity issuer
   (X.509 SVIDs, §5.1) with `x5chain` authoritative?
6. Not checked against the source: the DSSE envelope specification identifier, RFC 9278 and RFC 7638 clause numbers,
   RFC 8037 and RFC 7518 sections, FIPS 186-5 and NIST SP 800-186 section references, and the SLH-DSA COSE draft. The
   IANA COSE Algorithms registry (for -7, -8, -9, -19, -35, -48 to -51, -257) and RFC 9964 (AKP key type, thumbprint
   members, empty context) were read when the register was written.

Acceptance needs appointed editors and a last-call window. Until then this proposal stays at DRAFT and the live tree
keeps its current signature members.
