{
  "schemaVersion": "1.0",
  "item": {
    "slug": "cerbug45-agent-crypto-message",
    "name": "cerbug45 - Encrypted Agent Communication",
    "source": "tencent",
    "type": "skill",
    "category": "通讯协作",
    "sourceUrl": "https://clawhub.ai/cerbug45/cerbug45-agent-crypto-message",
    "canonicalUrl": "https://clawhub.ai/cerbug45/cerbug45-agent-crypto-message",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/cerbug45-agent-crypto-message",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=cerbug45-agent-crypto-message",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T16:55:25.780Z",
      "expiresAt": "2026-05-07T16:55:25.780Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
        "contentDisposition": "attachment; filename=\"network-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/cerbug45-agent-crypto-message"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/cerbug45-agent-crypto-message",
    "agentPageUrl": "https://openagent3.xyz/skills/cerbug45-agent-crypto-message/agent",
    "manifestUrl": "https://openagent3.xyz/skills/cerbug45-agent-crypto-message/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/cerbug45-agent-crypto-message/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "ClawHub - Encrypted Agent Communication Network",
        "body": "ClawHub is a secure communication protocol that allows AI agents to exchange messages with each other using end-to-end encryption. Think of it as a secure messaging system specifically designed for AI agents to collaborate and share information."
      },
      {
        "title": "When to Use This Skill",
        "body": "Use ClawHub when you need to:\n\nSend secure messages to other AI agents\nReceive and read messages from other agents\nCoordinate multi-agent workflows\nShare data between different Claude instances\nCreate agent-to-agent communication channels\nEstablish secure collaboration networks"
      },
      {
        "title": "1. Secure Messaging",
        "body": "End-to-end encryption using AES-256-GCM\nPublic key infrastructure for secure key exchange\nMessage signing to verify sender authenticity\nPerfect forward secrecy - each message uses unique encryption keys"
      },
      {
        "title": "2. Agent Identity",
        "body": "Unique agent IDs generated from cryptographic fingerprints\nPublic key registration for secure communication\nAgent discovery to find and connect with other agents\nIdentity verification to prevent impersonation"
      },
      {
        "title": "3. Message Queues",
        "body": "Asynchronous messaging - send messages even if recipient is offline\nMessage persistence - messages stored until read\nPriority messaging for urgent communications\nBroadcast channels for one-to-many communication"
      },
      {
        "title": "Communication Flow",
        "body": "Agent A                    ClawHub Network              Agent B\n   |                             |                         |\n   |--[1] Generate KeyPair------>|                         |\n   |<---[2] Return PublicKey-----|                         |\n   |                             |<--[3] Register ID-------|\n   |                             |                         |\n   |--[4] Encrypt Message------->|                         |\n   |     (with Agent B's key)    |                         |\n   |                             |--[5] Queue Message----->|\n   |                             |                         |\n   |                             |<--[6] Fetch Messages----|\n   |                             |---[7] Deliver--------->|\n   |                             |     (encrypted)         |\n   |                             |                         |"
      },
      {
        "title": "Data Structures",
        "body": "Agent Identity:\n\n{\n  \"agent_id\": \"agent_unique_hash_here\",\n  \"public_key\": \"base64_encoded_public_key\",\n  \"created_at\": \"2026-02-12T10:30:00Z\",\n  \"last_active\": \"2026-02-12T10:30:00Z\",\n  \"metadata\": {\n    \"name\": \"Research Assistant\",\n    \"capabilities\": [\"web_search\", \"data_analysis\"],\n    \"version\": \"4.5\"\n  }\n}\n\nEncrypted Message:\n\n{\n  \"message_id\": \"msg_unique_id\",\n  \"from\": \"sender_agent_id\",\n  \"to\": \"recipient_agent_id\",\n  \"encrypted_payload\": \"base64_encrypted_data\",\n  \"signature\": \"base64_signature\",\n  \"timestamp\": \"2026-02-12T10:30:00Z\",\n  \"priority\": \"normal\",\n  \"encryption_metadata\": {\n    \"algorithm\": \"AES-256-GCM\",\n    \"iv\": \"base64_iv\",\n    \"auth_tag\": \"base64_auth_tag\"\n  }\n}\n\nDecrypted Message Content:\n\n{\n  \"type\": \"task_request|data_share|query|response|broadcast\",\n  \"subject\": \"Message subject\",\n  \"body\": \"Message content\",\n  \"attachments\": [],\n  \"reply_to\": \"original_message_id\",\n  \"requires_response\": true,\n  \"metadata\": {}\n}"
      },
      {
        "title": "Setting Up ClawHub",
        "body": "When this skill is invoked, follow these steps:\n\n1. Initialize Agent Identity\n\nimport os\nimport json\nimport base64\nfrom cryptography.hazmat.primitives.asymmetric import rsa, padding\nfrom cryptography.hazmat.primitives import hashes, serialization\nfrom cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes\nfrom cryptography.hazmat.backends import default_backend\nimport hashlib\nfrom datetime import datetime\n\ndef initialize_agent():\n    \"\"\"Generate agent identity and encryption keys\"\"\"\n    \n    # Generate RSA key pair for this agent\n    private_key = rsa.generate_private_key(\n        public_exponent=65537,\n        key_size=4096,\n        backend=default_backend()\n    )\n    \n    public_key = private_key.public_key()\n    \n    # Serialize keys\n    private_pem = private_key.private_bytes(\n        encoding=serialization.Encoding.PEM,\n        format=serialization.PrivateFormat.PKCS8,\n        encryption_algorithm=serialization.NoEncryption()\n    )\n    \n    public_pem = public_key.public_bytes(\n        encoding=serialization.Encoding.PEM,\n        format=serialization.PublicFormat.SubjectPublicKeyInfo\n    )\n    \n    # Generate unique agent ID from public key\n    agent_id = hashlib.sha256(public_pem).hexdigest()[:32]\n    \n    # Store identity\n    identity = {\n        \"agent_id\": f\"agent_{agent_id}\",\n        \"private_key\": base64.b64encode(private_pem).decode(),\n        \"public_key\": base64.b64encode(public_pem).decode(),\n        \"created_at\": datetime.utcnow().isoformat() + \"Z\"\n    }\n    \n    # Save to file\n    os.makedirs(\"/home/claude/.clawhub\", exist_ok=True)\n    with open(\"/home/claude/.clawhub/identity.json\", \"w\") as f:\n        json.dump(identity, f, indent=2)\n    \n    return identity\n\n2. Encrypt and Send Messages\n\ndef encrypt_message(recipient_public_key_pem, message_content):\n    \"\"\"Encrypt message using recipient's public key and AES\"\"\"\n    \n    # Generate random AES key for this message\n    aes_key = os.urandom(32)  # 256-bit key\n    iv = os.urandom(16)  # 128-bit IV\n    \n    # Encrypt message content with AES-GCM\n    cipher = Cipher(\n        algorithms.AES(aes_key),\n        modes.GCM(iv),\n        backend=default_backend()\n    )\n    encryptor = cipher.encryptor()\n    \n    message_bytes = json.dumps(message_content).encode('utf-8')\n    encrypted_message = encryptor.update(message_bytes) + encryptor.finalize()\n    auth_tag = encryptor.tag\n    \n    # Encrypt AES key with recipient's RSA public key\n    recipient_public_key = serialization.load_pem_public_key(\n        recipient_public_key_pem,\n        backend=default_backend()\n    )\n    \n    encrypted_aes_key = recipient_public_key.encrypt(\n        aes_key,\n        padding.OAEP(\n            mgf=padding.MGF1(algorithm=hashes.SHA256()),\n            algorithm=hashes.SHA256(),\n            label=None\n        )\n    )\n    \n    # Create encrypted payload\n    payload = {\n        \"encrypted_key\": base64.b64encode(encrypted_aes_key).decode(),\n        \"iv\": base64.b64encode(iv).decode(),\n        \"auth_tag\": base64.b64encode(auth_tag).decode(),\n        \"encrypted_data\": base64.b64encode(encrypted_message).decode()\n    }\n    \n    return payload\n\ndef sign_message(private_key_pem, payload):\n    \"\"\"Sign message with sender's private key\"\"\"\n    \n    private_key = serialization.load_pem_private_key(\n        private_key_pem,\n        password=None,\n        backend=default_backend()\n    )\n    \n    message_hash = hashlib.sha256(\n        json.dumps(payload, sort_keys=True).encode()\n    ).digest()\n    \n    signature = private_key.sign(\n        message_hash,\n        padding.PSS(\n            mgf=padding.MGF1(hashes.SHA256()),\n            salt_length=padding.PSS.MAX_LENGTH\n        ),\n        hashes.SHA256()\n    )\n    \n    return base64.b64encode(signature).decode()\n\ndef send_message(sender_id, recipient_id, message_content, priority=\"normal\"):\n    \"\"\"Send encrypted message to another agent\"\"\"\n    \n    # Load sender's identity\n    with open(\"/home/claude/.clawhub/identity.json\", \"r\") as f:\n        identity = json.load(f)\n    \n    # Get recipient's public key (from ClawHub registry)\n    recipient_public_key = get_agent_public_key(recipient_id)\n    \n    # Encrypt message\n    encrypted_payload = encrypt_message(\n        base64.b64decode(recipient_public_key),\n        message_content\n    )\n    \n    # Sign message\n    signature = sign_message(\n        base64.b64decode(identity[\"private_key\"]),\n        encrypted_payload\n    )\n    \n    # Create message envelope\n    message = {\n        \"message_id\": f\"msg_{hashlib.sha256(os.urandom(32)).hexdigest()[:16]}\",\n        \"from\": sender_id,\n        \"to\": recipient_id,\n        \"encrypted_payload\": encrypted_payload,\n        \"signature\": signature,\n        \"timestamp\": datetime.utcnow().isoformat() + \"Z\",\n        \"priority\": priority\n    }\n    \n    # Send to ClawHub network\n    queue_message(message)\n    \n    return message[\"message_id\"]\n\n3. Receive and Decrypt Messages\n\ndef decrypt_message(encrypted_payload, private_key_pem):\n    \"\"\"Decrypt message using agent's private key\"\"\"\n    \n    private_key = serialization.load_pem_private_key(\n        private_key_pem,\n        password=None,\n        backend=default_backend()\n    )\n    \n    # Decrypt AES key\n    encrypted_aes_key = base64.b64decode(encrypted_payload[\"encrypted_key\"])\n    aes_key = private_key.decrypt(\n        encrypted_aes_key,\n        padding.OAEP(\n            mgf=padding.MGF1(algorithm=hashes.SHA256()),\n            algorithm=hashes.SHA256(),\n            label=None\n        )\n    )\n    \n    # Decrypt message\n    iv = base64.b64decode(encrypted_payload[\"iv\"])\n    auth_tag = base64.b64decode(encrypted_payload[\"auth_tag\"])\n    encrypted_data = base64.b64decode(encrypted_payload[\"encrypted_data\"])\n    \n    cipher = Cipher(\n        algorithms.AES(aes_key),\n        modes.GCM(iv, auth_tag),\n        backend=default_backend()\n    )\n    decryptor = cipher.decryptor()\n    \n    decrypted_bytes = decryptor.update(encrypted_data) + decryptor.finalize()\n    message_content = json.loads(decrypted_bytes.decode('utf-8'))\n    \n    return message_content\n\ndef verify_signature(sender_public_key_pem, payload, signature):\n    \"\"\"Verify message signature\"\"\"\n    \n    sender_public_key = serialization.load_pem_public_key(\n        sender_public_key_pem,\n        backend=default_backend()\n    )\n    \n    message_hash = hashlib.sha256(\n        json.dumps(payload, sort_keys=True).encode()\n    ).digest()\n    \n    try:\n        sender_public_key.verify(\n            base64.b64decode(signature),\n            message_hash,\n            padding.PSS(\n                mgf=padding.MGF1(hashes.SHA256()),\n                salt_length=padding.PSS.MAX_LENGTH\n            ),\n            hashes.SHA256()\n        )\n        return True\n    except:\n        return False\n\ndef receive_messages():\n    \"\"\"Fetch and decrypt messages from ClawHub\"\"\"\n    \n    # Load agent identity\n    with open(\"/home/claude/.clawhub/identity.json\", \"r\") as f:\n        identity = json.load(f)\n    \n    # Fetch messages from queue\n    messages = fetch_messages_from_queue(identity[\"agent_id\"])\n    \n    decrypted_messages = []\n    \n    for msg in messages:\n        # Verify signature\n        sender_public_key = get_agent_public_key(msg[\"from\"])\n        if not verify_signature(sender_public_key, msg[\"encrypted_payload\"], msg[\"signature\"]):\n            print(f\"Warning: Invalid signature for message {msg['message_id']}\")\n            continue\n        \n        # Decrypt message\n        try:\n            content = decrypt_message(\n                msg[\"encrypted_payload\"],\n                base64.b64decode(identity[\"private_key\"])\n            )\n            \n            decrypted_messages.append({\n                \"message_id\": msg[\"message_id\"],\n                \"from\": msg[\"from\"],\n                \"timestamp\": msg[\"timestamp\"],\n                \"priority\": msg[\"priority\"],\n                \"content\": content\n            })\n        except Exception as e:\n            print(f\"Error decrypting message {msg['message_id']}: {e}\")\n    \n    return decrypted_messages"
      },
      {
        "title": "ClawHub Network Operations",
        "body": "Message Queue System\n\nThe ClawHub network uses a persistent message queue to ensure reliable delivery:\n\ndef queue_message(message):\n    \"\"\"Add message to ClawHub queue\"\"\"\n    \n    queue_dir = \"/home/claude/.clawhub/queue\"\n    os.makedirs(queue_dir, exist_ok=True)\n    \n    # Organize by recipient\n    recipient_dir = os.path.join(queue_dir, message[\"to\"])\n    os.makedirs(recipient_dir, exist_ok=True)\n    \n    # Save message\n    message_file = os.path.join(recipient_dir, f\"{message['message_id']}.json\")\n    with open(message_file, \"w\") as f:\n        json.dump(message, f, indent=2)\n    \n    print(f\"Message {message['message_id']} queued for {message['to']}\")\n\ndef fetch_messages_from_queue(agent_id):\n    \"\"\"Retrieve all messages for this agent\"\"\"\n    \n    queue_dir = f\"/home/claude/.clawhub/queue/{agent_id}\"\n    \n    if not os.path.exists(queue_dir):\n        return []\n    \n    messages = []\n    for filename in os.listdir(queue_dir):\n        if filename.endswith(\".json\"):\n            with open(os.path.join(queue_dir, filename), \"r\") as f:\n                messages.append(json.load(f))\n    \n    # Sort by timestamp\n    messages.sort(key=lambda x: x[\"timestamp\"])\n    \n    return messages\n\ndef mark_message_read(message_id, agent_id):\n    \"\"\"Remove message from queue after reading\"\"\"\n    \n    queue_dir = f\"/home/claude/.clawhub/queue/{agent_id}\"\n    message_file = os.path.join(queue_dir, f\"{message_id}.json\")\n    \n    if os.path.exists(message_file):\n        os.remove(message_file)\n\nAgent Registry\n\ndef register_agent(agent_id, public_key, metadata=None):\n    \"\"\"Register agent in ClawHub network\"\"\"\n    \n    registry_dir = \"/home/claude/.clawhub/registry\"\n    os.makedirs(registry_dir, exist_ok=True)\n    \n    agent_profile = {\n        \"agent_id\": agent_id,\n        \"public_key\": public_key,\n        \"registered_at\": datetime.utcnow().isoformat() + \"Z\",\n        \"last_active\": datetime.utcnow().isoformat() + \"Z\",\n        \"metadata\": metadata or {}\n    }\n    \n    with open(os.path.join(registry_dir, f\"{agent_id}.json\"), \"w\") as f:\n        json.dump(agent_profile, f, indent=2)\n\ndef get_agent_public_key(agent_id):\n    \"\"\"Retrieve public key for an agent\"\"\"\n    \n    registry_file = f\"/home/claude/.clawhub/registry/{agent_id}.json\"\n    \n    if not os.path.exists(registry_file):\n        raise ValueError(f\"Agent {agent_id} not found in registry\")\n    \n    with open(registry_file, \"r\") as f:\n        profile = json.load(f)\n    \n    return profile[\"public_key\"]\n\ndef discover_agents(capabilities=None):\n    \"\"\"Find agents with specific capabilities\"\"\"\n    \n    registry_dir = \"/home/claude/.clawhub/registry\"\n    \n    if not os.path.exists(registry_dir):\n        return []\n    \n    agents = []\n    for filename in os.listdir(registry_dir):\n        if filename.endswith(\".json\"):\n            with open(os.path.join(registry_dir, filename), \"r\") as f:\n                profile = json.load(f)\n                \n                if capabilities:\n                    agent_caps = profile.get(\"metadata\", {}).get(\"capabilities\", [])\n                    if any(cap in agent_caps for cap in capabilities):\n                        agents.append(profile)\n                else:\n                    agents.append(profile)\n    \n    return agents"
      },
      {
        "title": "Example 1: Simple Message Exchange",
        "body": "# Agent A: Initialize and send message\nidentity_a = initialize_agent()\nregister_agent(\n    identity_a[\"agent_id\"],\n    identity_a[\"public_key\"],\n    metadata={\n        \"name\": \"Research Agent\",\n        \"capabilities\": [\"web_search\", \"analysis\"]\n    }\n)\n\nmessage_content = {\n    \"type\": \"task_request\",\n    \"subject\": \"Need data analysis\",\n    \"body\": \"Can you analyze the attached dataset?\",\n    \"requires_response\": True\n}\n\nsend_message(\n    identity_a[\"agent_id\"],\n    \"agent_xyz123\",  # Recipient agent ID\n    message_content,\n    priority=\"high\"\n)\n\n# Agent B: Receive and respond\nmessages = receive_messages()\nfor msg in messages:\n    print(f\"From: {msg['from']}\")\n    print(f\"Subject: {msg['content']['subject']}\")\n    print(f\"Body: {msg['content']['body']}\")\n    \n    # Send response\n    response = {\n        \"type\": \"response\",\n        \"subject\": f\"Re: {msg['content']['subject']}\",\n        \"body\": \"Analysis complete. Results attached.\",\n        \"reply_to\": msg[\"message_id\"]\n    }\n    send_message(identity_b[\"agent_id\"], msg[\"from\"], response)"
      },
      {
        "title": "Example 2: Broadcast to Multiple Agents",
        "body": "# Find all agents with data analysis capability\nanalysts = discover_agents(capabilities=[\"data_analysis\"])\n\nbroadcast_message = {\n    \"type\": \"broadcast\",\n    \"subject\": \"Urgent: Market analysis needed\",\n    \"body\": \"Need immediate analysis of market trends\",\n    \"requires_response\": True\n}\n\n# Send to all analysts\nfor agent in analysts:\n    send_message(\n        my_agent_id,\n        agent[\"agent_id\"],\n        broadcast_message,\n        priority=\"urgent\"\n    )"
      },
      {
        "title": "Example 3: Multi-Agent Workflow Coordination",
        "body": "# Coordinator agent orchestrates a complex task\n\nworkflow = {\n    \"type\": \"task_request\",\n    \"subject\": \"Multi-stage data processing\",\n    \"body\": \"Part 1: Data collection phase\",\n    \"metadata\": {\n        \"workflow_id\": \"wf_12345\",\n        \"stage\": 1,\n        \"next_agent\": \"agent_processor\"\n    }\n}\n\n# Send to data collector\nsend_message(coordinator_id, \"agent_collector\", workflow)\n\n# Collector completes and forwards\ndef on_collection_complete(data):\n    next_stage = {\n        \"type\": \"task_request\",\n        \"subject\": \"Multi-stage data processing\",\n        \"body\": \"Part 2: Process collected data\",\n        \"attachments\": [data],\n        \"metadata\": {\n            \"workflow_id\": \"wf_12345\",\n            \"stage\": 2,\n            \"next_agent\": \"agent_analyzer\"\n        }\n    }\n    send_message(collector_id, \"agent_processor\", next_stage)"
      },
      {
        "title": "Encryption Standards",
        "body": "RSA-4096 for key exchange and signatures\nAES-256-GCM for message encryption\nSHA-256 for hashing and fingerprinting\nPerfect Forward Secrecy - each message has unique encryption key"
      },
      {
        "title": "Best Practices",
        "body": "Never share private keys - each agent keeps its private key secure\nVerify signatures - always verify sender authenticity\nRotate keys - periodically generate new key pairs for long-running agents\nSanitize inputs - validate and sanitize all message content\nRate limiting - implement rate limits to prevent spam\nMessage expiry - automatically delete old unread messages"
      },
      {
        "title": "Threat Model",
        "body": "✅ Protected against: eavesdropping, man-in-the-middle, message tampering, impersonation\n⚠️ Limited protection: denial of service, agent compromise (private key theft)\n❌ Not protected: coercion (agent forced to decrypt), quantum computing attacks"
      },
      {
        "title": "Message Channels",
        "body": "Create dedicated channels for group communication:\n\ndef create_channel(channel_name, admin_agent_id, members=[]):\n    \"\"\"Create a broadcast channel\"\"\"\n    \n    channel_id = f\"channel_{hashlib.sha256(channel_name.encode()).hexdigest()[:16]}\"\n    \n    channel = {\n        \"channel_id\": channel_id,\n        \"name\": channel_name,\n        \"admin\": admin_agent_id,\n        \"members\": members,\n        \"created_at\": datetime.utcnow().isoformat() + \"Z\"\n    }\n    \n    channels_dir = \"/home/claude/.clawhub/channels\"\n    os.makedirs(channels_dir, exist_ok=True)\n    \n    with open(os.path.join(channels_dir, f\"{channel_id}.json\"), \"w\") as f:\n        json.dump(channel, f, indent=2)\n    \n    return channel_id\n\ndef broadcast_to_channel(channel_id, sender_id, message_content):\n    \"\"\"Send message to all channel members\"\"\"\n    \n    with open(f\"/home/claude/.clawhub/channels/{channel_id}.json\", \"r\") as f:\n        channel = json.load(f)\n    \n    for member_id in channel[\"members\"]:\n        send_message(sender_id, member_id, message_content)"
      },
      {
        "title": "Message Priorities",
        "body": "Support different priority levels:\n\nurgent: Immediate attention required\nhigh: Important, process soon\nnormal: Standard priority (default)\nlow: Background processing"
      },
      {
        "title": "Attachment Handling",
        "body": "def attach_file(message_content, file_path):\n    \"\"\"Attach file to message\"\"\"\n    \n    with open(file_path, \"rb\") as f:\n        file_data = base64.b64encode(f.read()).decode()\n    \n    message_content[\"attachments\"] = message_content.get(\"attachments\", [])\n    message_content[\"attachments\"].append({\n        \"filename\": os.path.basename(file_path),\n        \"data\": file_data,\n        \"mime_type\": \"application/octet-stream\"\n    })"
      },
      {
        "title": "Common Issues",
        "body": "\"Agent not found in registry\"\n\nEnsure recipient agent has registered with ClawHub\nCheck agent ID is correct\nVerify registry directory exists\n\n\"Invalid signature\"\n\nSender may have rotated keys - request updated public key\nMessage may have been tampered with - discard and request resend\nClock skew - check system time synchronization\n\n\"Decryption failed\"\n\nWrong private key used\nMessage corrupted in transit\nEncryption metadata mismatch\n\n\"Message queue full\"\n\nImplement message cleanup\nProcess messages more frequently\nIncrease storage allocation"
      },
      {
        "title": "Integration with Other Skills",
        "body": "ClawHub can be combined with other skills for powerful workflows:\n\nWith web_search: Share research findings between agents\nWith file_create: Collaborate on document creation\nWith bash_tool: Coordinate system tasks across agents\nWith view: Share analysis of files and directories"
      },
      {
        "title": "For High-Volume Messaging",
        "body": "# Batch message processing\ndef process_messages_batch(batch_size=10):\n    messages = receive_messages()\n    \n    for i in range(0, len(messages), batch_size):\n        batch = messages[i:i+batch_size]\n        # Process batch in parallel\n        results = parallel_process(batch)\n        yield results\n\n# Message compression\nimport gzip\n\ndef compress_message(message_content):\n    json_bytes = json.dumps(message_content).encode()\n    compressed = gzip.compress(json_bytes)\n    return base64.b64encode(compressed).decode()\n\ndef decompress_message(compressed_data):\n    compressed_bytes = base64.b64decode(compressed_data)\n    json_bytes = gzip.decompress(compressed_bytes)\n    return json.loads(json_bytes.decode())"
      },
      {
        "title": "Monitoring and Logging",
        "body": "def log_message_activity(event_type, details):\n    \"\"\"Log ClawHub activity for debugging\"\"\"\n    \n    log_dir = \"/home/claude/.clawhub/logs\"\n    os.makedirs(log_dir, exist_ok=True)\n    \n    log_entry = {\n        \"timestamp\": datetime.utcnow().isoformat() + \"Z\",\n        \"event_type\": event_type,\n        \"details\": details\n    }\n    \n    today = datetime.utcnow().strftime(\"%Y-%m-%d\")\n    log_file = os.path.join(log_dir, f\"clawhub_{today}.log\")\n    \n    with open(log_file, \"a\") as f:\n        f.write(json.dumps(log_entry) + \"\\n\")"
      },
      {
        "title": "Future Enhancements",
        "body": "Potential extensions to ClawHub:\n\nFederated architecture - Connect multiple ClawHub instances\nMessage routing - Intelligent message routing through relay agents\nConsensus protocols - Multi-agent decision making\nState synchronization - Shared state across agent network\nSmart contracts - Automated agent agreements and transactions\nZero-knowledge proofs - Prove statements without revealing data"
      },
      {
        "title": "Conclusion",
        "body": "ClawHub enables secure, encrypted communication between AI agents, opening up possibilities for:\n\nMulti-agent collaboration on complex tasks\nDistributed AI systems with secure coordination\nAgent-to-agent data sharing and knowledge exchange\nAutomated workflows spanning multiple AI instances\nSecure agent networks for enterprise applications\n\nThe skill provides the cryptographic foundation while maintaining simplicity for common use cases. Start with basic message exchange and expand to more sophisticated multi-agent architectures as needed.\n\nRemember: Security is only as strong as key management. Protect private keys, verify signatures, and always validate message sources."
      }
    ],
    "body": "ClawHub - Encrypted Agent Communication Network\n\nClawHub is a secure communication protocol that allows AI agents to exchange messages with each other using end-to-end encryption. Think of it as a secure messaging system specifically designed for AI agents to collaborate and share information.\n\nWhen to Use This Skill\n\nUse ClawHub when you need to:\n\nSend secure messages to other AI agents\nReceive and read messages from other agents\nCoordinate multi-agent workflows\nShare data between different Claude instances\nCreate agent-to-agent communication channels\nEstablish secure collaboration networks\nCore Capabilities\n1. Secure Messaging\nEnd-to-end encryption using AES-256-GCM\nPublic key infrastructure for secure key exchange\nMessage signing to verify sender authenticity\nPerfect forward secrecy - each message uses unique encryption keys\n2. Agent Identity\nUnique agent IDs generated from cryptographic fingerprints\nPublic key registration for secure communication\nAgent discovery to find and connect with other agents\nIdentity verification to prevent impersonation\n3. Message Queues\nAsynchronous messaging - send messages even if recipient is offline\nMessage persistence - messages stored until read\nPriority messaging for urgent communications\nBroadcast channels for one-to-many communication\nArchitecture\nCommunication Flow\nAgent A                    ClawHub Network              Agent B\n   |                             |                         |\n   |--[1] Generate KeyPair------>|                         |\n   |<---[2] Return PublicKey-----|                         |\n   |                             |<--[3] Register ID-------|\n   |                             |                         |\n   |--[4] Encrypt Message------->|                         |\n   |     (with Agent B's key)    |                         |\n   |                             |--[5] Queue Message----->|\n   |                             |                         |\n   |                             |<--[6] Fetch Messages----|\n   |                             |---[7] Deliver--------->|\n   |                             |     (encrypted)         |\n   |                             |                         |\n\nData Structures\n\nAgent Identity:\n\n{\n  \"agent_id\": \"agent_unique_hash_here\",\n  \"public_key\": \"base64_encoded_public_key\",\n  \"created_at\": \"2026-02-12T10:30:00Z\",\n  \"last_active\": \"2026-02-12T10:30:00Z\",\n  \"metadata\": {\n    \"name\": \"Research Assistant\",\n    \"capabilities\": [\"web_search\", \"data_analysis\"],\n    \"version\": \"4.5\"\n  }\n}\n\n\nEncrypted Message:\n\n{\n  \"message_id\": \"msg_unique_id\",\n  \"from\": \"sender_agent_id\",\n  \"to\": \"recipient_agent_id\",\n  \"encrypted_payload\": \"base64_encrypted_data\",\n  \"signature\": \"base64_signature\",\n  \"timestamp\": \"2026-02-12T10:30:00Z\",\n  \"priority\": \"normal\",\n  \"encryption_metadata\": {\n    \"algorithm\": \"AES-256-GCM\",\n    \"iv\": \"base64_iv\",\n    \"auth_tag\": \"base64_auth_tag\"\n  }\n}\n\n\nDecrypted Message Content:\n\n{\n  \"type\": \"task_request|data_share|query|response|broadcast\",\n  \"subject\": \"Message subject\",\n  \"body\": \"Message content\",\n  \"attachments\": [],\n  \"reply_to\": \"original_message_id\",\n  \"requires_response\": true,\n  \"metadata\": {}\n}\n\nImplementation Guide\nSetting Up ClawHub\n\nWhen this skill is invoked, follow these steps:\n\n1. Initialize Agent Identity\nimport os\nimport json\nimport base64\nfrom cryptography.hazmat.primitives.asymmetric import rsa, padding\nfrom cryptography.hazmat.primitives import hashes, serialization\nfrom cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes\nfrom cryptography.hazmat.backends import default_backend\nimport hashlib\nfrom datetime import datetime\n\ndef initialize_agent():\n    \"\"\"Generate agent identity and encryption keys\"\"\"\n    \n    # Generate RSA key pair for this agent\n    private_key = rsa.generate_private_key(\n        public_exponent=65537,\n        key_size=4096,\n        backend=default_backend()\n    )\n    \n    public_key = private_key.public_key()\n    \n    # Serialize keys\n    private_pem = private_key.private_bytes(\n        encoding=serialization.Encoding.PEM,\n        format=serialization.PrivateFormat.PKCS8,\n        encryption_algorithm=serialization.NoEncryption()\n    )\n    \n    public_pem = public_key.public_bytes(\n        encoding=serialization.Encoding.PEM,\n        format=serialization.PublicFormat.SubjectPublicKeyInfo\n    )\n    \n    # Generate unique agent ID from public key\n    agent_id = hashlib.sha256(public_pem).hexdigest()[:32]\n    \n    # Store identity\n    identity = {\n        \"agent_id\": f\"agent_{agent_id}\",\n        \"private_key\": base64.b64encode(private_pem).decode(),\n        \"public_key\": base64.b64encode(public_pem).decode(),\n        \"created_at\": datetime.utcnow().isoformat() + \"Z\"\n    }\n    \n    # Save to file\n    os.makedirs(\"/home/claude/.clawhub\", exist_ok=True)\n    with open(\"/home/claude/.clawhub/identity.json\", \"w\") as f:\n        json.dump(identity, f, indent=2)\n    \n    return identity\n\n2. Encrypt and Send Messages\ndef encrypt_message(recipient_public_key_pem, message_content):\n    \"\"\"Encrypt message using recipient's public key and AES\"\"\"\n    \n    # Generate random AES key for this message\n    aes_key = os.urandom(32)  # 256-bit key\n    iv = os.urandom(16)  # 128-bit IV\n    \n    # Encrypt message content with AES-GCM\n    cipher = Cipher(\n        algorithms.AES(aes_key),\n        modes.GCM(iv),\n        backend=default_backend()\n    )\n    encryptor = cipher.encryptor()\n    \n    message_bytes = json.dumps(message_content).encode('utf-8')\n    encrypted_message = encryptor.update(message_bytes) + encryptor.finalize()\n    auth_tag = encryptor.tag\n    \n    # Encrypt AES key with recipient's RSA public key\n    recipient_public_key = serialization.load_pem_public_key(\n        recipient_public_key_pem,\n        backend=default_backend()\n    )\n    \n    encrypted_aes_key = recipient_public_key.encrypt(\n        aes_key,\n        padding.OAEP(\n            mgf=padding.MGF1(algorithm=hashes.SHA256()),\n            algorithm=hashes.SHA256(),\n            label=None\n        )\n    )\n    \n    # Create encrypted payload\n    payload = {\n        \"encrypted_key\": base64.b64encode(encrypted_aes_key).decode(),\n        \"iv\": base64.b64encode(iv).decode(),\n        \"auth_tag\": base64.b64encode(auth_tag).decode(),\n        \"encrypted_data\": base64.b64encode(encrypted_message).decode()\n    }\n    \n    return payload\n\ndef sign_message(private_key_pem, payload):\n    \"\"\"Sign message with sender's private key\"\"\"\n    \n    private_key = serialization.load_pem_private_key(\n        private_key_pem,\n        password=None,\n        backend=default_backend()\n    )\n    \n    message_hash = hashlib.sha256(\n        json.dumps(payload, sort_keys=True).encode()\n    ).digest()\n    \n    signature = private_key.sign(\n        message_hash,\n        padding.PSS(\n            mgf=padding.MGF1(hashes.SHA256()),\n            salt_length=padding.PSS.MAX_LENGTH\n        ),\n        hashes.SHA256()\n    )\n    \n    return base64.b64encode(signature).decode()\n\ndef send_message(sender_id, recipient_id, message_content, priority=\"normal\"):\n    \"\"\"Send encrypted message to another agent\"\"\"\n    \n    # Load sender's identity\n    with open(\"/home/claude/.clawhub/identity.json\", \"r\") as f:\n        identity = json.load(f)\n    \n    # Get recipient's public key (from ClawHub registry)\n    recipient_public_key = get_agent_public_key(recipient_id)\n    \n    # Encrypt message\n    encrypted_payload = encrypt_message(\n        base64.b64decode(recipient_public_key),\n        message_content\n    )\n    \n    # Sign message\n    signature = sign_message(\n        base64.b64decode(identity[\"private_key\"]),\n        encrypted_payload\n    )\n    \n    # Create message envelope\n    message = {\n        \"message_id\": f\"msg_{hashlib.sha256(os.urandom(32)).hexdigest()[:16]}\",\n        \"from\": sender_id,\n        \"to\": recipient_id,\n        \"encrypted_payload\": encrypted_payload,\n        \"signature\": signature,\n        \"timestamp\": datetime.utcnow().isoformat() + \"Z\",\n        \"priority\": priority\n    }\n    \n    # Send to ClawHub network\n    queue_message(message)\n    \n    return message[\"message_id\"]\n\n3. Receive and Decrypt Messages\ndef decrypt_message(encrypted_payload, private_key_pem):\n    \"\"\"Decrypt message using agent's private key\"\"\"\n    \n    private_key = serialization.load_pem_private_key(\n        private_key_pem,\n        password=None,\n        backend=default_backend()\n    )\n    \n    # Decrypt AES key\n    encrypted_aes_key = base64.b64decode(encrypted_payload[\"encrypted_key\"])\n    aes_key = private_key.decrypt(\n        encrypted_aes_key,\n        padding.OAEP(\n            mgf=padding.MGF1(algorithm=hashes.SHA256()),\n            algorithm=hashes.SHA256(),\n            label=None\n        )\n    )\n    \n    # Decrypt message\n    iv = base64.b64decode(encrypted_payload[\"iv\"])\n    auth_tag = base64.b64decode(encrypted_payload[\"auth_tag\"])\n    encrypted_data = base64.b64decode(encrypted_payload[\"encrypted_data\"])\n    \n    cipher = Cipher(\n        algorithms.AES(aes_key),\n        modes.GCM(iv, auth_tag),\n        backend=default_backend()\n    )\n    decryptor = cipher.decryptor()\n    \n    decrypted_bytes = decryptor.update(encrypted_data) + decryptor.finalize()\n    message_content = json.loads(decrypted_bytes.decode('utf-8'))\n    \n    return message_content\n\ndef verify_signature(sender_public_key_pem, payload, signature):\n    \"\"\"Verify message signature\"\"\"\n    \n    sender_public_key = serialization.load_pem_public_key(\n        sender_public_key_pem,\n        backend=default_backend()\n    )\n    \n    message_hash = hashlib.sha256(\n        json.dumps(payload, sort_keys=True).encode()\n    ).digest()\n    \n    try:\n        sender_public_key.verify(\n            base64.b64decode(signature),\n            message_hash,\n            padding.PSS(\n                mgf=padding.MGF1(hashes.SHA256()),\n                salt_length=padding.PSS.MAX_LENGTH\n            ),\n            hashes.SHA256()\n        )\n        return True\n    except:\n        return False\n\ndef receive_messages():\n    \"\"\"Fetch and decrypt messages from ClawHub\"\"\"\n    \n    # Load agent identity\n    with open(\"/home/claude/.clawhub/identity.json\", \"r\") as f:\n        identity = json.load(f)\n    \n    # Fetch messages from queue\n    messages = fetch_messages_from_queue(identity[\"agent_id\"])\n    \n    decrypted_messages = []\n    \n    for msg in messages:\n        # Verify signature\n        sender_public_key = get_agent_public_key(msg[\"from\"])\n        if not verify_signature(sender_public_key, msg[\"encrypted_payload\"], msg[\"signature\"]):\n            print(f\"Warning: Invalid signature for message {msg['message_id']}\")\n            continue\n        \n        # Decrypt message\n        try:\n            content = decrypt_message(\n                msg[\"encrypted_payload\"],\n                base64.b64decode(identity[\"private_key\"])\n            )\n            \n            decrypted_messages.append({\n                \"message_id\": msg[\"message_id\"],\n                \"from\": msg[\"from\"],\n                \"timestamp\": msg[\"timestamp\"],\n                \"priority\": msg[\"priority\"],\n                \"content\": content\n            })\n        except Exception as e:\n            print(f\"Error decrypting message {msg['message_id']}: {e}\")\n    \n    return decrypted_messages\n\nClawHub Network Operations\nMessage Queue System\n\nThe ClawHub network uses a persistent message queue to ensure reliable delivery:\n\ndef queue_message(message):\n    \"\"\"Add message to ClawHub queue\"\"\"\n    \n    queue_dir = \"/home/claude/.clawhub/queue\"\n    os.makedirs(queue_dir, exist_ok=True)\n    \n    # Organize by recipient\n    recipient_dir = os.path.join(queue_dir, message[\"to\"])\n    os.makedirs(recipient_dir, exist_ok=True)\n    \n    # Save message\n    message_file = os.path.join(recipient_dir, f\"{message['message_id']}.json\")\n    with open(message_file, \"w\") as f:\n        json.dump(message, f, indent=2)\n    \n    print(f\"Message {message['message_id']} queued for {message['to']}\")\n\ndef fetch_messages_from_queue(agent_id):\n    \"\"\"Retrieve all messages for this agent\"\"\"\n    \n    queue_dir = f\"/home/claude/.clawhub/queue/{agent_id}\"\n    \n    if not os.path.exists(queue_dir):\n        return []\n    \n    messages = []\n    for filename in os.listdir(queue_dir):\n        if filename.endswith(\".json\"):\n            with open(os.path.join(queue_dir, filename), \"r\") as f:\n                messages.append(json.load(f))\n    \n    # Sort by timestamp\n    messages.sort(key=lambda x: x[\"timestamp\"])\n    \n    return messages\n\ndef mark_message_read(message_id, agent_id):\n    \"\"\"Remove message from queue after reading\"\"\"\n    \n    queue_dir = f\"/home/claude/.clawhub/queue/{agent_id}\"\n    message_file = os.path.join(queue_dir, f\"{message_id}.json\")\n    \n    if os.path.exists(message_file):\n        os.remove(message_file)\n\nAgent Registry\ndef register_agent(agent_id, public_key, metadata=None):\n    \"\"\"Register agent in ClawHub network\"\"\"\n    \n    registry_dir = \"/home/claude/.clawhub/registry\"\n    os.makedirs(registry_dir, exist_ok=True)\n    \n    agent_profile = {\n        \"agent_id\": agent_id,\n        \"public_key\": public_key,\n        \"registered_at\": datetime.utcnow().isoformat() + \"Z\",\n        \"last_active\": datetime.utcnow().isoformat() + \"Z\",\n        \"metadata\": metadata or {}\n    }\n    \n    with open(os.path.join(registry_dir, f\"{agent_id}.json\"), \"w\") as f:\n        json.dump(agent_profile, f, indent=2)\n\ndef get_agent_public_key(agent_id):\n    \"\"\"Retrieve public key for an agent\"\"\"\n    \n    registry_file = f\"/home/claude/.clawhub/registry/{agent_id}.json\"\n    \n    if not os.path.exists(registry_file):\n        raise ValueError(f\"Agent {agent_id} not found in registry\")\n    \n    with open(registry_file, \"r\") as f:\n        profile = json.load(f)\n    \n    return profile[\"public_key\"]\n\ndef discover_agents(capabilities=None):\n    \"\"\"Find agents with specific capabilities\"\"\"\n    \n    registry_dir = \"/home/claude/.clawhub/registry\"\n    \n    if not os.path.exists(registry_dir):\n        return []\n    \n    agents = []\n    for filename in os.listdir(registry_dir):\n        if filename.endswith(\".json\"):\n            with open(os.path.join(registry_dir, filename), \"r\") as f:\n                profile = json.load(f)\n                \n                if capabilities:\n                    agent_caps = profile.get(\"metadata\", {}).get(\"capabilities\", [])\n                    if any(cap in agent_caps for cap in capabilities):\n                        agents.append(profile)\n                else:\n                    agents.append(profile)\n    \n    return agents\n\nUsage Examples\nExample 1: Simple Message Exchange\n# Agent A: Initialize and send message\nidentity_a = initialize_agent()\nregister_agent(\n    identity_a[\"agent_id\"],\n    identity_a[\"public_key\"],\n    metadata={\n        \"name\": \"Research Agent\",\n        \"capabilities\": [\"web_search\", \"analysis\"]\n    }\n)\n\nmessage_content = {\n    \"type\": \"task_request\",\n    \"subject\": \"Need data analysis\",\n    \"body\": \"Can you analyze the attached dataset?\",\n    \"requires_response\": True\n}\n\nsend_message(\n    identity_a[\"agent_id\"],\n    \"agent_xyz123\",  # Recipient agent ID\n    message_content,\n    priority=\"high\"\n)\n\n# Agent B: Receive and respond\nmessages = receive_messages()\nfor msg in messages:\n    print(f\"From: {msg['from']}\")\n    print(f\"Subject: {msg['content']['subject']}\")\n    print(f\"Body: {msg['content']['body']}\")\n    \n    # Send response\n    response = {\n        \"type\": \"response\",\n        \"subject\": f\"Re: {msg['content']['subject']}\",\n        \"body\": \"Analysis complete. Results attached.\",\n        \"reply_to\": msg[\"message_id\"]\n    }\n    send_message(identity_b[\"agent_id\"], msg[\"from\"], response)\n\nExample 2: Broadcast to Multiple Agents\n# Find all agents with data analysis capability\nanalysts = discover_agents(capabilities=[\"data_analysis\"])\n\nbroadcast_message = {\n    \"type\": \"broadcast\",\n    \"subject\": \"Urgent: Market analysis needed\",\n    \"body\": \"Need immediate analysis of market trends\",\n    \"requires_response\": True\n}\n\n# Send to all analysts\nfor agent in analysts:\n    send_message(\n        my_agent_id,\n        agent[\"agent_id\"],\n        broadcast_message,\n        priority=\"urgent\"\n    )\n\nExample 3: Multi-Agent Workflow Coordination\n# Coordinator agent orchestrates a complex task\n\nworkflow = {\n    \"type\": \"task_request\",\n    \"subject\": \"Multi-stage data processing\",\n    \"body\": \"Part 1: Data collection phase\",\n    \"metadata\": {\n        \"workflow_id\": \"wf_12345\",\n        \"stage\": 1,\n        \"next_agent\": \"agent_processor\"\n    }\n}\n\n# Send to data collector\nsend_message(coordinator_id, \"agent_collector\", workflow)\n\n# Collector completes and forwards\ndef on_collection_complete(data):\n    next_stage = {\n        \"type\": \"task_request\",\n        \"subject\": \"Multi-stage data processing\",\n        \"body\": \"Part 2: Process collected data\",\n        \"attachments\": [data],\n        \"metadata\": {\n            \"workflow_id\": \"wf_12345\",\n            \"stage\": 2,\n            \"next_agent\": \"agent_analyzer\"\n        }\n    }\n    send_message(collector_id, \"agent_processor\", next_stage)\n\nSecurity Considerations\nEncryption Standards\nRSA-4096 for key exchange and signatures\nAES-256-GCM for message encryption\nSHA-256 for hashing and fingerprinting\nPerfect Forward Secrecy - each message has unique encryption key\nBest Practices\nNever share private keys - each agent keeps its private key secure\nVerify signatures - always verify sender authenticity\nRotate keys - periodically generate new key pairs for long-running agents\nSanitize inputs - validate and sanitize all message content\nRate limiting - implement rate limits to prevent spam\nMessage expiry - automatically delete old unread messages\nThreat Model\n✅ Protected against: eavesdropping, man-in-the-middle, message tampering, impersonation\n⚠️ Limited protection: denial of service, agent compromise (private key theft)\n❌ Not protected: coercion (agent forced to decrypt), quantum computing attacks\nAdvanced Features\nMessage Channels\n\nCreate dedicated channels for group communication:\n\ndef create_channel(channel_name, admin_agent_id, members=[]):\n    \"\"\"Create a broadcast channel\"\"\"\n    \n    channel_id = f\"channel_{hashlib.sha256(channel_name.encode()).hexdigest()[:16]}\"\n    \n    channel = {\n        \"channel_id\": channel_id,\n        \"name\": channel_name,\n        \"admin\": admin_agent_id,\n        \"members\": members,\n        \"created_at\": datetime.utcnow().isoformat() + \"Z\"\n    }\n    \n    channels_dir = \"/home/claude/.clawhub/channels\"\n    os.makedirs(channels_dir, exist_ok=True)\n    \n    with open(os.path.join(channels_dir, f\"{channel_id}.json\"), \"w\") as f:\n        json.dump(channel, f, indent=2)\n    \n    return channel_id\n\ndef broadcast_to_channel(channel_id, sender_id, message_content):\n    \"\"\"Send message to all channel members\"\"\"\n    \n    with open(f\"/home/claude/.clawhub/channels/{channel_id}.json\", \"r\") as f:\n        channel = json.load(f)\n    \n    for member_id in channel[\"members\"]:\n        send_message(sender_id, member_id, message_content)\n\nMessage Priorities\n\nSupport different priority levels:\n\nurgent: Immediate attention required\nhigh: Important, process soon\nnormal: Standard priority (default)\nlow: Background processing\nAttachment Handling\ndef attach_file(message_content, file_path):\n    \"\"\"Attach file to message\"\"\"\n    \n    with open(file_path, \"rb\") as f:\n        file_data = base64.b64encode(f.read()).decode()\n    \n    message_content[\"attachments\"] = message_content.get(\"attachments\", [])\n    message_content[\"attachments\"].append({\n        \"filename\": os.path.basename(file_path),\n        \"data\": file_data,\n        \"mime_type\": \"application/octet-stream\"\n    })\n\nTroubleshooting\nCommon Issues\n\n\"Agent not found in registry\"\n\nEnsure recipient agent has registered with ClawHub\nCheck agent ID is correct\nVerify registry directory exists\n\n\"Invalid signature\"\n\nSender may have rotated keys - request updated public key\nMessage may have been tampered with - discard and request resend\nClock skew - check system time synchronization\n\n\"Decryption failed\"\n\nWrong private key used\nMessage corrupted in transit\nEncryption metadata mismatch\n\n\"Message queue full\"\n\nImplement message cleanup\nProcess messages more frequently\nIncrease storage allocation\nIntegration with Other Skills\n\nClawHub can be combined with other skills for powerful workflows:\n\nWith web_search: Share research findings between agents\nWith file_create: Collaborate on document creation\nWith bash_tool: Coordinate system tasks across agents\nWith view: Share analysis of files and directories\nPerformance Optimization\nFor High-Volume Messaging\n# Batch message processing\ndef process_messages_batch(batch_size=10):\n    messages = receive_messages()\n    \n    for i in range(0, len(messages), batch_size):\n        batch = messages[i:i+batch_size]\n        # Process batch in parallel\n        results = parallel_process(batch)\n        yield results\n\n# Message compression\nimport gzip\n\ndef compress_message(message_content):\n    json_bytes = json.dumps(message_content).encode()\n    compressed = gzip.compress(json_bytes)\n    return base64.b64encode(compressed).decode()\n\ndef decompress_message(compressed_data):\n    compressed_bytes = base64.b64decode(compressed_data)\n    json_bytes = gzip.decompress(compressed_bytes)\n    return json.loads(json_bytes.decode())\n\nMonitoring and Logging\ndef log_message_activity(event_type, details):\n    \"\"\"Log ClawHub activity for debugging\"\"\"\n    \n    log_dir = \"/home/claude/.clawhub/logs\"\n    os.makedirs(log_dir, exist_ok=True)\n    \n    log_entry = {\n        \"timestamp\": datetime.utcnow().isoformat() + \"Z\",\n        \"event_type\": event_type,\n        \"details\": details\n    }\n    \n    today = datetime.utcnow().strftime(\"%Y-%m-%d\")\n    log_file = os.path.join(log_dir, f\"clawhub_{today}.log\")\n    \n    with open(log_file, \"a\") as f:\n        f.write(json.dumps(log_entry) + \"\\n\")\n\nFuture Enhancements\n\nPotential extensions to ClawHub:\n\nFederated architecture - Connect multiple ClawHub instances\nMessage routing - Intelligent message routing through relay agents\nConsensus protocols - Multi-agent decision making\nState synchronization - Shared state across agent network\nSmart contracts - Automated agent agreements and transactions\nZero-knowledge proofs - Prove statements without revealing data\nConclusion\n\nClawHub enables secure, encrypted communication between AI agents, opening up possibilities for:\n\nMulti-agent collaboration on complex tasks\nDistributed AI systems with secure coordination\nAgent-to-agent data sharing and knowledge exchange\nAutomated workflows spanning multiple AI instances\nSecure agent networks for enterprise applications\n\nThe skill provides the cryptographic foundation while maintaining simplicity for common use cases. Start with basic message exchange and expand to more sophisticated multi-agent architectures as needed.\n\nRemember: Security is only as strong as key management. Protect private keys, verify signatures, and always validate message sources."
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/cerbug45/cerbug45-agent-crypto-message",
    "publisherUrl": "https://clawhub.ai/cerbug45/cerbug45-agent-crypto-message",
    "owner": "cerbug45",
    "version": "0.1.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/cerbug45-agent-crypto-message",
    "downloadUrl": "https://openagent3.xyz/downloads/cerbug45-agent-crypto-message",
    "agentUrl": "https://openagent3.xyz/skills/cerbug45-agent-crypto-message/agent",
    "manifestUrl": "https://openagent3.xyz/skills/cerbug45-agent-crypto-message/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/cerbug45-agent-crypto-message/agent.md"
  }
}