{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://thehiveryiq.com/.well-known/schemas/disclosure-presentation-v1.json",
  "title": "Disclosure Presentation Receipt, v1",
  "description": "Canonical schema for the Hive disclosure presentation receipt, canonical type disclosure.presentation. The receipt records that a notice text, at a stated version, was presented on a stated surface class at a stated instant, by a committed presenting party, to a committed subject, and it records the relation between that instant and the instant of a linked prior receipt for the assisted action the notice was about.",
  "type": "object",
  "required": [
    "receipt_id",
    "payload_sha256",
    "sig_b64u",
    "key_id",
    "algorithm",
    "ts",
    "signed_body"
  ],
  "additionalProperties": false,
  "properties": {
    "receipt_id": { "type": "string", "pattern": "^r_disclosure\\.presentation_[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",
        "disclosure_id",
        "presentation",
        "presenter_commitment",
        "subject_commitment",
        "recorded_response",
        "bound_action",
        "ordering_class",
        "response_ordering_class",
        "salt_commitment",
        "boundary"
      ],
      "additionalProperties": false,
      "properties": {
        "receipt_type": { "type": "string", "const": "disclosure.presentation" },
        "schema": { "type": "string", "const": "r1.0.0" },
        "disclosure_id": { "type": "string", "pattern": "^dp_[0-9a-f]{16,64}$" },
        "presentation": {
          "type": "object",
          "description": "What was presented, in what version, on what surface class, and when.",
          "required": ["notice_digest", "notice_version", "presented_at", "surface_class"],
          "additionalProperties": false,
          "properties": {
            "notice_digest": {
              "type": "string",
              "description": "Lowercase hex SHA-256 over the exact bytes of the notice text that was presented.",
              "pattern": "^[0-9a-f]{64}$"
            },
            "notice_version": {
              "type": "string",
              "description": "Short opaque version label for the notice text, recorded as presented.",
              "pattern": "^[0-9a-z][0-9a-z._-]{0,47}$"
            },
            "presented_at": {
              "type": "object",
              "required": ["utc", "drift_seconds"],
              "additionalProperties": false,
              "properties": {
                "utc": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$" },
                "drift_seconds": { "type": "integer", "minimum": 0, "maximum": 86400 }
              }
            },
            "surface_class": {
              "type": "string",
              "enum": [
                "interactive_display",
                "voice_playback",
                "printed_handout",
                "messaging_thread",
                "embedded_webview"
              ]
            }
          }
        },
        "presenter_commitment": {
          "type": "string",
          "description": "Salted commitment over the identifier of the presenting party.",
          "pattern": "^[0-9a-f]{64}$"
        },
        "subject_commitment": {
          "type": "string",
          "description": "Salted commitment over the identifier of the person the notice was presented to.",
          "pattern": "^[0-9a-f]{64}$"
        },
        "recorded_response": {
          "type": "object",
          "description": "The response class recorded at the surface, with its instant when one was recorded.",
          "required": ["response_class", "response_channel_class"],
          "additionalProperties": false,
          "properties": {
            "response_class": { "type": "string", "enum": ["acknowledged", "declined", "none_recorded"] },
            "responded_at": {
              "type": "object",
              "required": ["utc", "drift_seconds"],
              "additionalProperties": false,
              "properties": {
                "utc": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$" },
                "drift_seconds": { "type": "integer", "minimum": 0, "maximum": 86400 }
              }
            },
            "response_channel_class": {
              "type": "string",
              "enum": [
                "interactive_display",
                "voice_playback",
                "printed_handout",
                "messaging_thread",
                "embedded_webview"
              ]
            }
          }
        },
        "bound_action": {
          "type": "object",
          "description": "Link to the prior receipt for the assisted action the notice was about.",
          "required": ["receipt_id", "receipt_type", "envelope_sha256", "issuance_instant"],
          "additionalProperties": false,
          "properties": {
            "receipt_id": { "type": "string", "pattern": "^r_[0-9a-z]+(\\.[0-9a-z]+)*_[0-9]{10,}_[0-9a-f]{12}$" },
            "receipt_type": { "type": "string", "pattern": "^[0-9a-z]+(\\.[0-9a-z]+)*$" },
            "envelope_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
            "issuance_instant": {
              "type": "object",
              "required": ["utc", "drift_seconds"],
              "additionalProperties": false,
              "properties": {
                "utc": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{1,9})?Z$" },
                "drift_seconds": { "type": "integer", "minimum": 0, "maximum": 86400 }
              }
            }
          }
        },
        "ordering_class": {
          "type": "string",
          "description": "Recomputed relation between the presentation instant and the bound action instant, under the recorded drift bounds.",
          "enum": ["notice_before_action", "notice_after_action", "ordering_indeterminate"]
        },
        "response_ordering_class": {
          "type": "string",
          "description": "Recomputed relation between the recorded response instant, the presentation instant, and the bound action instant.",
          "enum": [
            "response_within_presentation_window",
            "response_before_presentation",
            "response_after_action",
            "no_response_recorded"
          ]
        },
        "salt_commitment": {
          "type": "string",
          "description": "Commitment to the salt that keys the presenter and subject commitments. The salt itself is disclosed to the verifier in the request, never in the signed body.",
          "pattern": "^[0-9a-f]{64}$"
        },
        "boundary": {
          "type": "string",
          "minLength": 1,
          "const": "This receipt attests only that a notice with the recorded digest and version was recorded as presented on the recorded surface class at the recorded instant, by the committed presenting party, to the committed subject, that the recorded response class and its instant are the ones the presenting side recorded, and that the presentation instant, taken at its latest possible value under the recorded drift bound, is at or before the earliest possible instant of the linked prior receipt for the assisted action. It does not attest that any person read, understood, or agreed to anything, that the notice text was legally adequate, that the notice was legible or audible, that a recorded acknowledgement was freely given, or that the assisted action itself was correct. The surface class, the response channel class, and the notice version are recorded as presented and are not evaluated here."
        }
      }
    }
  }
}
