| 1 | --- |
| 2 | type: decision |
| 3 | id: dcr-de9d996 |
| 4 | status: decided |
| 5 | title: "Serialize attestation statements as canonical text and sign them as notes" |
| 6 | created: 2026-08-03 |
| 7 | source: design conversation, 2026-08-03 |
| 8 | --- |
| 9 | |
| 10 | # Serialize attestation statements as canonical text and sign them as notes |
| 11 | |
| 12 | An attestation is stored as readable statement text followed by a blank line and one signature line |
| 13 | per signer. The serialization rules determine the exact bytes covered by each signature. |
| 14 | |
| 15 | [verification.md](../../design/verification.md#statement-text) specifies the text format and |
| 16 | [signed-note envelope](../../design/verification.md#signed-notes). |
| 17 | [schema/attestation.cue](../../schema/attestation.cue) defines the statement shape. The reference |
| 18 | implementation is in [attest/text.go](../../attest/text.go) and |
| 19 | [attest/sign.go](../../attest/sign.go). |
| 20 | |
| 21 | ## Text format |
| 22 | |
| 23 | The first line identifies the statement type and version. Each later line contains a key, one space, |
| 24 | and a value. Keys are dotted paths to fields; numeric path segments identify array positions. |
| 25 | |
| 26 | The type appears only on the first line. Because signatures cover the text, that line also |
| 27 | distinguishes an attestation from another kind of document signed with the same key. |
| 28 | |
| 29 | The order is fixed: subject, predicate type, predicate content, then provenance. Each predicate type |
| 30 | defines the order of its own fields. A pure-check claim gives the check, result, and reproducibility |
| 31 | digests. An effectful claim gives the check, environment, time, and observation. The complete order |
| 32 | is in [verification.md](../../design/verification.md#line-order). |
| 33 | |
| 34 | Maps whose names are supplied by a caller, such as digest sets, sort by key. Arrays retain index |
| 35 | order. A field without a defined position is rejected. Adding a field therefore requires defining |
| 36 | its place in the versioned format. |
| 37 | |
| 38 | ## Values and empty containers |
| 39 | |
| 40 | Values are written directly, without escapes. The format rejects values containing newlines, empty |
| 41 | values, numeric leaves, empty containers, and field names containing separators such as dots or |
| 42 | spaces. |
| 43 | |
| 44 | Rejection ensures that the validated statement and signed statement contain the same information. A |
| 45 | renderer must not silently omit a value it cannot represent. |
| 46 | |
| 47 | An empty list or object would produce no lines, so it cannot be serialized. A statement that needs |
| 48 | to express a zero case must use an explicit value and omit the empty container. The schema must |
| 49 | define what that value and the omitted field mean. Otherwise it could accept statements that cannot |
| 50 | be signed. |
| 51 | |
| 52 | ## Verification uses the stored bytes |
| 53 | |
| 54 | The stored note contains the exact text that was signed. A reader can inspect it with `git cat-file` |
| 55 | or search it as plain text. |
| 56 | |
| 57 | Parsing alone is insufficient. The verifier must render the parsed statement again and require |
| 58 | byte-for-byte equality with the input. It rejects noncanonical text even when a signature over that |
| 59 | text is valid. This prevents different implementations from interpreting equivalent-looking |
| 60 | encodings differently. |
| 61 | |
| 62 | ## Multiple signatures |
| 63 | |
| 64 | Each signer signs the same statement text independently. Signature lines appear as siblings beneath |
| 65 | that text. Moving a signature to different text causes verification to fail. |
| 66 | |
| 67 | The envelope follows the signed-note format used by `golang.org/x/mod/sumdb/note` and |
| 68 | transparency-log checkpoints. The |
| 69 | [Phase 6 transparency work](../../design/roadmap.md#phase-6--trust-backstop) can therefore use the |
| 70 | same envelope family; see |
| 71 | [[ida-d2dc957]](../ideas/ida-d2dc957-attestations-ride-on-a-transparent-leaf.md). |
| 72 | |
| 73 | A signature covers the text, including its type line. It does not cover a Git object or separately |
| 74 | sign the displayed signer name. |
| 75 | [[ida-51605e8]](../ideas/ida-51605e8-authenticity-not-git-coupled.md) explains the |
| 76 | storage-independent authentication requirement. |
| 77 | |
| 78 | ## Signer names and verifier keys |
| 79 | |
| 80 | A signature line identifies a key by name and hash. A host signing name combines its fully qualified |
| 81 | host name and purpose, for example `laddie.gunk.dev/attestations`. |
| 82 | |
| 83 | The verifier-key hash includes the name and public key. Different purpose names therefore identify |
| 84 | different verifier keys even if the underlying public key is the same. |
| 85 | |
| 86 | The verifier receives an explicit set of known keys. A key outside that set does not contribute an |
| 87 | accepted signature. A signature that claims a known key but fails verification rejects the note. |
| 88 | |
| 89 | The implemented note format supports raw Ed25519 signatures. The signing key is a deployment |
| 90 | parameter. A host's `/etc/ssh/ssh_host_ed25519_key` is one possible source; this decision does not |
| 91 | require every deployment to use it. |
| 92 | |
| 93 | ## Implementation and conformance |
| 94 | |
| 95 | The helper implements the note format with `crypto/ed25519` and the Go standard library. This keeps |
| 96 | a small executable free of external module dependencies. Compatibility depends on the specified |
| 97 | bytes and conformance examples. |
| 98 | |
| 99 | [attest/conformance/](../../attest/conformance/) contains statements paired with exact serialized |
| 100 | text, valid notes including a note with two signatures, and inputs that must be rejected. The |
| 101 | `attest-conformance` check runs these fixtures. Unit tests also reproduce the published |
| 102 | sum.golang.org verifier-key hash from its name and public key. |
| 103 | |
| 104 | Fixtures describe the contract. They must not be changed merely to match a different implementation |
| 105 | output. Changing the serialization rules can invalidate signatures created under those rules and |
| 106 | therefore requires a format change. |
| 107 | |
| 108 | This decision supplies the serialization and envelope details for |
| 109 | [[dcr-0de694f]](dcr-0de694f-phase2-attestation-shape.md). The |
| 110 | [helper documentation](../../design/verification.md#the-helper) describes how they are used. |