# Seal and verify

> Turn a Notarized capture into a proof, and check any sealed Trace offline.

Part of the Exalto Capture docs. Page: https://capture.exalto.ai/docs/seal-and-verify. Every page is listed in https://capture.exalto.ai/llms.txt; the whole site in one file is https://capture.exalto.ai/llms-full.txt.

Sealing turns a Captured Trace into a `.llmtrace` package that anyone can check. Verifying checks a package against a trusted notary key, without contacting the provider or the notary. Witnessed Traces are already sealed, so everything about sealing on this page applies to Notarized Traces.

## Seal a Trace

With the SDK, pass the `.llmcapture` and its capture key to `notarize`, which returns the Notarized `.llmtrace`:

```python title="seal.py"
trace = client.notarize(capture_bytes, capture_key)
```

Sealing takes much longer than the call did, and much more CPU and memory: it reconnects to a notary holding the same signing key and computes the TLSNotary proof from the encrypted checkpoint. [SDK](https://capture.exalto.ai/docs/sdk#seal-later) has the details.

A failed or interrupted seal can be retried: the checkpoint is never consumed, though an interrupted proof starts over. Seal while Exalto's Registry still lists a notary that seals for the key that witnessed the call.

Each seal through Exalto's notary draws on your [sealing allowance](https://capture.exalto.ai/docs/billing). When it runs out, sealing is refused, never billed.

### Hosted captures

Seal a hosted capture from **Captures** in the web app, or with an API key that has **Seal with Exalto** (`notarization:request`):

```sh title="Terminal"
curl -X POST https://api.capture.exalto.ai/api/captures/traces/trc-example/notarizations \
  -H "Authorization: Bearer $EXALTO_API_KEY"
```

## Verify a Trace

### With the SDK

`notary.verify(trace)` checks a package against that notary's keys: for Exalto's notary, a key in its Registry; for your own, its configured public key. `verify(trace, public_key)` checks it against one key you trust directly.

A verified package returns its `evidence_kind`, `provider` and `provider_host`, `created_at_unix_ms`, `notary_public_key`, `request_path`, `package_sha256` and `trace_otlp_json`. Anything that doesn't check out raises an error instead. Report the result with its evidence kind: opening a package isn't verifying it.

Verification contacts neither the provider nor a notary, nor Exalto: it uses the copy of the Registry `Notary.exalto` last read.

> **A passing Witnessed package isn't a proof**
>
> Verification passes for Witnessed packages too, so always report the `evidence_kind` with the outcome. It comes from the package's manifest format: `notarized` (`ecp/trace-evidence/v1`) is a TLSNotary proof, `witnessed` (`ecp/witness-evidence/v1`) is the notary operator's signed receipt.

### Without installing anything

Anyone can check a package at [capture.exalto.ai/verify](https://capture.exalto.ai/verify). The page checks the file without storing it. The same check is an HTTP call:

```sh title="Terminal"
curl --fail-with-body https://api.capture.exalto.ai/api/verify \
  -H "Content-Type: application/vnd.exalto.notary.trace-package+zip" \
  --data-binary @trc-example.llmtrace
```

A passing package returns `verified: true`, the `evidence_kind`, the `provider` and `host`, the `notary_key_id` and `trust_source`, and the package's digests. A failure returns an error with a code such as `tampered_package` or `untrusted_notary`. The hosted verifier trusts only keys in Exalto's Registry, so check a package from a self-hosted notary with the SDK instead.

## What verification checks

1. The archive is exactly the canonical package, file for file.
2. Every file matches the hash in the package's manifest.
3. The notary key matches the verifier's trust source, and was trusted at the package's timestamp.
4. The evidence is valid. A Notarized package's TLSNotary proof and signature hold, and the proof authenticates the provider's hostname and certificate. A Witnessed package's receipt signature holds, and the receipt covers the disclosed bytes.
5. The disclosed request and response match the evidence, and every header value is hidden.
6. Rebuilding the OpenTelemetry trace from the disclosed bytes reproduces `trace.otlp.json` byte for byte.

The [trace package format](https://capture.exalto.ai/docs/trace-packages) describes each file.
