# Signatrust Trust Bundle v2 (`signatrust-trust-bundle-v2`)

CAH-3B-5 — Signed Trust Bundle v2 export + independent verification.

Status: **local-only**. This artifact and its verifiers run entirely against
locally-held material and externally-supplied trusted roots. It introduces no
network service, no production root, no production access, and no change to any
Receipt schema, ledger, epoch, DBD, DEP, or key-fingerprint/lifecycle semantics.

---

## Section 65 — Outline

### 65.1 Purpose

A Trust Bundle v2 is a **root-signed, self-contained export** of a local
issuer's `signatrust-key-lifecycle/1` chain (CAH-3B-3): the **complete** prefix
from `ISSUER_GENESIS` through a chosen lifecycle head. It lets an independent
verifier confirm — using **only an externally-supplied trusted issuer root** —
that the bundle and its included lifecycle prefix are cryptographically
consistent with that root.

The format is **completely separate** from the unsigned
`signatrust-trust-bundle-v1` ledger-scan export
(`scripts/export-trust-bundle.ts`). v1 is never reused, reinterpreted, or
converted here (see Section 50).

### 65.2 Bundle shape

```
{
  format: "signatrust-trust-bundle-v2",
  bundle_id: <opaque id>,
  issuer_id: <string>,
  root_fingerprint: "sha256:<64hex>",
  bundle_sequence: <int >= 1>,
  previous_bundle_hash: null | "sha256:<64hex>",
  lifecycle_head_hash: "sha256:<64hex>",
  records: [ complete signatrust-key-lifecycle/1 records, GENESIS -> head, in order ],
  generated_at: "YYYY-MM-DDTHH:MM:SS.sssZ",
  bundle_hash: "sha256:<64hex>",
  signature: { algorithm: "ed25519", root_fingerprint: "sha256:...", value: <base64> }
}
```

### 65.3 Signed body / bundle hash / signature

- `signed_body = bundle MINUS {bundle_hash, signature}`.
- `bundle_hash = "sha256:" + hex(sha256(utf8(canonicalize(signed_body))))`.
- `signature = Ed25519 over the utf8 bytes of the bundle_hash STRING` — this
  mirrors the CAH-3B-3 record-hash signing pattern exactly, so the issuer root's
  existing `sign(hashString)` primitive is reused verbatim.

Canonicalization is CAH-1B `canonicalize` (`src/canonical.ts` /
`sdk/python/canonical_v1.py`). Fingerprints are CAH-3B-2
`fingerprintEd25519SpkiBase64` (`src/keyFingerprint.ts` /
`sdk/python/key_fingerprint_v1.py`). Lifecycle records are verified with CAH-3B-3
`verifyLifecycleChain` (`src/keyLifecycle.ts` / `sdk/python/key_lifecycle_v1.py`).

### 65.4 Verification axes

`verifyTrustBundleV2` evaluates ten independent axes, each reported as one of
`ESTABLISHED` / `CONTRADICTED` / `NOT_ESTABLISHED` / `NOT_APPLICABLE`:

| Axis | Meaning |
| --- | --- |
| `structure` | Shape, required fields, field formats, canonical `generated_at`. |
| `bundle_hash` | Recomputed `bundle_hash` equals the sealed value. |
| `root_fingerprint` | bundle vs signature vs records vs trusted root fingerprint agree. |
| `root_signature` | Ed25519 signature over `bundle_hash` verifies under the trusted root. |
| `issuer_consistency` | All records share the bundle's `issuer_id`; no foreign records. |
| `lifecycle_chain` | The complete prefix verifies end-to-end (CAH-3B-3). |
| `lifecycle_head` | `lifecycle_head_hash` equals the last record's `record_hash`. |
| `bundle_sequence` | `sequence >= 1`; seq 1 -> `previous_bundle_hash == null`; seq N -> hash present. |
| `prefix_monotonicity` | Across a bundle sequence, each bundle extends the prior prefix. |
| `trust_anchor` | A trusted root was externally supplied to the verifier. |

The projection additionally carries `trust_anchor_basis` and a sorted
`error_codes` list, plus a `valid` boolean (all axes `ESTABLISHED`, with
`prefix_monotonicity` allowed to be `NOT_APPLICABLE` for a single bundle).

### 65.5 Trust anchor axis

For this wave the trust anchor axis is `ESTABLISHED` with basis
`EXTERNALLY_SUPPLIED_TEST_ROOT` **when and only when the trusted root is supplied
by the caller**. It is **never** "globally trusted". If no trusted root is
supplied the axis is `NOT_ESTABLISHED` and the bundle is not `valid`. The bundle
**cannot self-establish trust**: the trusted root is always caller-supplied and
is never taken from the bundle body.

### 65.6 Complete-prefix rule

`records[]` MUST equal the **complete** lifecycle prefix from GENESIS through
`lifecycle_head_hash` — never a subset. `buildBundleFromLifecycleStore` always
emits the full store contents and refuses to export from a corrupt / forked /
empty store (it runs `verifyLifecycleChain` end-to-end first). An **empty
lifecycle cannot be exported** (a valid GENESIS-containing chain is required).

### 65.7 Sequencing, previous hash, prefix monotonicity, fork

- Bundle #1: `bundle_sequence == 1`, `previous_bundle_hash == null`.
- Bundle #N+1: `bundle_sequence == prev.bundle_sequence + 1`,
  `previous_bundle_hash == prev.bundle_hash`.
- **Prefix monotonicity**: bundle N+1's `records[]` MUST start with
  structurally-identical (canonicalize-equal) records from bundle N, in the same
  order. A shorter next-prefix is a **rollback** (`prefix_rollback`); a differing
  slot is a **mutation** (`prefix_mutation`).
- **Zero-new-record bundles are allowed** and documented as
  snapshot / preservation bundles that add no new lifecycle knowledge.
- **Fork**: two bundles sharing the same `bundle_sequence` AND the same
  `previous_bundle_hash` are a `bundle_fork`.

### 65.8 Signer restriction

The bundle signer is ALWAYS the **issuer root** (`src/localIssuerRoot.ts`). The
operating Receipt-signing key MUST NOT sign bundles;
`buildBundleFromLifecycleStore` throws `signer_root_mismatch` if the signer's
fingerprint is not the store root's, and a bundle actually signed by a non-root
key fails the `root_signature` axis against the trusted root. This is tested
explicitly (unit test + adversarial vector #3).

### 65.9 `generated_at` semantics

`generated_at` uses the CAH-3B-3 canonical millisecond form
`YYYY-MM-DDTHH:MM:SS.sssZ` (i.e. `Date.prototype.toISOString()`). It is a local
wall-clock stamp for operator convenience only; it is **not** an independent
timestamp and proves nothing about real time (see the time limitation below).

### 65.10 Error codes

Canonical bundle-level error-code vocabulary:

`invalid_format`, `invalid_bundle_hash`, `invalid_signature`,
`root_fingerprint_mismatch`, `issuer_mismatch`, `invalid_lifecycle_head`,
`invalid_lifecycle_chain`, `lifecycle_record_invalid`, `invalid_bundle_sequence`,
`invalid_previous_bundle_hash`, `prefix_rollback`, `prefix_mutation`,
`bundle_fork`, `missing_required_field`, `unsupported_algorithm`,
`unsupported_format`, `empty_lifecycle`, `missing_genesis`, `cross_issuer_record`,
`duplicate_lifecycle_record`, `reordered_lifecycle_record`, `attacker_self_root`,
`operating_key_signer`, `generated_at_invalid`.

`attacker_self_root` and `operating_key_signer` are **reserved** vocabulary that
describe adversary *intent*. The verifier cannot reconstruct a public key from a
fingerprint alone, so it reports these scenarios through the observable
cryptographic axes instead: an attacker self-root surfaces as
`root_fingerprint_mismatch` (adversarial #1) and an operating-key signer surfaces
as `invalid_signature` (adversarial #3). The reserved codes are retained for
documentation and future use and are never silently repurposed.

### 65.11 Deliverables

| Deliverable | Path |
| --- | --- |
| Core module | `src/trustBundleV2.ts` |
| Unit + adversarial tests | `src/trustBundleV2.test.ts` |
| CLI exporter | `scripts/export-trust-bundle-v2.ts` |
| Deterministic vector generator | `scripts/cah/gen-trust-bundle-v2-vectors.ts` |
| Node vectors runner | `scripts/cah/trust-bundle-v2-vectors.test.ts` |
| Python verifier | `sdk/python/trust_bundle_v2.py` |
| Python vectors runner | `sdk/python/test_trust_bundle_v2_vectors.py` |
| Frozen vector corpus | `audit/cah/vectors/trust-bundle-v2/vectors.json` + `manifest.json` |

`package.json` scripts: `test:cah-3b-5-unit`, `test:cah-3b-5-node-vectors`,
`test:cah-3b-5-python-vectors`, aggregate `test:cah-3b-5`, plus
`export:trust-bundle-v2`.

### 65.12 Node / Python parity

The Node module (`src/trustBundleV2.ts`) and the independent Python verifier
(`sdk/python/trust_bundle_v2.py`) are re-derivations from the same normative
freeze. Both consume the **same** frozen `vectors.json` and reproduce the LITERAL
`expected_result` projection for every vector. The literal `expected_result` is
generated once by running the Node verifier; runners never recompute "expected".

---

## Section 66 — Claim boundary (VERBATIM)

> A valid Signatrust Trust Bundle v2 establishes that the supplied bundle and
> included lifecycle prefix are cryptographically consistent with the externally
> trusted issuer root supplied to the verifier. It does not, by itself, establish
> trust in that root, prove absence of conflicting bundles, prove independent
> wall-clock time, or prove external historical preservation.

---

## Limitations (verbatim cross-references)

### Single-view equivocation limitation (Section 17 / 42)

A single verifier sees only the bundles it is handed. A holder could present
different, internally-consistent bundle chains to different verifiers. The bundle
chain is **not** an equivocation / non-equivocation proof: prefix monotonicity
and fork detection only constrain the bundles a **single** verifier actually
observes together. Detecting cross-view equivocation requires an external
mechanism (e.g. a shared transparency log) that is explicitly **out of scope**
for this wave. Treating a bundle chain as a non-equivocation proof is a STOP
condition.

### Time limitation (Section 15 / 58)

`generated_at` and every lifecycle `recorded_at` / `effective_at` are local
wall-clock stamps produced by the signer. They are **not** independent time and
prove nothing about real-world ordering or freshness. No external timestamp,
RFC3161, Certificate Transparency, or transparency-log anchoring is implemented
or implied. A valid bundle does **not** prove independent wall-clock time.

### Preservation limitation (Section 57)

A bundle proves only that its contents were cryptographically consistent when
signed. It does **not** prove that any external party independently preserved,
witnessed, or archived the history, nor that the exporter retained anything.
External historical preservation is out of scope and is not established by a
valid bundle.

### v1 non-reinterpretation (Section 50)

`signatrust-trust-bundle-v2` is a distinct format. The unsigned
`signatrust-trust-bundle-v1` ledger-scan export is never reused, reinterpreted,
converted, or upgraded into v2, and `scripts/export-trust-bundle.ts` is left
byte-identical. A silent v1 -> v2 conversion is a STOP condition.

### Local-only status

Everything here is local-only: local issuer root, local lifecycle store,
locally-built bundles, and verifiers that require a caller-supplied trusted root.
No production root, no production access, no real legacy migration, no root
rotation, and no server Receipt-verification route changes are part of this wave.

---

## Strongest supported guarantee

The strongest guarantee this artifact supports is exactly the Section 66 claim
boundary quoted verbatim above. Explicitly **unsupported**: trust in the root
itself; absence of conflicting/forked bundles across views; independent
wall-clock time; and external historical preservation.
