{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://xcim.invalid/ietf/as01/schemas/common.schema.json",
  "title": "AS01-F01 common",
  "$defs": {
    "hash": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$",
      "minLength": 43,
      "maxLength": 43
    },
    "signature": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{85}[AQgw]$",
      "minLength": 86,
      "maxLength": 86
    },
    "segment": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]+$",
      "maxLength": 262144,
      "minLength": 1
    },
    "id": {
      "type": "string",
      "pattern": "^[!-~]+$",
      "minLength": 1,
      "maxLength": 256
    },
    "token": {
      "type": "string",
      "pattern": "^[A-Za-z0-9._:-]+$",
      "minLength": 1,
      "maxLength": 200
    },
    "domain": {
      "type": "string",
      "pattern": "^[a-z0-9.-]+$",
      "minLength": 1,
      "maxLength": 253
    },
    "origin": {
      "type": "string",
      "pattern": "^https://[a-z0-9.-]+$",
      "maxLength": 300
    },
    "positive": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991
    },
    "nonnegative": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    },
    "jwk": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kty",
        "crv",
        "x"
      ],
      "properties": {
        "kty": {
          "const": "OKP"
        },
        "crv": {
          "const": "Ed25519"
        },
        "x": {
          "$ref": "https://xcim.invalid/ietf/as01/schemas/common.schema.json#/$defs/hash"
        }
      }
    },
    "jws": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "protected",
        "payload",
        "signature"
      ],
      "properties": {
        "protected": {
          "$ref": "https://xcim.invalid/ietf/as01/schemas/common.schema.json#/$defs/segment"
        },
        "payload": {
          "$ref": "https://xcim.invalid/ietf/as01/schemas/common.schema.json#/$defs/segment"
        },
        "signature": {
          "$ref": "https://xcim.invalid/ietf/as01/schemas/common.schema.json#/$defs/signature"
        }
      }
    },
    "quorum": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "payload",
        "signatures"
      ],
      "properties": {
        "payload": {
          "$ref": "https://xcim.invalid/ietf/as01/schemas/common.schema.json#/$defs/segment"
        },
        "signatures": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "protected",
              "signature"
            ],
            "properties": {
              "protected": {
                "$ref": "https://xcim.invalid/ietf/as01/schemas/common.schema.json#/$defs/segment"
              },
              "signature": {
                "$ref": "https://xcim.invalid/ietf/as01/schemas/common.schema.json#/$defs/signature"
              }
            }
          },
          "minItems": 1,
          "maxItems": 8
        }
      }
    },
    "pin": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kid",
        "alg",
        "public_jwk",
        "thumbprint",
        "role",
        "valid_from",
        "valid_until"
      ],
      "properties": {
        "kid": {
          "$ref": "https://xcim.invalid/ietf/as01/schemas/common.schema.json#/$defs/token"
        },
        "alg": {
          "enum": [
            "Ed25519",
            "EdDSA"
          ]
        },
        "public_jwk": {
          "$ref": "https://xcim.invalid/ietf/as01/schemas/common.schema.json#/$defs/jwk"
        },
        "thumbprint": {
          "$ref": "https://xcim.invalid/ietf/as01/schemas/common.schema.json#/$defs/hash"
        },
        "role": {
          "$ref": "https://xcim.invalid/ietf/as01/schemas/common.schema.json#/$defs/token"
        },
        "valid_from": {
          "$ref": "https://xcim.invalid/ietf/as01/schemas/common.schema.json#/$defs/nonnegative"
        },
        "valid_until": {
          "$ref": "https://xcim.invalid/ietf/as01/schemas/common.schema.json#/$defs/positive"
        }
      }
    }
  }
}
