Cyphra
Cyphra is a Python reference implementation of a zero-knowledge, end-to-end encrypted messaging platform. It supports two modes:
- A standalone terminal messaging client.
- An importable Python SDK for developer applications.
Maintainers: Anupam1707 and asmitbaldi.
The mandatory hybrid construction is:
X25519 ephemeral DH || ML-KEM-768 encapsulation -> HKDF-SHA384 -> AES-256-GCM
Every message carries an Ed25519 signature over its canonical envelope.
Architecture
untrusted network
┌───────────────┐ opaque frames ┌────────────────┐
│ CyphraClient │◄─────────────────►│ WebSocketBroker│
└──────┬────────┘ └────────────────┘
│ composes
┌──────▼────────┐ ciphertext-only local state
│ CryptoEngine │◄──────────────────────────────┐
└───────────────┘ │
┌────────────▼─────────┐
│ DatabaseManager │
│ SQLCipher │
└──────────────────────┘
CryptoEngineowns identity generation, bundle verification, hybrid encryption, signatures, and decryption.DatabaseManagerowns SQLCipher persistence and stores private identity material, trusted contacts, and encrypted envelopes only.CyphraClientcomposes cryptography, storage, and transport.- The fixed Vercel HTTP relay routes public bundles and opaque ciphertext without receiving plaintext or private keys.
Install
python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install -e '.[dev]'
Standalone Client
The client uses the fixed deployed relay internally. Users do not select a broker URL.
cyphra chat --name Alice
cyphra chat --name Bob
The terminal UI shows connected people, supports r to refresh and q to quit, and asks the user to approve the peer fingerprint before chatting. Type /quit to leave.
Each identity uses its own encrypted database under ~/.cyphra/; use --db for a custom path.
SDK Mode
Developer applications can import Cyphra components directly:
from cyphra import CyphraClient, CryptoEngine, DatabaseManager
from cyphra.network.http_client import HttpBrokerClient
engine = CryptoEngine()
database = DatabaseManager.from_passphrase("alice.db", "a long local passphrase")
CyphraClient.provision_identity(engine, database)
transport = HttpBrokerClient("https://post-q.vercel.app")
client = CyphraClient(engine, database, transport)
Fixed Vercel Relay
The deployed relay URL is https://post-q.vercel.app.
The Vercel handler uses transient process memory for public bundles, presence, and temporary opaque packet forwarding. No external database is configured. Persistent identities, contacts, and encrypted message history remain in each client database.
Because serverless memory is not durable or shared across every instance, this relay is suitable for controlled demonstrations and testing, not reliable offline delivery.
Deploy through the Vercel GitHub integration by importing Anupam1707/PostQ, selecting Other as the framework, and deploying the main branch.
Local Relay Development
cyphra-server --insecure-dev --host 127.0.0.1 --port 8765
The local WebSocket relay remains available for development and tests, but the normal standalone client uses the fixed Vercel HTTPS relay.
Security Notes
- ML-KEM-768 is mandatory; there is no classical-only downgrade path.
- Each message gets fresh X25519 ephemeral material, ML-KEM encapsulation, HKDF salt, and AES-GCM nonce.
- The relay sees identity IDs, public bundles, timing, sizes, and opaque ciphertext.
- Plaintext, private keys, passphrases, and derived message keys remain client-side.
- Offline delivery is intentionally not guaranteed by the transient relay.
- This is a security-focused reference implementation, not a substitute for independent cryptographic review.
Build and Publish
The package provides the cyphra and cyphra-server console commands.
rm -rf dist build *.egg-info
python3 -m build
python3 -m twine check dist/*
python3 -m pip install --force-reinstall dist/cyphra-*.whl
cyphra --help
Publish after reviewing the artifacts:
python3 -m twine upload dist/*
Never commit PyPI credentials. Increment the version in pyproject.toml for every release.
Testing
pytest -q
python3 -m py_compile api/index.py cyphra/**/*.py cyphra/*.py tests/*.py
Metadata
Release files for cyphra 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cyphra-0.1.0.tar.gz | 28.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cyphra-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.5 kB
Release files / cyphra-0.1.0.tar.gz
| Download URL | cyphra-0.1.0.tar.gz |
|---|---|
| Size | 28.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e4aea34a53a384c20fef2c17c64bcac762d3b4fb518afd251ad0ce1f18d4069
|
|
BLAKE2b-256 checksum How to use checksums |
9e88153d265583643101927524964ee928ff9c96883ad48c4a724b80e427c553
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.0
|
Release files / cyphra-0.1.0-py3-none-any.whl
| Download URL | cyphra-0.1.0-py3-none-any.whl |
|---|---|
| Size | 31.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
247ffabe3479da0c4a7a9cd51bbb047e4996ead7058226e70093891e8b839141
|
|
BLAKE2b-256 checksum How to use checksums |
75492e9b347ed75aadf82a0b42f8ad373981050d303ca0fdea7f5d04ff9276d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.0
|