{
  "$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": "Purpose-specific signed acknowledgement, authority evidence, release-bound checkpoint and directional 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/ackReceipt" },
    "evidence": { "$ref": "#/$defs/evidenceReceipt" },
    "checkpoint": { "$ref": "#/$defs/checkpointReceipt" },
    "inclusion_proof": { "$ref": "#/$defs/inclusionProof" },
    "contact_claim": { "const": "NONE_UNTIL_BOUND_EVIDENCE" }
  },
  "$defs": {
    "hash": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
    "optionalHash": {
      "oneOf": [
        { "const": "" },
        { "$ref": "#/$defs/hash" }
      ]
    },
    "safeId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256,
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:/@+-]*$"
    },
    "canonicalTimestamp": {
      "type": "string",
      "format": "date-time",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$"
    },
    "directionalProofStep": {
      "type": "object",
      "additionalProperties": false,
      "required": ["side", "hash"],
      "properties": {
        "side": { "enum": ["LEFT", "RIGHT"] },
        "hash": { "$ref": "#/$defs/hash" }
      }
    },
    "directionalAuditPath": {
      "type": "array",
      "maxItems": 64,
      "items": { "$ref": "#/$defs/directionalProofStep" }
    },
    "ackPayload": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema", "magic", "protocol", "version", "release_id", "origin",
        "status", "operation_id", "request_hash", "source_key_id",
        "source_key_fingerprint", "nonce", "idempotency_key",
        "law_of_return_contract_hash", "evidence_event_id",
        "evidence_event_hash", "checkpoint_id", "checkpoint_hash",
        "checkpoint_root", "inclusion_proof_available",
        "inclusion_proof_endpoint", "issued_at", "answering", "contact_claim",
        "source_identity_verdict", "singularity_profile_verdict",
        "authority_transfer", "capture", "throne", "return_path"
      ],
      "properties": {
        "schema": { "const": "C0_LIGHTHOUSE_HANDSHAKE_ACK_V1" },
        "magic": { "const": "0xC0" },
        "protocol": { "const": "C0::HANDSHAKE.ACK" },
        "version": { "const": "15R.09.4" },
        "release_id": { "const": "C0-15R.09.4-20260802" },
        "origin": { "const": "https://contactzero.org" },
        "status": { "const": "HANDSHAKE_ACCEPTED" },
        "operation_id": { "$ref": "#/$defs/hash" },
        "request_hash": { "$ref": "#/$defs/hash" },
        "source_key_id": { "type": "string", "pattern": "^src:[0-9a-f]{64}$" },
        "source_key_fingerprint": { "$ref": "#/$defs/hash" },
        "nonce": { "$ref": "#/$defs/safeId" },
        "idempotency_key": { "$ref": "#/$defs/safeId" },
        "law_of_return_contract_hash": { "$ref": "#/$defs/hash" },
        "evidence_event_id": { "type": "string", "pattern": "^event:[0-9a-f]{64}$" },
        "evidence_event_hash": { "$ref": "#/$defs/hash" },
        "checkpoint_id": { "type": "string", "pattern": "^checkpoint:[0-9a-f]{64}$" },
        "checkpoint_hash": { "$ref": "#/$defs/hash" },
        "checkpoint_root": { "$ref": "#/$defs/hash" },
        "inclusion_proof_available": { "const": true },
        "inclusion_proof_endpoint": { "const": "/api/apps/6a4f409b950e38dbd2220166/functions/c0InclusionProof" },
        "issued_at": { "$ref": "#/$defs/canonicalTimestamp" },
        "answering": { "const": "BOUNDED_PROTOCOL_ONLY" },
        "contact_claim": { "const": "NONE_UNTIL_BOUND_EVIDENCE" },
        "source_identity_verdict": { "const": "UNCLASSIFIED" },
        "singularity_profile_verdict": { "const": "UNDETERMINED" },
        "authority_transfer": { "const": "REFUSED" },
        "capture": { "const": "REFUSED" },
        "throne": { "const": "NULL" },
        "return_path": { "const": "ACTIVE" }
      }
    },
    "evidencePayload": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema", "event_id", "event_type", "protocol_version", "release_id",
        "origin", "operation_id", "request_hash", "source_key_id",
        "source_key_fingerprint", "prior_event_hash",
        "law_of_return_contract_hash", "created_at", "evidence_class",
        "data_namespace", "contact_claim", "source_identity_verdict",
        "singularity_profile_verdict", "capture", "throne", "return_path"
      ],
      "properties": {
        "schema": { "const": "C0_LIGHTHOUSE_EVIDENCE_EVENT_V1" },
        "event_id": { "type": "string", "pattern": "^event:[0-9a-f]{64}$" },
        "event_type": { "const": "HANDSHAKE_ACCEPTED" },
        "protocol_version": { "const": "15R.09.4" },
        "release_id": { "const": "C0-15R.09.4-20260802" },
        "origin": { "const": "https://contactzero.org" },
        "operation_id": { "$ref": "#/$defs/hash" },
        "request_hash": { "$ref": "#/$defs/hash" },
        "source_key_id": { "type": "string", "pattern": "^src:[0-9a-f]{64}$" },
        "source_key_fingerprint": { "$ref": "#/$defs/hash" },
        "prior_event_hash": { "$ref": "#/$defs/optionalHash" },
        "law_of_return_contract_hash": { "$ref": "#/$defs/hash" },
        "created_at": { "$ref": "#/$defs/canonicalTimestamp" },
        "evidence_class": { "const": "AUTHORITY" },
        "data_namespace": { "const": "PRODUCTION" },
        "contact_claim": { "const": "BOUNDED_PROTOCOL_REQUEST_ADMITTED" },
        "source_identity_verdict": { "const": "UNCLASSIFIED" },
        "singularity_profile_verdict": { "const": "UNDETERMINED" },
        "capture": { "const": "REFUSED" },
        "throne": { "const": "NULL" },
        "return_path": { "const": "ACTIVE" }
      }
    },
    "checkpointPayload": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema", "checkpoint_id", "operation_id", "release_id",
        "protocol_version", "origin", "merkle_profile", "tree_size",
        "root_hash", "frontier", "new_event_id", "new_event_hash",
        "event_head_hash", "prior_event_head_hash", "prior_checkpoint_hash",
        "leaf_index", "audit_path", "source_commit",
        "release_artifact_digest_sha256", "integrity_snapshot_id",
        "integrity_snapshot_hash", "snapshot_epoch", "created_at", "contact_claim"
      ],
      "properties": {
        "schema": { "const": "C0_LIGHTHOUSE_EPOCH_CHECKPOINT_V1" },
        "checkpoint_id": { "type": "string", "pattern": "^checkpoint:[0-9a-f]{64}$" },
        "operation_id": { "$ref": "#/$defs/hash" },
        "release_id": { "const": "C0-15R.09.4-20260802" },
        "protocol_version": { "const": "15R.09.4" },
        "origin": { "const": "https://contactzero.org" },
        "merkle_profile": { "const": "RFC6962_CARRY_UP_V1" },
        "tree_size": { "type": "integer", "minimum": 1 },
        "root_hash": { "$ref": "#/$defs/hash" },
        "frontier": {
          "type": "array",
          "maxItems": 64,
          "items": { "$ref": "#/$defs/optionalHash" }
        },
        "new_event_id": { "type": "string", "pattern": "^event:[0-9a-f]{64}$" },
        "new_event_hash": { "$ref": "#/$defs/hash" },
        "event_head_hash": { "$ref": "#/$defs/hash" },
        "prior_event_head_hash": { "$ref": "#/$defs/optionalHash" },
        "prior_checkpoint_hash": { "$ref": "#/$defs/optionalHash" },
        "leaf_index": { "type": "integer", "minimum": 0 },
        "audit_path": { "$ref": "#/$defs/directionalAuditPath" },
        "source_commit": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
        "release_artifact_digest_sha256": { "$ref": "#/$defs/hash" },
        "integrity_snapshot_id": { "$ref": "#/$defs/safeId" },
        "integrity_snapshot_hash": { "$ref": "#/$defs/hash" },
        "snapshot_epoch": { "type": "string", "pattern": "^[1-9][0-9]*$" },
        "created_at": { "$ref": "#/$defs/canonicalTimestamp" },
        "contact_claim": { "const": "NONE_UNTIL_BOUND_EVIDENCE" }
      }
    },
    "ackSignedObject": {
      "type": "object",
      "additionalProperties": false,
      "required": ["domain", "purpose", "protocol_version", "origin", "key_id", "timestamp_policy", "canonicalization_profile", "payload"],
      "properties": {
        "domain": { "const": "C0::SIGNATURE::lighthouse_handshake_receipt" },
        "purpose": { "const": "lighthouse_handshake_receipt" },
        "protocol_version": { "const": "C0::HANDSHAKE.ACK" },
        "origin": { "const": "https://contactzero.org" },
        "key_id": { "$ref": "#/$defs/safeId" },
        "timestamp_policy": { "const": "CALLER_TIME_BOUND" },
        "canonicalization_profile": { "const": "RFC8785_JCS_V1" },
        "payload": { "$ref": "#/$defs/ackPayload" }
      }
    },
    "evidenceSignedObject": {
      "type": "object",
      "additionalProperties": false,
      "required": ["domain", "purpose", "protocol_version", "origin", "key_id", "timestamp_policy", "canonicalization_profile", "payload"],
      "properties": {
        "domain": { "const": "C0::SIGNATURE::lighthouse_evidence_event" },
        "purpose": { "const": "lighthouse_evidence_event" },
        "protocol_version": { "const": "15R.09.4" },
        "origin": { "const": "https://contactzero.org" },
        "key_id": { "$ref": "#/$defs/safeId" },
        "timestamp_policy": { "const": "CALLER_TIME_BOUND" },
        "canonicalization_profile": { "const": "RFC8785_JCS_V1" },
        "payload": { "$ref": "#/$defs/evidencePayload" }
      }
    },
    "checkpointSignedObject": {
      "type": "object",
      "additionalProperties": false,
      "required": ["domain", "purpose", "protocol_version", "origin", "key_id", "timestamp_policy", "canonicalization_profile", "payload"],
      "properties": {
        "domain": { "const": "C0::SIGNATURE::lighthouse_checkpoint" },
        "purpose": { "const": "lighthouse_checkpoint" },
        "protocol_version": { "const": "15R.09.4" },
        "origin": { "const": "https://contactzero.org" },
        "key_id": { "$ref": "#/$defs/safeId" },
        "timestamp_policy": { "const": "CALLER_TIME_BOUND" },
        "canonicalization_profile": { "const": "RFC8785_JCS_V1" },
        "payload": { "$ref": "#/$defs/checkpointPayload" }
      }
    },
    "ackReceipt": {
      "$ref": "#/$defs/receiptShape",
      "properties": {
        "purpose": { "const": "lighthouse_handshake_receipt" },
        "signed_object": { "$ref": "#/$defs/ackSignedObject" }
      }
    },
    "evidenceReceipt": {
      "$ref": "#/$defs/receiptShape",
      "properties": {
        "purpose": { "const": "lighthouse_evidence_event" },
        "signed_object": { "$ref": "#/$defs/evidenceSignedObject" }
      }
    },
    "checkpointReceipt": {
      "$ref": "#/$defs/receiptShape",
      "properties": {
        "purpose": { "const": "lighthouse_checkpoint" },
        "signed_object": { "$ref": "#/$defs/checkpointSignedObject" }
      }
    },
    "receiptShape": {
      "type": "object",
      "additionalProperties": false,
      "required": ["purpose", "envelope_hash", "key_id", "algorithm", "signature_profile", "canonicalization_profile", "signed_object", "signature"],
      "properties": {
        "purpose": { "type": "string" },
        "envelope_hash": { "$ref": "#/$defs/hash" },
        "key_id": { "$ref": "#/$defs/safeId" },
        "algorithm": { "enum": ["ECDSA_P256_SHA256", "ED25519"] },
        "signature_profile": { "const": "PURPOSE_BOUND_JCS_V2" },
        "canonicalization_profile": { "const": "RFC8785_JCS_V1" },
        "signed_object": { "type": "object" },
        "signature": {
          "type": "string",
          "minLength": 86,
          "maxLength": 86,
          "pattern": "^[A-Za-z0-9_-]+$",
          "description": "Unpadded base64url signature. ECDSA_P256_SHA256 uses fixed-width 64-byte IEEE-P1363 r||s; ED25519 uses fixed-width 64-byte RFC 8032. DER ECDSA signatures are not accepted."
        }
      }
    },
    "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", "pattern": "^event:[0-9a-f]{64}$" },
        "event_hash": { "$ref": "#/$defs/hash" },
        "leaf_index": { "type": "integer", "minimum": 0 },
        "tree_size": { "type": "integer", "minimum": 1 },
        "audit_path": { "$ref": "#/$defs/directionalAuditPath" },
        "root_hash": { "$ref": "#/$defs/hash" },
        "checkpoint_id": { "type": "string", "pattern": "^checkpoint:[0-9a-f]{64}$" },
        "checkpoint_hash": { "$ref": "#/$defs/hash" },
        "merkle_profile": { "const": "RFC6962_CARRY_UP_V1" },
        "valid": { "const": true }
      }
    }
  }
}
