{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://standard-barcodeverified.org/protocol/receipt.schema.json",
 "title": "Receipt · AI Product Match Verification 0.1",
 "type": "object",
 "required": [
  "v",
  "issuer",
  "seq",
  "subject",
  "subject_type",
  "market",
  "core_version",
  "profile_version",
  "verified_at",
  "answer_hash",
  "match_hash",
  "result",
  "prev_hash",
  "hash",
  "id",
  "kid",
  "sig"
 ],
 "properties": {
  "v": {
   "const": 1
  },
  "issuer": {
   "type": "string"
  },
  "seq": {
   "type": "integer",
   "minimum": 1
  },
  "subject": {
   "type": "string",
   "pattern": "^[0-9]{14}$"
  },
  "subject_type": {
   "const": "product-match"
  },
  "market": {
   "type": "string",
   "pattern": "^[A-Z]{2}$",
   "not": {
    "const": "GB"
   }
  },
  "core_version": {
   "type": "string"
  },
  "profile_version": {
   "type": "string"
  },
  "verified_at": {
   "type": "string",
   "format": "date-time"
  },
  "answer_hash": {
   "type": "string",
   "pattern": "^sha256:[0-9a-f]{64}$"
  },
  "match_hash": {
   "type": "string",
   "pattern": "^sha256:[0-9a-f]{64}$"
  },
  "result": {
   "type": "object",
   "required": [
    "value",
    "dimensions"
   ],
   "properties": {
    "value": {
     "enum": [
      "verified",
      "listed",
      "stale",
      "unknown"
     ]
    },
    "dimensions": {
     "type": "object",
     "required": [
      "source_authority",
      "disagreement",
      "freshness",
      "authorisation"
     ]
    }
   }
  },
  "supersedes": {
   "type": [
    "string",
    "null"
   ]
  },
  "issued_at": {
   "type": "string",
   "format": "date-time"
  },
  "prev_hash": {
   "type": "string",
   "pattern": "^sha256:[0-9a-f]{64}$"
  },
  "hash": {
   "type": "string",
   "pattern": "^sha256:[0-9a-f]{64}$"
  },
  "id": {
   "type": "string"
  },
  "kid": {
   "type": "string"
  },
  "sig": {
   "type": "string"
  }
 },
 "description": "hash = sha256 over the canonical receipt without hash, sig and id (UTF-8 JSON, keys sorted, no spaces); id derives from the hash; sig over the hash string by the key named by kid, resolved on the keyring at https://rco-barcodeverified.org/keyring.json; prev_hash = the hash of the issuer's receipt before it in seq."
}