Zero-storage authentication for Python applications. The server knows absolutely nothing about your users.
Overview
CryptoLogin is a passwordless authentication system built on a radical principle: the server should never know anything that the user doesn't explicitly share.
Key properties:
- ๐ Zero-knowledge inspired: The
master_secretnever leaves the client - ๐ก๏ธ Breach-resistant: If the database is leaked, there's nothing to exploit
- โก Fast: HMAC-SHA256 verification (~1ms per login)
- ๐ Simple: 3 API endpoints, 2 SDKs (Python + JavaScript)
- ๐ฆ Battle-tested primitives: Built on standard
hashlib,hmac, and Web Crypto API
Security Model
What the server stores
CREATE TABLE users (
user_id TEXT PRIMARY KEY, -- 64-char hex, derived from master_secret
user_data TEXT, -- Optional JSON metadata
created_at TEXT,
updated_at TEXT,
last_activity_at TEXT,
challenge TEXT -- Temporary, for active login sessions
);
No passwords. No emails. No secrets.
Authentication flow
sequenceDiagram
participant Client
participant Server
Client->>Client: Derive user_id from master_secret (PBKDF2)
Client->>Server: POST /auth/login/init {user_id}
Server->>Server: Generate random challenge
Server-->>Client: Return challenge
Client->>Client: Compute HMAC(challenge, user_id)
Client->>Server: POST /auth/login/verify {user_id, hmac}
Server->>Server: Verify HMAC
Server-->>Client: Return session_id
โโโโโโโโโโโโ โโโโโโโโโโโโ
โ Client โ โ Server โ
โโโโโโฌโโโโโโ โโโโโโฌโโโโโโ
โ 1. Derive user_id from master_secret โ
โ (PBKDF2-SHA512, 100k iterations) โ
โ โ
โ 2. POST /auth/login/init {user_id} โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบ โ
โ โ 3. Generate challenge
โ 4. Return challenge โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ 5. Compute HMAC(challenge, user_id) โ
โ โ
โ 6. POST /auth/login/verify โ
โ {user_id, hmac} โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโบ โ
โ โ 7. Verify HMAC
โ 8. Return session โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ
Authenticated โ
Session created
Cryptographic primitives
| Component | Algorithm | Purpose |
|---|---|---|
| Key derivation | PBKDF2-HMAC-SHA512 (100k iterations) | Derive user_id from master_secret |
| Authentication | HMAC-SHA256 | Prove knowledge of master_secret |
| Comparison | Constant-time (hmac.compare_digest) | Prevent timing attacks |
No custom cryptography. All primitives are from Python's standard library.
Installation
pip install cryptologin
# With server dependencies (FastAPI, Uvicorn)
pip install 'cryptologin[server]'
# With CLI formatting (Rich)
pip install 'cryptologin[cli]'
# Everything
pip install 'cryptologin[all]'
Quick Start
Initialize a project
cryptologin init
cryptologin run --port 8000
Server (Python API)
from cryptologin.storage.sqlite_v2 import SQLiteStorageV2
from cryptologin.core.user_manager_v2 import UserManagerV2
# Initialize
storage = SQLiteStorageV2(db_path="auth.db", auto_migrate=True)
user_manager = UserManagerV2(storage=storage)
# Register (user_id derived client-side from master_secret)
user_manager.register_user_v2(user_id, user_data={"name": "Alice"})
# Login flow
challenge = user_manager.initiate_login_v2(user_id)
# Client computes: hmac = HMAC-SHA256(challenge, user_id)
session = user_manager.complete_login_v2(user_id, hmac)
Client (JavaScript)
npm install cryptologin-client
import { createClient } from "cryptologin-client";
const client = createClient({
baseURL: "https://api.yourapp.com/v1",
timeout: 30000,
});
// Register - SDK derives user_id automatically
await client.register("my-master-secret-min-32-chars", { name: "Alice" });
// Login - SDK handles the full HMAC flow
const session = await client.login("my-master-secret-min-32-chars");
console.log("Session:", session.sessionId);
CLI Usage
# Initialize a project
cryptologin init
# Start the API server
cryptologin run --port 8000 --debug
# Register a user
cryptologin register --secret "my-master-secret-min-32-chars" \
--data '{"name": "Alice", "role": "admin"}'
# Login
cryptologin login --secret "my-master-secret-min-32-chars"
# List all users
cryptologin users --json
# Get user data
cryptologin get-data --user-id 892e3cac5f8d...
# Delete a user
cryptologin delete --user-id 892e3cac5f8d... --secret "master-secret" --yes
# Show system status
cryptologin status
# Show version
cryptologin --version
Trade-offs
CryptoLogin is not for everyone. Be honest about the trade-offs:
โ Use it if:
- You need zero-knowledge authentication
- Your users can manage a master_secret (password manager, hardware key)
- You want breach-resistant authentication
- Compliance requires minimal data retention (GDPR, HIPAA)
โ Don't use it if:
- You need "Forgot Password" (impossible by design)
- Your users are non-technical and will forget credentials
- You need email-based account recovery
The trade-off: Absolute security vs. convenience. Like a Bitcoin wallet: Not your keys, not your crypto. Not your master_secret, not your account.
Architecture
cryptologin/
โโโ client/
โ โโโ crypto_client.py # Cryptographic operations
โโโ core/
โ โโโ user_manager.py # V1 manager (legacy)
โ โโโ user_manager_v2.py # V2 manager (HMAC-based)
โ โโโ exceptions.py # Custom exceptions
โโโ storage/
โ โโโ base.py # Abstract storage
โ โโโ sqlite.py # V1 SQLite storage
โ โโโ sqlite_v2.py # V2 SQLite storage
โโโ main.py # FastAPI application
โโโ cli.py # Command-line interface
Two versions coexist peacefully:
- V1: Traditional challenge-response (legacy support)
- V2: Zero-knowledge HMAC-based (recommended)
Live Demo
Try CryptoLogin right now:
Documentation
Packages
| Package | Description | Link |
|---|---|---|
| cryptologin | Python server SDK | PyPi |
| cryptologin-client | JavaScript client SDK | npm |
Roadmap
- V1 - Challenge-response authentication
- V2 - Zero-knowledge HMAC-based authentication
- JavaScript SDK with Web Crypto API
- SQLite storage with auto-migration
- FastAPI integration
- Professional CLI
- PostgreSQL storage adapter
- Redis session storage
- WebAuthn/FIDO2 support
- Flash512-Vanguard integration (v3.0)
- OAuth2 provider mode
- Mobile SDKs (React Native, Flutter)
Contributing
Contributions are welcome! Please read CONTRIBUTING.md before submitting PRs.
Areas where we need help:
- ๐งช Test coverage (especially edge cases)
- ๐ Documentation improvements
- ๐ Storage adapters (PostgreSQL, Redis, MongoDB)
- ๐จ UI/UX improvements for the demo
- ๐ Translations
Security
See SECURITY.md for reporting vulnerabilities.
Disclaimer: CryptoLogin has not been audited by third-party security experts. Use at your own risk for production systems. Always consult with a security professional before deploying authentication systems.
License
MIT ยฉ erabytse
The future of auth isn't about building better honeypots. It's about removing the honey.
โญ Star on GitHub ยท ๐ฆ PyPI ยท ๐ Demo
"If you believe in local-first, privacy-respecting AI infrastructure, consider starring this repository. It helps the PoetryCoding movement grow. โญ"
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cryptologin-2.1.7.tar.gz.
File metadata
- Download URL: cryptologin-2.1.7.tar.gz
- Upload date:
- Size: 44.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60a36322babda31634de12d626549c98548527f1268f2d99c35e657695c37abe
|
|
| MD5 |
6c0a9eb817bfa1c56eecc544129466ec
|
|
| BLAKE2b-256 |
822e43abfbfa4f3e0ab12908aceff9622fd94e4e414cea973516c54855e90bf7
|
File details
Details for the file cryptologin-2.1.7-py3-none-any.whl.
File metadata
- Download URL: cryptologin-2.1.7-py3-none-any.whl
- Upload date:
- Size: 51.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da1e487421114182a64e2e20f4083375827b3052ae85c8a22d1c71e11afc7774
|
|
| MD5 |
38cc8d60875bb6fdc87226feed70f88f
|
|
| BLAKE2b-256 |
469b85dd57bea156c9cdb4044a53f5cb177fad2095e710b2a01e2f259d6e6db7
|