gunk-dev/the-valley

dcr-de9d996-statement-text-and-signed-note.md

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