Skip to main content

X Chat SDK - End-to-end encryption for X Direct Messages (Python bindings)

Project description

chat-xdk Python bindings

Python bindings for the X Chat SDK — end-to-end encryption for X Direct Messages.

Install

pip install chatxdk

The PyPI distribution is chatxdk; import it as chat_xdk.

Architecture

Python (chat_xdk) → PyO3 → chat-xdk-core (Rust)

Prerequisites

  • Python 3.10+
  • Rust (stable) and maturin

Setup

From source (editable install):

cd crates/pyo3
pip install maturin
maturin develop

Release wheel:

maturin build --release
pip install target/wheels/*.whl

Quick Start

from chat_xdk import Chat

chat = Chat(config_json)
chat.unlock("2580")

# Initial load — batch decrypt with automatic key extraction.
# Each signing-key entry must include the identity public key and its binding
# signature so the SDK can verify the signing key is authentic.
result = chat.decrypt_events(raw_events, [
    {
        "user_id": "111",
        "public_key_version": "v1",
        "public_key": "BASE64...",
        "identity_public_key": "BASE64...",
        "identity_public_key_signature": "BASE64...",
    },
    {
        "user_id": "222",
        "public_key_version": "v1",
        "public_key": "BASE64...",
        "identity_public_key": "BASE64...",
        "identity_public_key_signature": "BASE64...",
    },
])

for dm in result["messages"]:
    if dm["event"]["type"] == "Message":
        print(dm["event"]["sender_id"], dm["event"]["content"]["text"])

# Cache keys, then use decrypt_event for individual events
cached_keys = result["conversation_keys"]["keys"]
event = chat.decrypt_event(new_event_b64, cached_keys, sender_signing_keys)

API

See the Python column of the unified tables in docs/API.md for the full method list, parameters, and return types.

Security limitations

The underlying protocol provides no forward secrecy and no post-compromise security: compromise of an identity private key exposes all conversation keys ever encrypted to that public key — and therefore all past and future messages in those conversations. Key rotation does not retroactively protect messages encrypted under a previous key. See docs/CRYPTO.md — Known Limitations.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

chatxdk-0.2.1-cp310-abi3-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.10+Windows x86-64

chatxdk-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

chatxdk-0.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

chatxdk-0.2.1-cp310-abi3-macosx_11_0_arm64.whl (3.0 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

chatxdk-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file chatxdk-0.2.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: chatxdk-0.2.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.9 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for chatxdk-0.2.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2e111d3853596564d854eb6c6eab2fa556fa47e409c1b5580c714b07b48657f9
MD5 cf016cb7d756f67b9c8ed90bfb1e9a7a
BLAKE2b-256 fe06507ed7197fe5f529dbca421b0d166ed277e8c1430e789116427e12ffbf6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.2.1-cp310-abi3-win_amd64.whl:

Publisher: release.yml on xdevplatform/chat-xdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chatxdk-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chatxdk-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8d7913b98f01f4be40085f43863798b2702d69c6a844d7fd9ae7014e8ed71e5c
MD5 e2fb82f75cbf917822bde4dc6cf78b86
BLAKE2b-256 9b1fcd25a7cf8259807778a11ddd85bae4ef78e13367b83496a58c415ca7d1a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.2.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on xdevplatform/chat-xdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chatxdk-0.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for chatxdk-0.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 06d018315c797973dc052bce707952fc21efad5ca7c7007b01553aeff943c9c7
MD5 c65ddd7889f1d16f98a6476acce2d2d0
BLAKE2b-256 b98f13105be6fb0861ed88deda2cf4367129c05a0bb46b11ad2dd89ad237db5d

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.2.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on xdevplatform/chat-xdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chatxdk-0.2.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chatxdk-0.2.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 588c31b4a18386f869a62933c8206d439bb81935f33afa55b8621116860b7758
MD5 6ffffb86d2207d3b587c69e31cc0fb5e
BLAKE2b-256 b592696c27929ab2dcda19ad19f8e19defed2e1c724b528923640fa1ea7208c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.2.1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on xdevplatform/chat-xdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chatxdk-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for chatxdk-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 59443e85bb1a6b9c75d92d23146b2c683a408a186dd69634a46f400de516ef4f
MD5 ef1ad7801e374ea957fbb3fd9e79859c
BLAKE2b-256 5cd71007fa5b9201f7cd213577ded29eee6888b95dcdc976a4fdb5861826d940

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.2.1-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on xdevplatform/chat-xdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page