{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mathgraph.org/schemas/external-binding-v1.schema.json",
  "title": "MathGraph unsigned in-toto Statement v1 external binding",
  "description": "Exact correspondence only. Consumers must additionally reject duplicate JSON keys and nonfinite numbers, verify exact artifact bytes against a separately selected pin, validate the capability descriptor, compare claim/assumptions/evidence exactly, and reject critical or duplicate-ID extensions. No signature, authentication, qualification, freshness or action authority is established.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "_type",
    "subject",
    "predicateType",
    "predicate"
  ],
  "properties": {
    "_type": {
      "const": "https://in-toto.io/Statement/v1"
    },
    "subject": {
      "type": "array",
      "minItems": 1,
      "maxItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "digest"
        ],
        "properties": {
          "name": {
            "type": "string",
            "pattern": "\\S"
          },
          "digest": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "sha256"
            ],
            "properties": {
              "sha256": {
                "$ref": "#/$defs/sha256"
              }
            }
          }
        }
      }
    },
    "predicateType": {
      "const": "https://mathgraph.org/attestation/external-binding/v1"
    },
    "predicate": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema_version",
        "signature",
        "artifact",
        "claim",
        "assumptions",
        "evidence",
        "extensions"
      ],
      "properties": {
        "schema_version": {
          "const": "mathgraph.external-binding.v1"
        },
        "signature": {
          "const": "UNSIGNED"
        },
        "artifact": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "name",
            "sha256",
            "size_bytes",
            "media_type",
            "object_schema"
          ],
          "properties": {
            "name": {
              "type": "string",
              "pattern": "\\S"
            },
            "sha256": {
              "$ref": "#/$defs/sha256"
            },
            "size_bytes": {
              "type": "integer",
              "minimum": 0
            },
            "media_type": {
              "const": "application/json"
            },
            "object_schema": {
              "const": "mathgraph.capability-contract.v1"
            }
          }
        },
        "claim": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "id",
            "kind",
            "scope"
          ],
          "properties": {
            "id": {
              "type": "string",
              "pattern": "\\S"
            },
            "kind": {
              "type": "string",
              "pattern": "\\S"
            },
            "scope": {
              "type": "string",
              "pattern": "\\S"
            }
          }
        },
        "assumptions": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "\\S"
          }
        },
        "evidence": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "locator",
              "sha256",
              "size_bytes",
              "media_type"
            ],
            "properties": {
              "id": {
                "type": "string",
                "pattern": "\\S"
              },
              "locator": {
                "type": "string",
                "pattern": "\\S"
              },
              "sha256": {
                "$ref": "#/$defs/sha256"
              },
              "size_bytes": {
                "type": "integer",
                "minimum": 0
              },
              "media_type": {
                "type": "string",
                "pattern": "\\S"
              }
            }
          },
          "uniqueItems": true
        },
        "extensions": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "version",
              "critical",
              "payload"
            ],
            "properties": {
              "id": {
                "type": "string",
                "pattern": "\\S"
              },
              "version": {
                "type": "string",
                "pattern": "\\S"
              },
              "critical": {
                "const": false
              },
              "payload": {
                "type": "object"
              }
            }
          },
          "uniqueItems": true
        }
      }
    }
  },
  "$defs": {
    "sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "minLength": 64,
      "maxLength": 64
    }
  }
}
