{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:intertween:experimental:integrity:0.1:integrity-checkpoint",
  "title": "IntegrityCheckpoint",
  "description": "Experimental 0.1 structure only. No assertion of signature, authority, privacy or federation conformance. See README.md.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "node",
    "trace_scope",
    "sequence_from",
    "sequence_to",
    "merkle_root",
    "previous_checkpoint",
    "created_at",
    "signing_key",
    "signature",
    "witness_attestations"
  ],
  "properties": {
    "node": {
      "type": "string",
      "format": "uri",
      "minLength": 1
    },
    "trace_scope": {
      "type": "string",
      "format": "uri",
      "minLength": 1
    },
    "sequence_from": {
      "type": "integer",
      "minimum": 1
    },
    "sequence_to": {
      "type": "integer",
      "minimum": 1
    },
    "merkle_root": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "previous_checkpoint": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        {
          "type": "null"
        }
      ]
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "signing_key": {
      "type": "string",
      "minLength": 1
    },
    "signature": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "algorithm",
        "key_id",
        "value"
      ],
      "properties": {
        "algorithm": {
          "const": "ECDSA-P256-SHA256"
        },
        "key_id": {
          "type": "string",
          "minLength": 1
        },
        "value": {
          "type": "string",
          "pattern": "^[A-Za-z0-9+/]+={0,2}$"
        }
      }
    },
    "witness_attestations": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "witness",
          "checkpoint_hash",
          "claim",
          "created_at",
          "signature"
        ],
        "properties": {
          "witness": {
            "type": "string",
            "format": "uri",
            "minLength": 1
          },
          "checkpoint_hash": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "claim": {
            "enum": [
              "checkpoint-retained",
              "signature-verified",
              "sequence-consistency-verified"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "signature": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "algorithm",
              "key_id",
              "value"
            ],
            "properties": {
              "algorithm": {
                "const": "ECDSA-P256-SHA256"
              },
              "key_id": {
                "type": "string",
                "minLength": 1
              },
              "value": {
                "type": "string",
                "pattern": "^[A-Za-z0-9+/]+={0,2}$"
              }
            }
          }
        }
      }
    }
  }
}
