# Video attestation

Video attestation chains a hash per chunk, seeds live recordings with a server nonce so a pre-recorded video can't pass as live, and carries the manifest beside the file.

Video attestation is the video form of an attestation bundle, that hashes the recording chunk by chunk into a chain so a change to any chunk is caught at that chunk.

## When to use it

Use it for walk-around inspections, damage videos and any recording that must be shown unchanged. Use a live capture session when it also matters that the video was recorded now, not uploaded from earlier.

## How it works

1. **Chunks.** The recording is cut into chunks of about 2 seconds.
2. **Chain.** Each chunk's hash covers the previous one: `chunk_hash_i = SHA256(prev_chunk_hash || SHA256(chunk_bytes))`. Changing, dropping or reordering any chunk breaks every later hash, which verification reports as `frame_hash_mismatch` at that chunk.
3. **Seed.** For a live session, chunk 0 is seeded with a `session_nonce` the server issues when the session opens, so a video hashed in advance can't produce a valid chain. A recorded upload is seeded with `""`.

1. **Open session**: server issues session_nonce
2. **Stream chunks**: hash chain, server timestamps
3. **Finalize**: signed bundle + manifest

The final chain hash is the bundle's `sensor_hash`, and the bundle travels beside the video as a sidecar manifest.

## Key fields

| Field | Type | Description |
| --- | --- | --- |
| `session_nonce` | string \| null | The server-issued seed for a live session; `null` for a recorded upload. |
| `video_manifest.chunk_duration_ms` | integer | The target chunk length, usually 2000. |
| `video_manifest.duration_seconds` | number | The recording's length. |
| `video_manifest.codec` | string | The container and codec, such as `video/webm;codecs=vp9`. |
| `video_manifest.chunks` | object[] | Each chunk's `index`, `byte_length`, `chunk_hash` and `captured_at`. |

## Open a live session

[`POST /v1/attest/capture_sessions`](https://provenanceauth.com/docs/api/capture-sessions.md#post-v1-attest-capture-sessions) opens a session and returns its nonce:

**curl**

```bash
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_full_K7mN3xQp9RbT2vWm8sYd4cFjLhXn6gAe

curl -s $PROVENANCE_API/v1/attest/capture_sessions \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "device_id": "dev_00000000000000000000000000000001", "claim_id": "CLM-DOCS-VIDEO", "chunk_duration_ms": 2000 }' | tee session.json
```

**Node**

```ts
import { Provenance } from "@provenanceauth/sdk";

const prov = new Provenance({ apiKey: process.env.PROVENANCE_KEY!, baseUrl: process.env.PROVENANCE_API });
const session = await prov.attest.captureSessions.create({ deviceId: "dev_00000000000000000000000000000001", claimId: "CLM-DOCS-VIDEO", chunkDurationMs: 2000 });
```

**Python**

```python
import os
import httpx

api, headers = os.environ["PROVENANCE_API"], {"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}
session = httpx.post(f"{api}/v1/attest/capture_sessions", headers=headers, json={
    "device_id": "dev_00000000000000000000000000000001", "claim_id": "CLM-DOCS-VIDEO", "chunk_duration_ms": 2000,
}).json()
```

```json
{
  "id": "cses_7XX5ES93YC9TEBG9ADWE958XQS",
  "object": "capture_session",
  "status": "open",
  "session_nonce": "23adc0fd19002088bc9c590fefa854868149fddb784eed8bd27b97a21ff82913",
  "expires_at": "2026-10-24T13:39:08.922Z"
}
```

The capture app then sends each chunk's hash as it is cut, with [`POST /v1/attest/capture_sessions/{id}/chunks`](https://provenanceauth.com/docs/api/capture-sessions.md#post-v1-attest-capture-sessions-id-chunks). The server timestamps each arrival:

**curl**

```bash
export SESSION_ID=$(jq -r .id session.json)
curl $PROVENANCE_API/v1/attest/capture_sessions/$SESSION_ID/chunks \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "index": 0, "chunk_hash": "2110a233677a28c9cd6d66ac954ce831e70587e1940cf53e1a66f36683efad68", "captured_at": "2026-10-24T13:30:00.000Z" }'
```

**Node**

```ts
await prov.attest.captureSessions.appendChunk(session.id, { index: 0, chunkHash: "2110a233677a28c9cd6d66ac954ce831e70587e1940cf53e1a66f36683efad68", capturedAt: "2026-10-24T13:30:00.000Z" });
```

**Python**

```python
httpx.post(f"{api}/v1/attest/capture_sessions/{session['id']}/chunks", headers=headers, json={
    "index": 0, "chunk_hash": "2110a233677a28c9cd6d66ac954ce831e70587e1940cf53e1a66f36683efad68", "captured_at": "2026-10-24T13:30:00.000Z",
})
```

```json
{ "object": "capture_chunk", "session_id": "cses_7XX5ES93YC9TEBG9ADWE958XQS", "index": 0, "chunk_count": 1 }
```

When recording stops, the app finalizes with the device-signed bundle at [`POST /v1/attest/capture_sessions/{id}/finalize`](https://provenanceauth.com/docs/api/capture-sessions.md#post-v1-attest-capture-sessions-id-finalize), which verifies the nonce, the chain and the timing, and returns the verification result with `liveness_checked: true`. A recorded upload skips the session and goes to [`POST /v1/attest/attestations`](https://provenanceauth.com/docs/api/claims.md#post-v1-attest-attestations) with its manifest.

## What the checks mean

| Factor | Points | Meaning |
| --- | --- | --- |
| `frame_hash_mismatch` | 50 | A chunk's bytes don't match the chain; the factor names the first bad chunk. |
| `session_nonce_mismatch` | 70 | The chain isn't seeded with the session's nonce: the main sign of a replayed recording. |
| `liveness_check_failed` | 40 | The chunk timing was inconsistent: gaps far outside the cadence, timestamps out of order, or chunks after finalize. |
| `video_manifest_incomplete` | 40 | Chunks are missing or out of sequence in the manifest. |

`liveness_check_failed` is a timing check on the chunks. It doesn't check that a person was present.

**Limitations:** the manifest travels beside the video file; it isn't embedded in the MP4 or WebM container.

## Related

- [Attestation bundles](https://provenanceauth.com/docs/attest/concepts/attestation-bundles.md)
- [Verification](https://provenanceauth.com/docs/attest/concepts/verification.md)
- [Risk scoring](https://provenanceauth.com/docs/attest/concepts/risk-scoring.md)
