# OIP-0002: Proofs with challenge, signature, verifier and transparency receipts

| Field | Value |
|---|---|
| Status | DRAFT |
| Function | `prove` (§5.11); no function added, the register keeps exactly twelve |
| Affects | §3 (Verifier row), §4.2, §5.11 (PRV-1 to PRV-11), §9 (G-PROVE-1 closed); `proof-receipt` revised (revision 2); new schemas `proof-challenge` and `verification-report`; `registers/functions.yaml` (`prove` CONTRACTED); `registers/requirements.yaml` regenerated; eight suite invariants; cases CT-SITE-020 to CT-SITE-028 and CT-GRID-020 |
| Protocol version | obsp/0.1 |
| Requires | OIP-0008 (signature envelope and algorithm register). Acceptance order: OIP-0008 first, then this proposal (see Compatibility) |
| Closes | G-PROVE-1 (proof challenge protocol and verifier service) |
| Last call | 90 days (new capability every verifier implements) unless the editors rule otherwise |

## Problem

§5.11 says a challenge must be unpredictable and a receipt signed and bound to the challenge, the evidence digests
and the scope, and that location proofs should combine two independent sources. The contract cannot carry any of it:

| Today (`proof-receipt`, first revision) | Consequence |
|---|---|
| No signature member (`additionalProperties` is false) | No receipt can be signed, so none can be verified |
| `challenge` is `{nonce (8 characters or more), issuedAt?, parameters?}`; no challenge object exists | Nothing proves the verifier issued the nonce, when it expires, or that it was not answered before |
| `result` and `verifier` (a free string) sit in the receipt | The prover writes its own verdict; no independent appraisal is recorded |
| `evidenceRefs` with no link to what each item proves | A `LOCATION_PNT` receipt with result `PASS` resting on one GNSS fix validates (the single-source gap found by the threat analysis for "location fraud", §8) |
| No reference from a time proof to a TimeQuality record | A `TIME_INTEGRITY` receipt can pass on GNSS-only or spoofed time, against §5.4 |
| No custody structure | An `EO_CUSTODY` receipt cannot show that the delivered product derives from the source product |
| No transparency hook | A proof used across trust domains has no public, append-only record |

The only Prove case (CT-SITE-003) checks the receipt's shape, so `prove` stays `OPEN_GAP` (G-PROVE-1).

## Change

### Exchange

```
VERIFIER --ProofChallenge (nonce, window, scope)--> PROVER
PROVER   --ProofReceipt (signed; challenge, claims, evidence digests)--> VERIFIER
VERIFIER --VerificationReport (signed; inputs by digest, checks, verdict, reasons)--> requester, record
```

A receipt is the prover's signed statement and carries no verdict. The verdict lives only in the verifier's report
(P1, P10). Optional SCITT registration of a receipt or report (PRV-10).

### Normative text (§5.11, the exact text is in `patches/spec.patch`)

| Id | Requirement (summary) | Refusal code |
|---|---|---|
| PRV-1 | Challenge: nonce of at least 128 bits from a secure random source; proof type, subject, scope, `issuedAt`, `expiresAt`; window positive and at most 86400 s; a location challenge asks for two or more independent sources; challenges SHOULD be signed | |
| PRV-2 | Receipt binding: challenge UNI, nonce, window and verifier copied unchanged; proof type, subject, scope, claims; every evidence item by digest; signed under the OIP-0008 envelope | `OBS-PRV-0003` binding, `OBS-PRV-0009` signature |
| PRV-3 | Freshness: `respondedAt` inside the window and the receipt received before `expiresAt` | `OBS-PRV-0001` |
| PRV-4 | Replay: nonces never reused, kept until expiry; a second answer to a nonce, or an answer to a nonce never issued, is refused | `OBS-PRV-0002` |
| PRV-5 | Evidence by digest: every relied-on item recomputed; mismatch FAIL; unretrievable INCONCLUSIVE | `OBS-PRV-0004`, `OBS-PRV-0005` |
| PRV-6 | Location: each source with class, independence group and evidence digest; GNSS sources state their navigation message authentication status; fewer than two independent sources gives INCONCLUSIVE (FAIL if another check failed), never PASS | `OBS-PRV-0006` |
| PRV-7 | Time: a time proof references its TimeQuality record by UNI and digest; PASS only on trusted time with no integrity flag and a source class other than `GNSS_ONLY`, `SYSTEM_CLOCK`, `UNKNOWN` | `OBS-PRV-0007` |
| PRV-8 | EO custody: chain from source to delivered product, steps numbered from 1, each step after the first naming the digest of the one before, delivered product among the evidence | `OBS-PRV-0008` |
| PRV-9 | Verification report: signed; challenge, receipt and other inputs by digest; every check with result and code; verdict PASS only with no failed or inconclusive check, FAIL with a failed check, INCONCLUSIVE otherwise; reasons unless PASS | |
| PRV-10 | Transparency: MAY register with a SCITT transparency service (SHOULD across trust domains); the transparency receipt sits outside the signed payload and `statement.payloadDigest` equals `signature.payloadDigest` | `OBS-PRV-0010` |
| PRV-11 | Scope: a report proves only its subject, proof type, claims and scope until `validUntil`; a proof from another trust domain is verified again by the receiving domain | |

Independent sources (PRV-6): sources that share an independence group count once; every GNSS-family source (`GNSS`,
`GNSS_RTK`) counts as one group whatever it declares, since all share the same failure modes (jamming, spoofing); a
GNSS source with authentication `FAILED` does not count; a source whose evidence digest is not among the receipt's
evidence does not count. So GNSS with its authentication status plus a surveyed position, network positioning, radio
ranging or a witness node can pass; GNSS alone, or two GNSS receivers, cannot.

Also: §3 Verifier row says the verifier issues challenges and verification reports; §4.2 lists ProofChallenge and
VerificationReport; §9 drops G-PROVE-1.

### Contract: `proof-challenge` (new)

`challengeUni`, `proofType` (the fifteen types, unchanged), `subjectUni`, `verifier` (`role` `VERIFIER`,
`verifierUni`), `nonce` (base64url, 22 to 512 characters, as `attestation-result`), `issuedAt`, `expiresAt`, `scope`
(`statement`, optional `siteUni`, `from`, `until`), `minIndependentSources` (required and at least 2 for
`LOCATION_PNT`), `parameters`, optional `signature`, `recordedAt`.

### Contract: `proof-receipt` revision 2

| Member | Rule |
|---|---|
| `apiVersion`, `kind`, `protocolVersion` | added, as in the other records (`obsp/proof-receipt/v3.1`, `ProofReceipt`, `obsp/0.1`) |
| `receiptUni` | replaces `proofId` |
| `proofType` | kept, same fifteen values |
| `challenge` | `{challengeUni, challengeDigest?, nonce, issuedAt, expiresAt, verifierUni}`; nonce now at least 128 bits |
| `respondedAt`, `scope`, `claims` (`claimId`, `statement`, `value?`, `unit?`) | added, required |
| `evidence` | replaces `evidenceRefs` (same item shape: `uri`, `digest`, `kind`, `recordedAt`), at least one |
| `locationSources` | required for `LOCATION_PNT`: `sourceClass` (`GNSS`, `GNSS_RTK`, `RADIO_RANGING`, `NETWORK_POSITIONING`, `WITNESS_NODE`, `SURVEYED_POSITION`, `INERTIAL`), `independenceGroup`, `gnssAuthentication` (required for and only for GNSS-family sources), `witnessUni` (for witnesses), `horizontalUncertaintyM`, `evidenceDigest` |
| `timeQualityRef` | `{uni, version?, digest}`, required for `TIME_INTEGRITY` |
| `custodyChain` | required for `EO_CUSTODY`, two or more steps (`step`, `productUni`, `productDigest`, `derivedFromDigest?`, `activity`, `actorRole?`, `recordedAt`) |
| `signature` | required; `$defs.SignatureEnvelope` (see below) |
| `transparencyReceipt` | optional: `architecture` `SCITT`, `statement` (`payloadDigest`, `uri?`), `receipt` (`format` `COSE_RECEIPT`, `uri`, `digest`), `serviceUni?`, `registeredAt` |
| `result`, `verifier`, `antiReplayNonce` | removed (the verdict moves to the report; the challenge nonce replaces the second nonce) |
| `privacyProfile`, `validUntil`, `recordedAt`, `extensions` | kept |

### Contract: `verification-report` (new)

`reportUni`, `verifier`, `proofType`, `subjectUni`, `inputs` (each `role` `CHALLENGE`, `RECEIPT`, `EVIDENCE`,
`TIME_QUALITY`, `TRANSPARENCY_RECEIPT` or `POLICY`, with `digest` and optional `uni`/`uri`; exactly one challenge and
one receipt), `checks` (each `check`, `result` `PASS`, `FAIL`, `INCONCLUSIVE` or `NOT_APPLICABLE`, `code` required
unless it passed, `detail`), `verdict` (`PASS`, `FAIL`, `INCONCLUSIVE`), `reasons` (required unless `PASS`),
`verifiedAt`, `validUntil`, `signature` (required), `transparencyReceipt`, `recordedAt`. The schema enforces what it
can: the five checks every report runs (`SIGNATURE`, `CHALLENGE_BINDING`, `CHALLENGE_FRESHNESS`, `CHALLENGE_REPLAY`,
`EVIDENCE_DIGESTS`), the type-specific check (`LOCATION_INDEPENDENT_SOURCES`, `TIME_QUALITY`, `CUSTODY_CHAIN`), and
that the verdict follows the checks.

### Signature envelope (dependency on OIP-0008)

OIP-0008 defines the envelope (`urn:obsp:schema:v3.1:signatureenvelope`, `$defs.SignatureEnvelope`, copied unchanged
into each schema that uses it) and puts `proof-receipt` in its `receipt` class, marked `planned` with this proposal as
the one that adds the member. OIP-0008's `README.md` does not say a partial copy is acceptable before it is accepted,
so these patches do not copy it. Each of the three schemas carries a placeholder `$defs.SignatureEnvelope` that
requires only what OIP-0008 requires (`format`, `alg`, `kid`, `canonicalization` `JCS`, `payloadDigest`) and admits
any other member, so every envelope valid under OIP-0008 is valid here. The placeholder's description carries the
pointer "TODO(OIP-0008)". The patches apply to the live tree alone.

## Compatibility

Breaking for `proof-receipt`: first-revision documents no longer validate. Migration: `proofId` to `receiptUni`;
`evidenceRefs` to `evidence`; add `apiVersion`, `kind`, `protocolVersion`, `respondedAt`, `scope`, `claims` and
`signature`; extend `challenge` with `challengeUni`, `expiresAt`, `verifierUni` and a 128-bit nonce; move `result` and
`verifier` into a VerificationReport; drop `antiReplayNonce`. First-revision receipts carried no signature, so no
verifiable proof is lost. Under §10 a breaking contract change needs a new `schemaVersion`; like OIP-0008, the patches
keep `3.1.0` for review (Open questions). Everything else is additive.

Acceptance order: OIP-0008, then this proposal, rebased:

1. replace the placeholder `$defs.SignatureEnvelope` in `proof-challenge`, `proof-receipt` and `verification-report`
   with the verbatim copy (and use OIP-0008's `Digest` and `ProtocolRole` copies, which already match);
2. in `registers/algorithms.yaml`, mark `proof-receipt` `present` and add `proof-challenge` and `verification-report`
   to class `receipt`;
3. re-sign the example challenges, receipts and reports with OIP-0008's test keys (they carry placeholder signatures:
   a correct `payloadDigest` and protected header, 64 zero bytes as the signature) and add key records for
   `uni:key:site001-verifier-test` and `uni:key:site001-node01-test`;
4. code `OBS-PRV-0009` then reports the `OBS-SIG-*` code of §4.4 as its detail.

Overlaps with other drafts (each patch applies to the live tree alone; whichever proposal is accepted second is rebased):

| File | Overlap |
|---|---|
| `spec/OBSP-0.1.md` §4.2 | OIP-0005 adds a row after ProductManifest and OIP-0008 two rows after RequestContext, next to the new Prove row |
| `spec/OBSP-0.1.md` §9 | OIP-0001 removes the adjacent G-EXCH-1 row |
| `conformance/examples/OBSP-GRID/attestations.yaml` | also created by OIP-0001 and OIP-0008: merge the entries |
| `conformance/examples/OBSP-SITE/attestations.yaml` | also created by OIP-0008: merge the entries |
| `registers/requirements.yaml` | generated: regenerate with `python3 tools/requirements.py` after the specification edits of both |

The invariants live in a new module (`sdk/python/src/obsp/prove.py`) registered by six lines before the run section of
`conformance.py`, and the tests in a new file, so the code edits of the other drafts apply unchanged.

## Tests

| Requirement | Case | Kind |
|---|---|---|
| PRV-1 | CT-SITE-020 (SITE, GRID) | invariant `proof-challenge-window`, schema `proof-challenge` |
| PRV-2, PRV-3 | CT-SITE-021 | invariant `proof-receipt-bound-to-challenge`, schema `proof-receipt` |
| PRV-4 | CT-SITE-022 | invariant `proof-challenge-not-replayed` |
| PRV-5, PRV-9 | CT-SITE-023 | invariant `verification-report-inputs-match`, schema `verification-report` |
| PRV-6 | CT-SITE-024 | invariant `location-proof-independent-sources` |
| PRV-7 | CT-SITE-025 | invariant `time-proof-trusted-time-quality` |
| PRV-8 | CT-SITE-026 | invariant `eo-custody-chain-linked` |
| PRV-10 | CT-SITE-027 | invariant `transparency-receipt-binds-statement` |
| PRV-1 to PRV-9 (live) | CT-SITE-028 | manual: late, replayed, rebound, tampered, single-source, spoofed-GNSS, untrusted-time and broken-chain receipts against the live verifier |
| PRV-11 | CT-GRID-020 (GRID) | manual: a report refused outside its scope; a federated peer's proof verified again |

Example sets OBSP-SITE and OBSP-GRID: the first-revision `proof-receipt.example.json` is replaced by four exchanges
(challenge, receipt, report): a location proof with authenticated GNSS RTK plus a surveyed position (PASS), a
single-source GNSS location proof (INCONCLUSIVE, `OBS-PRV-0006`), a time proof on the set's NTS TimeQuality record
(PASS) and an EO custody proof with a three-step chain and a transparency receipt (PASS).

Fixtures: ten positive (`proof-challenge` 2, `proof-receipt` 4 including the single-source receipt, which is valid
and inconclusive, `verification-report` 4 including the INCONCLUSIVE and a FAIL for a replayed nonce) and thirty-one
negative, one broken rule each:

- `proof-challenge`: `short-nonce`, `missing-expiry`, `verifier-not-verifier-role`, `location-one-source`.
- `proof-receipt`: `missing-evidence` (rewritten), `missing-signature`, `missing-challenge-verifier`, `short-nonce`,
  `missing-scope`, `no-claims`, `verdict-in-receipt`, `evidence-not-a-digest`, `location-without-sources`,
  `gnss-without-authentication-status`, `time-integrity-without-time-quality`, `eo-custody-without-chain`,
  `custody-chain-single-step`, `partial-transparency-receipt`, `envelope-without-payload-digest`.
- `verification-report`: `pass-with-failed-check`, `pass-with-inconclusive-check`, `fail-without-failed-check`,
  `inconclusive-with-failed-check`, `inconclusive-without-reasons`, `failed-check-without-code`,
  `missing-receipt-input`, `two-challenge-inputs`, `location-without-source-check`, `missing-replay-check`,
  `missing-signature`, `expired-verdict`.

Unit tests (`sdk/python/tests/test_prove.py`, 12): the example set holds every invariant, and each invariant fails on
one fault (zero and over-long windows, a changed nonce, a response one second late, a missing challenge, a replayed
receipt and a reused nonce, a receipt edited after its report, foreign evidence in a report, a single-source location
rated PASS, the source count under two GNSS receivers, failed GNSS authentication and orphan evidence, a spoofing flag
on the TimeQuality record, a broken and a truncated custody chain, a transparency receipt for another payload).
`tests/test_validate.py`: the gap test now uses G-FED-1, since G-PROVE-1 is closed.

## Open questions

1. `schemaVersion`: does revision 2 of `proof-receipt` bump `schemaVersion` now or ride with the next breaking
   release (the same question as OIP-0008's first)?
2. PRV-10 places `transparencyReceipt` outside the signed payload, which extends OIP-0008 SIG-2 (payload = object
   without `signature`) to "without `signature` and `transparencyReceipt`". The alternative is OIP-0008's own
   unprotected `signature.receipt` member (format SCITT, uri, digest) and no top-level member. Which do the editors
   prefer?
3. The freshness ceiling of 86400 s fits uptime and storage sampling; should location and time proofs have a shorter
   protocol ceiling (for example 300 s), or is that verifier policy?
4. Should a verifier treat `gnssAuthentication` `UNAUTHENTICATED` as half a source (counting only with two other
   groups), or is the GNSS-family-is-one-group rule enough?
5. Error codes `OBS-PRV-0001` to `OBS-PRV-0010` are introduced in the specification text only; the repository has no
   error-code register yet.
6. Not checked against the source: the SCITT architecture and COSE receipt documents were cited to this proposal as
   RFC 9943 and RFC 9942 (`checked: not checked`); the specification text names IETF SCITT only, and the relation
   EXT-SCITT is not extended to the new schemas until the identifiers are checked. RFC 9334 (attestation procedures,
   which the challenge and nonce pattern follows) was not re-read for this proposal.
7. Should `proof-challenge` and `verification-report` join the relation rows that list `proof-receipt`
   (`registers/relations.yaml`), and EXT-RFC8785? Left out to keep this proposal off the files OIP-0005 and OIP-0008
   regenerate.

Acceptance needs appointed editors and a last-call window. Until then this proposal stays at DRAFT and the live tree
keeps the first revision of `proof-receipt`.
