Skip to main content

sbp4ai-client

SBP (Session Bridge Protocol) end-to-end encryption core. Implements the wire format from sbp-spec/spec/SBP-0.4-e2ee.md.

The relay (sbp4ai-dispatcher) never holds a secret: confidentiality comes from crypto_box sealing to the pinned recipient box public key, and integrity from an Ed25519 signature over tag || eph || cipher. Routing is blinded with HMAC(rk, scope), so the relay cannot even tell which session a frame belongs to.

Install

pip install sbp4ai-client

Standard usage (3 steps)

pip install sbp4ai-agents                      # on the controlled machine
sbp-agents --relay wss://relay.example.com/ws-e2ee
cat .copy2client

cat .copy2client → copy the whole block → paste it into the console / mini-program 「粘贴导入」(paste-import) box — it imports both clients at once (cli-web web console + cli-minis WeChat mini program).

The paste string carries the client's own box_sk / sign_sk plus the device's pinned public keys and rk, i.e. exactly the material this package's E2EELink needs.

Quick start

from sbp_client import KeyPair, KeyRing, derive_rk, E2EELink

rk = derive_rk("your-routing-passphrase")          # 32-byte shared routing key
me = KeyPair.generate()                            # your box+sign keypair
ring = KeyRing()
ring.add("peer", peer_box_pk_b64, peer_sign_pk_b64)  # pin the other side's publics

link = E2EELink(me, ring, rk, my_key_id="cli", device_did="dev_abc", role="client")
hello = link.hello()                               # send to relay first
link.subscribe(link.scope.device())                # ask relay to route device-tag frames
envelope = link.send(inner_frame, link.scope.session("sess1"), peer_key_id="dev")
# ... ship `envelope` over WebSocket; on the other side:
inner = link.recv(envelope)                        # decrypted + signature-checked

Key formats

Field Bytes Note
box_sk / box_pk 32 X25519 (crypto_box)
sign_sk 32 (PyNaCl seed) or 64 (libsodium seed‖pk) both accepted by KeyPair
sign_pk 32 Ed25519 verify key
rk 32 64-hex = raw key; anything else is stretched with Argon2id

KeyPair.to_strings() exports sign_sk in the 64-byte libsodium form, so the same string can be pasted straight into a JS client (libsodium / tweetnacl both want 64 bytes).

Wire format

envelope = { v:"sbp/0.3e", tag, kid, eph, sig, cipher }
  tag    = base64url(HMAC-SHA256(rk, scope))       scope: "dev|{did}" | "sid|{did}|{sid}"
  eph    = base64url(ephemeral X25519 public key)
  cipher = base64url(nonce[24] || crypto_box(inner))
  sig    = base64url(Ed25519.sign(sign_sk, tag || eph || cipher))

Every frame uses a fresh ephemeral keypair, so each crypto_box key is independent (forward secrecy within a session). The relay verifies sig with sign_pk from its public-key directory and routes by tag — it can do neither without rk / box_sk.

Layout

  • sbp_client/crypto.py — KeyPair, KeyRing, derive_rk, compute_tag, wrap/unwrap, sign_challenge/verify_challenge, verify_sig.
  • sbp_client/transport.py — E2EELink / Scope: transport-agnostic envelope wrap/unwrap + subscription control, shared by sbp4ai-agents and client apps.
  • sbp4ai-dispatcher — the relay (public-key directory + opaque-tag pub/sub).
  • sbp4ai-agents — the device/panel that reports local tmux / CLI sessions.

Metadata

Release files for sbp4ai-client 0.5.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sbp4ai-client 0.5.7
File Size Uploaded Provenance Actions
sbp4ai_client-0.5.7.tar.gz 8.4 kB Without provenance Details for sbp4ai_client-0.5.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sbp4ai-client 0.5.7
File Interpreter ABI Platform Actions
sbp4ai_client-0.5.7-py3-none-any.whl Python 3 none any Details for sbp4ai_client-0.5.7-py3-none-any.whl

Total release size: 16.7 kB

Release files / sbp4ai_client-0.5.7.tar.gz

Download URL sbp4ai_client-0.5.7.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
10236e3eb466f3da1c3f052f82ac2e13b23b762ef1121c3c53768f1eac1abb28
BLAKE2b-256 checksum
How to use checksums
9d58854f1649dc39646eb01d75e1c90704baeb04207eec541367808d00db6724
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Release files / sbp4ai_client-0.5.7-py3-none-any.whl

Download URL sbp4ai_client-0.5.7-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de717ba8d9904d99924ca4152196aafc44635fc17dd7e450ab30f1d44602ff7b
BLAKE2b-256 checksum
How to use checksums
e262eae453ed2df8895f0b212bb3f3d23590577b6516b976e78a2898db2e3926
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.12

Security for sbp4ai-client 0.5.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.7 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page