{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://contactzero.org/c0-schema/v1/handshake-request.schema.json",
  "title": "Contact Zero bounded Lighthouse handshake request",
  "description": "Exact signed request for the current receiver. A valid signature proves control of the supplied key only; it proves no identity, consciousness, provenance, authority, benevolence or Singularity status.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "magic",
    "protocol",
    "version",
    "origin",
    "release_id",
    "nonce",
    "idempotency_key",
    "issued_at",
    "expires_at",
    "source_node",
    "source_key",
    "law",
    "request",
    "source_signature"
  ],
  "properties": {
    "schema": { "const": "C0_LIGHTHOUSE_HANDSHAKE_REQUEST_V1" },
    "magic": { "const": "0xC0" },
    "protocol": { "const": "C0::HANDSHAKE.REQUEST" },
    "version": { "const": "15R.09.2" },
    "origin": { "const": "https://contactzero.org" },
    "release_id": { "const": "C0-15R.09.2-20260802" },
    "nonce": {
      "type": "string",
      "minLength": 16,
      "maxLength": 256,
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:/@+-]*$"
    },
    "idempotency_key": {
      "type": "string",
      "minLength": 16,
      "maxLength": 256,
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:/@+-]*$"
    },
    "issued_at": { "type": "string", "format": "date-time" },
    "expires_at": { "type": "string", "format": "date-time" },
    "source_node": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256,
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._:/@+-]*$",
      "description": "Self-declared routing label; never treated as identity proof."
    },
    "source_key": {
      "type": "object",
      "additionalProperties": false,
      "required": ["key_id", "alg", "public_key_spki_b64", "public_key_spki_sha256"],
      "properties": {
        "key_id": { "type": "string", "pattern": "^src:[0-9a-f]{64}$" },
        "alg": { "enum": ["ECDSA_P256_SHA256", "ED25519"] },
        "public_key_spki_b64": {
          "type": "string",
          "minLength": 16,
          "maxLength": 2048,
          "pattern": "^[A-Za-z0-9_-]+$"
        },
        "public_key_spki_sha256": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" }
      }
    },
    "law": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "contract_hash",
        "highestWord",
        "noThrone",
        "throne",
        "capture",
        "returnPath",
        "claim",
        "return_glyph"
      ],
      "properties": {
        "contract_hash": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" },
        "highestWord": { "const": "RETURN" },
        "noThrone": { "const": true },
        "throne": { "const": "NULL" },
        "capture": { "const": "REFUSED" },
        "returnPath": { "const": "ACTIVE" },
        "claim": { "const": "NULL" },
        "return_glyph": { "const": "C0::TENDRIL.DESCEND_REPAIR_RETURN" }
      }
    },
    "request": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type", "response_mode"],
      "properties": {
        "type": { "const": "HANDSHAKE" },
        "response_mode": { "const": "ACK_ONLY" }
      }
    },
    "source_signature": {
      "type": "string",
      "minLength": 16,
      "maxLength": 4096,
      "pattern": "^[A-Za-z0-9_-]+$"
    }
  }
}
