# Shareable receipt links (v1)

Goal: a receipt you can paste into a conversation or a ticket and that anyone
can verify **locally**, with **no server storage** — consistent with the
current retention rule ("receipts are returned to the caller and not stored").

## 1. Container

```json
{
  "v": "scorecompute.verify.link.v1",
  "payload_json": "<exact bytes from the receipt>",
  "signature": { "alg": "Ed25519", "key_id": "…", "public_key_url": "…", "value_b64": "…" },
  "signed_at": "2026-10-05T00:05:10.041Z"
}
```

The `payload` copy and `payload_sha256` are dropped: they are recomputed from
`payload_json` (`payload = JSON.parse(payload_json)`,
`payload_sha256 = SHA-256(payload_json)`), which halves the link size. The
container reconstructs the exact v1 envelope, then §6 of
[README.md](README.md) applies unchanged.

## 2. URL form

```
https://scorecompute.com/verify/#r=<base64url(UTF-8(container JSON))>
```

- `base64url`, standard alphabet, **no padding** (`+`→`-`, `/`→`_`, trailing
  `=` removed).
- The fragment after `#` is **never sent to the server** (browser rule): the
  site performs no lookup, no logging, no storage.
- Decoded container limit: 64 KiB (envelope limit). Recommended shareable
  size: ≤ 8 KiB decoded; beyond that, show "Download the receipt instead of a
  link" rather than silently truncating.

## 3. Verification behaviour (front)

1. Read `location.hash`, strip `#r=`, decode base64url (reject invalid).
2. Parse the container; require `v == scorecompute.verify.link.v1`; reject
   unknown fields.
3. Reconstruct the envelope and run the existing local verifier (the same code
   used for uploaded receipts).
4. Show `verdict`, `validation_scope`, `limits`, `signed_at`, `key_id`, and the
   key source: **"keys fetched from scorecompute.com — trust-on-first-use,
   not a trust anchor"**. Never upload the link or the receipt.
5. Any failure: display `invalid` with the reason; never "probably valid".

## 4. Producer behaviour

- After a successful check, offer **Copy link** and **Download receipt**.
- The copy button encodes only the reduced container; if the container exceeds
  the policy size, disable the link and explain the download fallback.
- No receipt identifiers, counters or personal data are added to the link.

## 5. Test vector

`vectors/receipts/valid-link.json` verifies with the reference verifier:

```
node verify-receipt.mjs vectors/receipts/valid-link.json vectors/spec-test-keyset.json
```

Expected: `VALID compatible numbers …`.

The encoded fragment is stored at
`vectors/receipts/valid-link.fragment.txt` (1 419 characters). Audit of
2026-10-05: decoding it and running the verifier returns `VALID`; flipping
base64 padding corrupts the JSON and is refused at decode; a semantically
tampered container that still decodes (`"compatible"` → `"compatible "`)
fails with `INVALID Signature mismatch.` and exit code 2.

## 6. Integration

- `/verify/` handles `#r=` on entry and every fragment change, using the existing browser verifier.
- **Copy link** sits beside Download; containers above 8 KiB require download. The receiver bounds the encoded fragment before decoding and the reconstructed envelope before verification.
- Link this spec and the standard from `/trust/` (or a public
  `/standard/receipt-v1` page) so third parties can implement it.

No scientific content changes; front-only.
