{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/hiveseal-qpuf-v2.json",
  "title": "HiveSeal QPuF v1",
  "description": "HiveSeal QPuF receipt. It records a nonce bound challenge and a signed response commitment, recomputes the challenge message, verifies the Ed25519 device signature, compares the response and enrollment commitments with the declared distance metric, and reports the supplied enrollment trust classification. It records only the supplied challenge response relation and does not establish unclonability, physical origin, or quantum origin. source_kind distinguishes simulated from physical_claimed.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": {
      "type": "string",
      "pattern": "^r_hiveseal\\.qpuf_[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",
        "puf_challenge_id",
        "evidence_digest_sha256",
        "recorded_at",
        "verdict",
        "boundary",
        "challenge_nonce",
        "challenge_committed_at",
        "response_observed_at",
        "response_bytes_commitment_sha256",
        "source_kind",
        "device_public_key",
        "device_signature",
        "enrollment_ref",
        "enrollment_trust_classification",
        "enrolled_response_commitment_sha256",
        "distance_metric",
        "acceptance_threshold",
        "challenge_message_sha256",
        "response_distance",
        "signature_relation",
        "enrollment_relation",
        "elements",
        "outcome"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": {
          "type": "string",
          "const": "hiveseal.qpuf"
        },
        "schema": {
          "type": "string",
          "const": "r2.0.0"
        },
        "puf_challenge_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": [
            "unclonability_proven",
            "physical_origin_proven",
            "quantum_origin_proven"
          ],
          "additionalProperties": false,
          "properties": {
            "unclonability_proven": {
              "type": "boolean",
              "const": false
            },
            "physical_origin_proven": {
              "type": "boolean",
              "const": false
            },
            "quantum_origin_proven": {
              "type": "boolean",
              "const": false
            }
          }
        },
        "boundary": {
          "type": "string",
          "const": "HiveSeal QPuF receipt. It records a nonce bound challenge and a signed response commitment, recomputes the challenge message, verifies the Ed25519 device signature, compares the response and enrollment commitments with the declared distance metric, and reports the supplied enrollment trust classification. It records only the supplied challenge response relation and does not establish unclonability, physical origin, or quantum origin. source_kind distinguishes simulated from physical_claimed."
        },
        "challenge_nonce": {
          "type": "string",
          "minLength": 16,
          "maxLength": 256
        },
        "challenge_committed_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$",
          "description": "Instant the challenge nonce was committed."
        },
        "response_observed_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$",
          "description": "Instant the response commitment was observed."
        },
        "response_bytes_commitment_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Commitment to the observed response bytes."
        },
        "source_kind": {
          "type": "string",
          "enum": [
            "simulated",
            "physical_claimed"
          ]
        },
        "device_public_key": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Lowercase hexadecimal Ed25519 public key for the signed device or platform message."
        },
        "device_signature": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{86}$",
          "description": "Unpadded base64url Ed25519 signature over the canonical message defined by this contract."
        },
        "enrollment_ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 256,
          "description": "Reference to the enrollment record used for comparison."
        },
        "enrollment_trust_classification": {
          "type": "string",
          "enum": [
            "trusted",
            "untrusted",
            "unknown"
          ],
          "description": "Trust classification supplied with the linked evidence. Unknown remains indeterminate."
        },
        "enrolled_response_commitment_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "Response commitment carried by the enrollment record."
        },
        "distance_metric": {
          "type": "string",
          "enum": [
            "sha256_hamming_bits"
          ]
        },
        "acceptance_threshold": {
          "type": "integer",
          "minimum": 0,
          "maximum": 256
        },
        "challenge_message_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$",
          "description": "SHA256 of the canonical device message."
        },
        "response_distance": {
          "type": "integer",
          "minimum": 0,
          "maximum": 256
        },
        "signature_relation": {
          "type": "string",
          "enum": [
            "valid",
            "invalid"
          ]
        },
        "enrollment_relation": {
          "type": "string",
          "enum": [
            "resolved",
            "untrusted",
            "indeterminate"
          ]
        },
        "elements": {
          "type": "array",
          "minItems": 0,
          "maxItems": 3,
          "items": {
            "type": "string",
            "enum": [
              "response_outside_tolerance",
              "device_signature_invalid",
              "enrollment_unresolved"
            ]
          }
        },
        "outcome": {
          "type": "string",
          "enum": [
            "enrolled_response_within_tolerance",
            "response_outside_tolerance",
            "trust_not_established"
          ]
        }
      }
    }
  }
}
