Skip to main content

Server-Side Secret-Free

PyPI version Python License: MIT

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_secret never 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

Download files

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

Source Distribution

cryptologin-2.1.6.tar.gz (44.5 kB view details)

Uploaded Source

Built Distribution

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

cryptologin-2.1.6-py3-none-any.whl (51.2 kB view details)

Uploaded Python 3

File details

Details for the file cryptologin-2.1.6.tar.gz.

File metadata

  • Download URL: cryptologin-2.1.6.tar.gz
  • Upload date:
  • Size: 44.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for cryptologin-2.1.6.tar.gz
Algorithm Hash digest
SHA256 eac9222a91f49dc40f072a47c47771b5e3d0134bb68a385451741ba2a9694647
MD5 7cf54a68bd1b9b7c70c1f51d16e2ded8
BLAKE2b-256 3b1dab8316aa52de751a60e6dc4cafa9a70778683e2af9d0ed5e1e37a24f41b8

See more details on using hashes here.

File details

Details for the file cryptologin-2.1.6-py3-none-any.whl.

File metadata

  • Download URL: cryptologin-2.1.6-py3-none-any.whl
  • Upload date:
  • Size: 51.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for cryptologin-2.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ed5145f6081b280c57c253512d8afdebba042608a559e7c4df000be534bdc30a
MD5 8f706a17de8d1e31aa9b382c64f2afed
BLAKE2b-256 8fdfa35e7a8f63fa1a9121c34c49641f6a567cb7095f5a05fb69335f63f9babd

See more details on using hashes here.

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