Expand description
Shared trust-roots TOML file model.
Three call sites read/write the same [[trust_root]] file format:
mkit trust {add,list,remove} (commands/trust.rs), mkit verify --trusted/--trust-roots (commands/verify.rs), and mkit verify-attest --trust-roots (commands/verify_attest.rs). This
module owns the parser, the writer, and the repo-local path-fencing
policy so none of the three grow a second trust-file format
(issue #693).
Grammar (a strict subset of TOML):
[[trust_root]]
keyid = "ed25519:..."
kind = "ed25519"
pubkey_hex = "..."kindis one ofed25519,secp256k1(aliassecp256k1-sec1),p256-sec1(aliasp256), orbls12381-thr. Anything else is ignored.algorithmis accepted as an alias forkind(perdocs/specs/SPEC-RELEASE-THRESHOLD.md); either field name works.pubkey_hexis the raw public key bytes in lowercase hex. Forbls12381-thr, the bytes are the 96-byte G2 compressed aggregated cohort public key (theMinSigvariant).
Lines outside a [[trust_root]] block, comments (#), and blank
lines are ignored. A missing file parses to zero entries — the
caller’s documented “no trust-roots configured” UX.
Structs§
- Trust
Entry - One validated
[[trust_root]]block: hex-decoded is deferred to the consumer (registry build / commit-signer compare) so callers that only need to list or rewrite the file never touch key bytes.
Functions§
- default_
trust_ roots_ path - Resolve the user-scoped default trust-roots path:
$XDG_CONFIG_HOME/mkit/trust-roots.toml. - find_
ed25519_ signer - Does
entriescontain a liveed25519trust root whose pubkey bytes equalsigner? Used bymkit verify --trustedto cross-check a commit/remix/tag’s embeddedsignerfield — commit signing is Ed25519-only today (issue #693 implementation notes). - hex_
decode - keyid_
matches_ pubkey - Cross-check (#223) that
keyidis consistent with the declared public key bytes. The canonical keyid shape is<prefix>:<body>: - load_
entries - Load and parse the trust-roots file at
path. A missing file parses to an empty list (not an error). - load_
registry - Load the trust-roots file at
pathinto anmkit-attestRegistry, for DSSE attestation verification (mkit verify-attest). - note_
if_ missing - Print a hint (not an error) when a trust-roots path passed a safety check but the file doesn’t exist yet. An empty registry means every signer check will fail closed; the caller’s own report loop covers the substance, this is just so a first-time user isn’t left wondering why nothing verified.
- parse
- Parse every
[[trust_root]]block intext. Blocks with missingkeyid/pubkey_hex, unparsable hex, or a keyid/pubkey mismatch (#223) are dropped with a stderr note rather than surfaced as a hard error — matchesverify-attest’s tolerant-parser policy. - save
- Write
entriestopath, creating parent directories as needed. - serialize
- Serialize
entriesback to the[[trust_root]]file grammar. Round-trips throughparse(modulo comments — this rewrites the whole file, so any hand-added comments in a filemkit trustsubsequently edits are NOT preserved). - short_
keyid - Shorten a keyid for display:
<prefix>:<first-16-hex>…. - warn_
if_ unsafe_ trust_ roots - Refuse to operate on an in-repo trust-roots file unless the user
passed
--trust-rootsexplicitly. Without this gate, a hostile cloned repo could ship<repo>/.mkit/trust-roots.tomllisting attacker keys and a trust-consuming command would trust it implicitly. Seedocs/THREAT-MODEL.md§5 “Trust-roots scope”.