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.0-cp310-abi3-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.10+Windows x86-64

chatxdk-0.2.0-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.0-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.0-cp310-abi3-macosx_11_0_arm64.whl (3.0 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

chatxdk-0.2.0-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.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: chatxdk-0.2.0-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.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 19db5dc35f49c463334555b54b8ee4cdfcea8aa8dbbc7cb06835cc081a5cc50f
MD5 d192cc0238e16921867bf2d1b95be4b7
BLAKE2b-256 23fc0a08f9c962a58d2883214bb4ca6a8dcbf758cd939e212d2ab37aa5cc6f86

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.2.0-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.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chatxdk-0.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a0b560b18c94b16616bb47dd818cd29f9fd9c81aa19eca75005cb8cc8fd1d41d
MD5 bd3b1ec05dde8cf2653bfd25a05d38b2
BLAKE2b-256 1a22792728760ee8b21ad8a801fa3d27c015f319dbd2f08e501095beeff0f846

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.2.0-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.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for chatxdk-0.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f9c168926f92105babb1ab5d73d77ec21600526f9e9de414db2c6b0677c817eb
MD5 0473fc081198f63f76bb02e5d3a1f2b2
BLAKE2b-256 590b2e0fe5630b29bc052e52211997da67394e56168379c7f05ff79ce57cd758

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.2.0-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.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chatxdk-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 31d2f3638d3cc7556a77085f267dae556ae3265204c7fcb82973fc4bf892d130
MD5 98debe23a899640a5187b0f65b3260df
BLAKE2b-256 e129e67529c55986e132c569bf3e285517cae40164d9b846bf3ad4ce812e1397

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.2.0-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.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for chatxdk-0.2.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2481049655dd0cb6f4d5f32ab92c4651777611976466bc518d20908d27878eb0
MD5 4b9cae106c475cd8ae6db77e75072195
BLAKE2b-256 6bbadca0a94ac0ef3e0ad203607c9a48e76d0730b9f60f93f67badeaa63a6898

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatxdk-0.2.0-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