{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://platoskallipolis.com/schemas/resource-reuse-evidence.v1.json",
  "title": "Plato's Kallipolis Resource Reuse Evidence",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "reuseId", "citationId", "evidenceUrl", "evidenceHash", "observedAt", "verificationState", "countable", "privacy"],
  "properties": {
    "schema": {"const": "kallipolis.resource-reuse-evidence.v1"},
    "reuseId": {"type": "string", "pattern": "^reuse\\.[a-f0-9]{64}$"},
    "citationId": {"type": "string"},
    "evidenceUrl": {"type": "string", "format": "uri"},
    "evidenceHash": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"},
    "observedAt": {"type": "string", "format": "date-time"},
    "verificationState": {"enum": ["pending-verification", "verified", "invalid", "withdrawn"]},
    "countable": {"type": "boolean"},
    "verifiedAt": {"type": "string", "format": "date-time"},
    "verification": {
      "type": "object",
      "additionalProperties": false,
      "required": ["schema", "method", "citationMatch", "resourceContentHashMatch", "evidenceBodyHashMatch", "redirectsAllowed"],
      "properties": {
        "schema": {"const": "kallipolis.public-reuse-verification.v1"},
        "method": {"const": "public-json-proof-v1"},
        "citationMatch": {"const": true},
        "resourceContentHashMatch": {"const": true},
        "evidenceBodyHashMatch": {"const": true},
        "redirectsAllowed": {"const": false}
      }
    },
    "privacy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["consumerIdentityStored", "walletDataStored", "requestDataStored"],
      "properties": {
        "consumerIdentityStored": {"const": false},
        "walletDataStored": {"const": false},
        "requestDataStored": {"const": false}
      }
    }
  },
  "allOf": [
    {
      "if": {"properties": {"verificationState": {"const": "verified"}}, "required": ["verificationState"]},
      "then": {"properties": {"countable": {"const": true}}, "required": ["verifiedAt", "verification"]},
      "else": {"properties": {"countable": {"const": false}}}
    }
  ]
}
