government

commit ce159ec40272fb3caed2436702b1426f1550e47d

tree

parent:
26a72779eff9f25b53bae86607e9e4f6cd54934d

nmyk <nick@nmyk.io>

2026-11-14T20:59:45-05:00

small changes to verify

certificate of ratification default key text
make depth text singular for only 1 cert

diff --git a/DESIGN.md b/DESIGN.md
index e523e6027e1415b7261daf57c85ddc18d40284c1..b3a22ac612922b5c817a2ee5b3ef0a515b48f6c6 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -445,7 +445,7 @@ - The keys for certs 1..n are derived from the author key: seed for depth *i* = SHA-256(author seed ‖ "GOVERNMENT" ‖ i). Output stays byte-for-byte deterministic, and the key holder alone can rebuild the chain or sign repeals.
 - Any changed byte breaks a signature: `E-TAMPERED: clause at depth 2 fails signature check`. Amending a program means re-ratifying it.
 - `--anchor` pins a public key, not a whole cert. It accepts a cert or a public key PEM and compares SubjectPublicKeyInfo. A re-ratified program with new dates or text still matches its author's pin.
 - `government verify` prints a certificate of ratification: author, key fingerprint (SHA-256 of the SPKI), window in force, depth and node count.
-- Without `--key`, the default seed is public, so anyone can forge, amend or repeal. `verify` says so: `ratified by nobody in particular (default key)`.
+- Without `--key`, the default seed is public, so anyone can forge, amend or repeal. `verify` says so, naming the ratifier as `Public (Default Key)`.
 
 ## Design decisions
 
diff --git a/PLAN.md b/PLAN.md
index 4b78842a379855cda5ef673497786365937c7523..7ff5890b3de9ef96347cd1b8fc3bbcb83426dbc4 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -203,7 +203,7 @@     - Build: the reader keeps comments and attaches each to the form on the next line or the form it trails; the certificatePolicies encoder adds user-notice qualifiers (`1.3.6.1.5.5.7.2.2`), splitting text over 200 characters; a raw-extension decoder reads them back; `tree`, errors and `decompile` show them.
     - Learn: policy qualifiers and why relying parties may ignore them (they never affect validation); working with extension bytes Go parses only partly.
     - Done when: a 450-character comment survives compile → decompile intact, and an error inside a noted form prints its note.
 34. **Authorship** (`lisp2gov`, `cmd/government`)
-    - Build: `--key` (Ed25519 PKCS#8), `--author "Name <email>"` into the anchor subject and subjectAltName, per-depth key derivation SHA-256(seed ‖ "GOVERNMENT" ‖ i), the `--effective` and `--expires` flags; `verify` reports "ratified by nobody in particular" for the default seed.
+    - Build: `--key` (Ed25519 PKCS#8), `--author "Name <email>"` into the anchor subject and subjectAltName, per-depth key derivation SHA-256(seed ‖ "GOVERNMENT" ‖ i), the `--effective` and `--expires` flags; `verify` names the ratifier "Public (Default Key)" for the default seed.
     - Learn: private keys, PKCS#8, and key derivation; why the default seed being public makes every default-built program forgeable.
     - Done when: two authors' builds of one source differ only in keys and names, each verifies with its own `--anchor` pin, and neither verifies with the other's.
 35. **Writing repeals** (`cmd/government`)
diff --git a/cmd/government/author_test.go b/cmd/government/author_test.go
index 7a31c000d0608f550adaac70effeadf3191cdc0a..2e2ccc4ae9df15f4b412b8102d8b8b0e62b7fd6f 100644
--- a/cmd/government/author_test.go
+++ b/cmd/government/author_test.go
@@ -59,7 +59,7 @@ 	if !strings.Contains(stdout, "Ratified by  Ada Lovelace <ada@example.com>\n") {
 		t.Errorf("certificate:\n%s", stdout)
 	}
 	_, stdout, _ = runCmd("verify", compileTo(t, dir, "anon", "1"))
-	if !strings.Contains(stdout, "nobody in particular (default key)") {
+	if !strings.Contains(stdout, "Public (Default Key)") {
 		t.Errorf("default key not reported:\n%s", stdout)
 	}
 }
diff --git a/cmd/government/verify.go b/cmd/government/verify.go
index 6cc29182c95b87ff260966ba96385094f1905896..4c822b62ca599101749b94246e2ad2305a47bdfb 100644
--- a/cmd/government/verify.go
+++ b/cmd/government/verify.go
@@ -46,7 +46,7 @@ 		author += " <" + names[0] + ">"
 	}
 	if isDefaultKey(anchor) {
 		// The default seed is public, so anyone could have made this.
-		author = "nobody in particular (default key)"
+		author = "Public (Default Key)"
 	}
 	start, end, _, _ := ratify.Window(p.Certs)
 
@@ -57,7 +57,11 @@ 	row("Program", strings.Join(anchor.Subject.Organization, ", "))
 	row("Ratified by", author)
 	row("Key", "SHA-256 "+ratify.Fingerprint(anchor.RawSubjectPublicKeyInfo))
 	row("In force", start.UTC().Format(time.RFC3339)+" to "+end.UTC().Format(time.RFC3339))
-	row("Depth", fmt.Sprintf("%d (a trust anchor and %d more certificates)", p.Depth(), p.Depth()))
+	more := "certificates"
+	if p.Depth() == 1 {
+		more = "certificate"
+	}
+	row("Depth", fmt.Sprintf("%d (a trust anchor and %d more %s)", p.Depth(), p.Depth(), more))
 	row("Nodes", fmt.Sprint(p.Nodes))
 	return b.String()
 }
diff --git a/cmd/government/verify_test.go b/cmd/government/verify_test.go
index 6159734e723dd392bc4bccbfcec6cb7c5fea2d95..a1effe1370d11088fe0eaf8561ffde030d2e6abf 100644
--- a/cmd/government/verify_test.go
+++ b/cmd/government/verify_test.go
@@ -19,15 +19,23 @@ 	}
 	for _, want := range []string{
 		"CERTIFICATE OF RATIFICATION",
 		"Program      worked",
-		"Ratified by  nobody in particular (default key)",
+		"Ratified by  Public (Default Key)",
 		"Key          SHA-256 ",
 		"In force     2000-01-01T00:00:00Z to 9999-12-31T23:59:59Z",
-		"Depth        3 ",
+		"Depth        3 (a trust anchor and 3 more certificates)\n",
 		"Nodes        7\n",
 	} {
 		if !strings.Contains(stdout, want) {
 			t.Errorf("missing %q in\n%s", want, stdout)
 		}
+	}
+}
+
+func TestVerifyDepthOne(t *testing.T) {
+	gov := compileTo(t, t.TempDir(), "answer", "42")
+	_, stdout, _ := runCmd("verify", gov)
+	if want := "Depth        1 (a trust anchor and 1 more certificate)\n"; !strings.Contains(stdout, want) {
+		t.Errorf("missing %q in\n%s", want, stdout)
 	}
 }