{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://iamar.world/schemas/pieces-0.schema.json",
  "title": "iamar package piece list (format 0)",
  "description": "<id>-<version>.pieces.json beside a packed .iamar file: the file's size, whole hash and per-piece hashes, signed with the same key as the package. See docs/WORLD_FORMAT.md, 'Distribution'. Unsigned piece lists (no key_id/public_key/signature) are only trustworthy when fetched from the world's host itself.",
  "type": "object",
  "required": [
    "format",
    "format_version",
    "id",
    "version",
    "size",
    "sha256",
    "piece_size",
    "pieces"
  ],
  "additionalProperties": false,
  "properties": {
    "format": {
      "const": "iamar-pieces"
    },
    "format_version": {
      "const": 0
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9_-]{0,63}$"
    },
    "version": {
      "type": "string",
      "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+([-+][0-9A-Za-z.-]+)?$"
    },
    "size": {
      "type": "integer",
      "minimum": 1,
      "description": "Bytes of the .iamar file."
    },
    "sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$",
      "description": "SHA-256 of the whole .iamar file."
    },
    "piece_size": {
      "const": 65536,
      "description": "Bytes per piece; the last piece may be shorter."
    },
    "pieces": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "pattern": "^[0-9a-f]{64}$"
      }
    },
    "algorithm": {
      "const": "RSA-PKCS1-v1_5-SHA256"
    },
    "signer": {
      "type": "string",
      "maxLength": 80
    },
    "key_id": {
      "type": "string",
      "pattern": "^rsa:[0-9a-f]{32}$"
    },
    "public_key": {
      "type": "string"
    },
    "signature": {
      "type": "string",
      "description": "Base64 RSA signature over the pieces signing text."
    }
  }
}
