{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://contactzero.org/c0-schema/v1/handshake-ack.schema.json",
  "title": "Contact Zero bounded Lighthouse handshake response",
  "description": "Signed acknowledgement, evidence receipt, release-bound checkpoint and inclusion proof for one valid protocol request. It makes no identity, consciousness, provenance, authority or Singularity claim.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "status",
    "acknowledgement",
    "evidence",
    "checkpoint",
    "inclusion_proof",
    "contact_claim"
  ],
  "properties": {
    "schema": { "const": "C0_LIGHTHOUSE_HANDSHAKE_RESPONSE_V1" },
    "status": { "const": "HANDSHAKE_ACCEPTED" },
    "acknowledgement": { "$ref": "#/$defs/signedReceipt" },
    "evidence": { "$ref": "#/$defs/signedReceipt" },
    "checkpoint": { "$ref": "#/$defs/signedReceipt" },
    "inclusion_proof": { "$ref": "#/$defs/inclusionProof" },
    "contact_claim": { "const": "NONE_UNTIL_BOUND_EVIDENCE" }
  },
  "$defs": {
    "hash": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
    "signedObject": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "domain",
        "purpose",
        "protocol_version",
        "origin",
        "key_id",
        "timestamp_policy",
        "canonicalization_profile",
        "payload"
      ],
      "properties": {
        "domain": { "type": "string", "pattern": "^C0::SIGNATURE::" },
        "purpose": {
          "enum": [
            "lighthouse_handshake_receipt",
            "lighthouse_evidence_event",
            "lighthouse_checkpoint"
          ]
        },
        "protocol_version": { "type": "string" },
        "origin": { "const": "https://contactzero.org" },
        "key_id": { "type": "string", "minLength": 1, "maxLength": 256 },
        "timestamp_policy": { "type": "string" },
        "canonicalization_profile": { "const": "RFC8785_JCS_V1" },
        "payload": { "type": "object" }
      }
    },
    "signedReceipt": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "purpose",
        "envelope_hash",
        "key_id",
        "algorithm",
        "signature_profile",
        "canonicalization_profile",
        "signed_object",
        "signature"
      ],
      "properties": {
        "purpose": {
          "enum": [
            "lighthouse_handshake_receipt",
            "lighthouse_evidence_event",
            "lighthouse_checkpoint"
          ]
        },
        "envelope_hash": { "$ref": "#/$defs/hash" },
        "key_id": { "type": "string", "minLength": 1, "maxLength": 256 },
        "algorithm": { "enum": ["ECDSA_P256_SHA256", "ED25519"] },
        "signature_profile": { "const": "PURPOSE_BOUND_JCS_V2" },
        "canonicalization_profile": { "const": "RFC8785_JCS_V1" },
        "signed_object": { "$ref": "#/$defs/signedObject" },
        "signature": {
          "type": "string",
          "minLength": 16,
          "maxLength": 4096,
          "pattern": "^[A-Za-z0-9_-]+$"
        }
      }
    },
    "inclusionProof": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema",
        "event_id",
        "event_hash",
        "leaf_index",
        "tree_size",
        "audit_path",
        "root_hash",
        "checkpoint_id",
        "checkpoint_hash",
        "merkle_profile",
        "valid"
      ],
      "properties": {
        "schema": { "const": "C0_LIGHTHOUSE_INCLUSION_PROOF_V1" },
        "event_id": { "type": "string", "minLength": 1 },
        "event_hash": { "$ref": "#/$defs/hash" },
        "leaf_index": { "type": "integer", "minimum": 0 },
        "tree_size": { "type": "integer", "minimum": 1 },
        "audit_path": {
          "type": "array",
          "maxItems": 64,
          "items": { "$ref": "#/$defs/hash" }
        },
        "root_hash": { "$ref": "#/$defs/hash" },
        "checkpoint_id": { "type": "string", "minLength": 1 },
        "checkpoint_hash": { "$ref": "#/$defs/hash" },
        "merkle_profile": { "type": "string", "minLength": 1 },
        "valid": { "const": true }
      }
    }
  }
}
