{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/origin-raster-v1.json",
  "title": "Raster Origin Assertion v1",
  "description": "Raster Origin Assertion receipt. Whether a region of a page was captured from a physical document or rendered by software is now a real question, so this receipt carries the origin class per region, the detector and version that produced it, the signals it relied on, its score with a named scale, and the ordered lineage of render profiles applied to that region, all signed by a named asserting key. Two verdict fields are fixed and the caller can never set them: the origin class is an assertion, and the origin is not forensically proven. It does not inspect the raster and does not attest that any region is authentic; detector_executed_by_service is fixed to false.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_origin\\.raster_[0-9]{10,}_[0-9a-f]{12}$"
    },
    "payload_sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "sig_b64u": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_-]{86}$"
    },
    "key_id": {
      "type": "string",
      "pattern": "^did:(hive|web|key):[A-Za-z0-9._:%-]+$"
    },
    "algorithm": {
      "type": "string",
      "const": "Ed25519"
    },
    "ts": {
      "type": "integer",
      "minimum": 1000000000
    },
    "signed_body": {
      "type": "object",
      "required": [
        "receipt_type",
        "schema",
        "raster_assertion_id",
        "evidence_digest_sha256",
        "recorded_at",
        "verdict",
        "boundary",
        "render_profile_digest_sha256",
        "asserting_key_id",
        "subjects"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "origin.raster"
        },
        "schema": {
          "type": "string",
          "const": "r1.0.0"
        },
        "raster_assertion_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "pattern": "^[A-Za-z0-9._:-]{1,256}$"
        },
        "evidence_digest_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "SHA-256 of the caller-held evidence bundle this receipt attests was recorded. The service never receives or inspects the underlying evidence, only its digest."
        },
        "recorded_at": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}([.][0-9]{1,9})?Z$"
        },
        "verdict": {
          "type": "object",
          "description": "Service-computed honesty boundary fields. Never caller overridable; recomputed and checked at verify time.",
          "required": [
            "origin_class_is_an_assertion",
            "origin_forensically_proven",
            "detector_executed_by_service",
            "subject_count",
            "captured_subject_count",
            "synthetic_render_subject_count",
            "mixed_subject_count",
            "undetermined_subject_count",
            "every_subject_carries_a_named_detector"
          ],
          "additionalProperties": false,
          "properties": {
            "origin_class_is_an_assertion": {
              "type": "boolean",
              "const": true
            },
            "origin_forensically_proven": {
              "type": "boolean",
              "const": false
            },
            "detector_executed_by_service": {
              "type": "boolean",
              "const": false
            },
            "subject_count": {
              "type": "integer",
              "minimum": 0
            },
            "captured_subject_count": {
              "type": "integer",
              "minimum": 0
            },
            "synthetic_render_subject_count": {
              "type": "integer",
              "minimum": 0
            },
            "mixed_subject_count": {
              "type": "integer",
              "minimum": 0
            },
            "undetermined_subject_count": {
              "type": "integer",
              "minimum": 0
            },
            "every_subject_carries_a_named_detector": {
              "type": "boolean"
            }
          }
        },
        "boundary": {
          "type": "string",
          "const": "Raster Origin Assertion receipt. Whether a region of a page was captured from a physical document or rendered by software is now a real question, so this receipt carries the origin class per region, the detector and version that produced it, the signals it relied on, its score with a named scale, and the ordered lineage of render profiles applied to that region, all signed by a named asserting key. Two verdict fields are fixed and the caller can never set them: the origin class is an assertion, and the origin is not forensically proven. It does not inspect the raster and does not attest that any region is authentic; detector_executed_by_service is fixed to false."
        },
        "render_profile_digest_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Profile the subject boxes are expressed against."
        },
        "asserting_key_id": {
          "type": "string",
          "pattern": "^did:(hive|web|key):[A-Za-z0-9._:%-]+$",
          "description": "Key of the party making the origin assertion."
        },
        "subjects": {
          "type": "array",
          "minItems": 1,
          "maxItems": 256,
          "items": {
            "type": "object",
            "required": [
              "page_index",
              "box_x",
              "box_y",
              "box_width",
              "box_height",
              "origin_class",
              "detector_ref",
              "detector_version",
              "signals",
              "score",
              "score_scale_ref"
            ],
            "additionalProperties": false,
            "properties": {
              "page_index": {
                "type": "integer",
                "minimum": 0,
                "maximum": 65535
              },
              "box_x": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1000000
              },
              "box_y": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1000000
              },
              "box_width": {
                "type": "integer",
                "minimum": 1,
                "maximum": 1000000
              },
              "box_height": {
                "type": "integer",
                "minimum": 1,
                "maximum": 1000000
              },
              "origin_class": {
                "type": "string",
                "enum": [
                  "captured",
                  "synthetic_render",
                  "mixed",
                  "undetermined"
                ]
              },
              "detector_ref": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "Detector that produced the class."
              },
              "detector_version": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "Version of that detector."
              },
              "signals": {
                "type": "array",
                "minItems": 1,
                "maxItems": 32,
                "items": {
                  "type": "string",
                  "enum": [
                    "jpeg_quantization",
                    "noise_residual",
                    "font_rasterization",
                    "resampling_trace",
                    "compression_history",
                    "edge_profile",
                    "color_banding",
                    "metadata_lineage"
                  ]
                }
              },
              "score": {
                "type": "number",
                "minimum": 0,
                "maximum": 1,
                "description": "Detector score."
              },
              "score_scale_ref": {
                "type": "string",
                "minLength": 1,
                "maxLength": 256,
                "description": "Named and versioned scale for that score."
              },
              "profile_lineage_digests": {
                "type": "array",
                "minItems": 0,
                "maxItems": 32,
                "items": {
                  "type": "string",
                  "pattern": "^[0-9a-f]{64}$",
                  "description": "Digest of one render profile in the ordered lineage applied to this subject."
                }
              }
            }
          }
        }
      }
    }
  }
}
