stikk_model/example_keys.rs
1//! prikk's published example public keys, and the check that flags them (`C-S2`).
2//!
3//! # What this control is, and what it is not
4//!
5//! prikk's own `security-setup.md` publishes the rule:
6//!
7//! > *"Any seed or key values published in Prikk's README, quick start, docs, tests, review packages,
8//! > or issue comments are public examples. They are compromised by publication and must never be
9//! > used for real signing."*
10//!
11//! **stikk flags the ones it can enumerate, and says so rather than implying more.** That rule's own
12//! scope includes prikk's *tests* and *issue comments*, which no list can close over: a test fixture
13//! added tomorrow is a published example by that definition and nothing here would know. What is
14//! enumerable is the set published in prikk's **user-facing documentation**, which is where a person
15//! following a guide would copy one from — and copying one from a guide is the threat (`T-S2`).
16//!
17//! # By the public value, never by storing a secret
18//!
19//! Every constant below is a **public key**. `C-S2`'s own wording is *"by pattern of the public value
20//! — never by storing the secret"*, and that is literal here rather than argued: a public key is
21//! public, and `C-I1a–e` is untouched.
22//!
23//! **RFC 023 Q1's derivation route is gone, and that is why these are copied rather than derived.**
24//! Q1 resolved to derive the comparison values from prikk's *published seeds* using prikk's own
25//! `key public`, so the stored values would be captured from the binary rather than transcribed. At
26//! prikk 0.41 **there are no published seeds left in the user-facing docs** — `PRIKK_*_SEED` was
27//! retired at 0.40 and the pages that exported them were rewritten (measured: the two seeds RFC 023
28//! recorded return zero hits in `README.md` and `docs/src/` at the 0.41.0 tag). What the docs publish
29//! now is public keys directly, which removes the derivation step: the value stikk compares is the
30//! value prikk published, copied from a named file and line.
31//!
32//! **So the drift guard is provenance plus the re-baseline, not a derivation.** Each entry records
33//! where it came from and at which version. A re-baseline re-checks them the way it re-checks a
34//! captured fixture, and the sweep that finds one is
35//! `git ls-files | xargs grep -ln "<value>"`. If prikk publishes a new example key, nothing here
36//! notices — that residual drift is real, is the same one RFC 023 Q1 recorded as surviving, and the
37//! upstream letter asking prikk to name its own published values remains the fix.
38
39/// One example key prikk publishes, with where it was found.
40#[derive(Debug, Clone, Copy, PartialEq, Eq)]
41pub struct ExampleKey {
42 /// The 64-hex public key, lowercase, exactly as prikk prints it.
43 pub public_key: &'static str,
44 /// Where prikk publishes it — file and line at [`MEASURED_AT`].
45 pub provenance: &'static str,
46}
47
48/// The prikk version these were read from. **Re-check at each re-baseline**, as for any captured
49/// fixture: an example that stops being published is one stikk should stop flagging, and a new one is
50/// one stikk is not yet flagging.
51pub const MEASURED_AT: &str = "prikk 0.41.0, read 2026-09-13";
52
53/// Every example public key stikk knows prikk publishes in its user-facing documentation.
54///
55/// Read from the `0.41.0` tag. Both appear as the argument to `trust maintainer add --public-key`,
56/// which is exactly the copy-paste path `T-S2` describes.
57pub const PUBLISHED_EXAMPLE_KEYS: &[ExampleKey] = &[
58 ExampleKey {
59 public_key: "a00899dfd3357aee69729405913f9324dfc033cec04a2215239eda64ae6d9d91",
60 provenance: "prikk docs/src/guide/tutorial.md:99, and backup-restore.md:27 and :211",
61 },
62 ExampleKey {
63 public_key: "27b081593fa86489f9356ef4bc0cbf5f4a5a5b708aa1a10f1a8187fd56a34801",
64 provenance: "prikk docs/src/guide/first-run.md:265 and :269",
65 },
66];
67
68/// Whether `public_key` is one prikk publishes as an example — and so is compromised by publication.
69///
70/// Case-insensitive on the hex, because a value that reaches stikk through a user's own shell may be
71/// upper-cased; the comparison is on the value, and hex case is not part of it.
72#[must_use]
73pub fn published_example(public_key: &str) -> Option<&'static ExampleKey> {
74 PUBLISHED_EXAMPLE_KEYS
75 .iter()
76 .find(|example| example.public_key.eq_ignore_ascii_case(public_key.trim()))
77}
78
79#[cfg(test)]
80mod tests;