A novel cryptographic authentication system that implements an evolving login scheme based on linear transformations of matrices over a prime field. This project demonstrates how mathematical concepts from linear algebra can be applied to create dynamic authentication mechanisms that change with each login attempt.
Unlike traditional static passwords, this system uses a 4x4 matrix that evolves through deterministic linear transformations with each authentication. The login "secret" changes over time, making it resistant to replay attacks and providing a unique authentication experience based on mathematical transformations.
- Evolving Authentication: Each login applies a new linear transformation to the base matrix
- Mathematical Foundation: Built on Galois Field GF(257) with 4x4 matrix operations
- Cross-Platform: Available as both C++ command-line tool and web interface
- Deterministic Evolution: Uses SplitMix64 PRNG for reproducible transformations
- SHA-256 Integration: Secure hashing for login code generation
- JSON Key Format: Human-readable key storage with integrity checksums
Simply open web/index.html in any modern browser - no server required!
cd cpp
make
./matrix_login gen --username alice --out alice.key.json
./matrix_login code --key alice.key.jsonThe system operates in Galois Field GF(257) (integers modulo 257) using 4x4 matrices:
- Initialization: At registration, a seed is derived from the current date/time, and a base matrix
M₀is generated - Evolution: On the k-th login, a deterministic transform matrix
T(k)is computed (invertible mod 257) - Transformation: The current matrix evolves as:
M_k = T(k) · T(k-1) · … · T(1) · M₀ (mod 257) - Authentication: Login code is
SHA-256(username || flattened(M_k))(hexadecimal) - Update: After successful login, the counter increments and the key evolves
Registration → M₀ (Base Matrix)
↓
Login #1 → T(1) → M₁ = T(1) · M₀
↓
Login #2 → T(2) → M₂ = T(2) · M₁ = T(2) · T(1) · M₀
↓
Login #3 → T(3) → M₃ = T(3) · M₂ = T(3) · T(2) · T(1) · M₀
↓
...and so on
Keys are stored as JSON files with the following structure:
{
"version": 1,
"username": "alice",
"modulus": 257,
"dim": 4,
"seedHex": "a1b2c3d4e5f6789012345678901234567890",
"m0": [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]],
"counter": 0,
"checksum": "sha256_hash_of_canonical_fields"
}seedHex: 16-byte hexadecimal seed derived from registration timestampm0: Base 4x4 matrix generated from the seed using SplitMix64 PRNGcounter: Current login attempt number (increments after each successful login)checksum: SHA-256 hash of canonical fields to prevent casual tamperingversion: Key format version for future compatibility
🚨 IMPORTANT: This is a research/educational project demonstrating novel cryptographic concepts.
- ❌ DO NOT use for production authentication
- ❌ No cryptographic security guarantees are provided
- ❌ Deterministic evolution may leak structural information if observed
- ✅ Intended for learning and experimentation only
Requirements: C++17 or newer, make
# Build the project
cd cpp
make
# Generate a new key
./matrix_login gen --username alice --out alice.key.json
# Get current login code
./matrix_login code --key alice.key.json
# Advance to next login (updates key)
./matrix_login advance --key alice.key.json --out alice.key.json
# Verify a login code
./matrix_login verify --key alice.key.json --code <hex_code>| Command | Description |
|---|---|
gen |
Create a new authentication key using current timestamp as seed |
code |
Compute current login code for the key's counter (read-only) |
advance |
Increment counter and save updated key for next login |
verify |
Check if provided code matches current expected code |
The web demo provides a user-friendly graphical interface:
# Simply open in any modern browser
open web/index.htmlWeb Features:
- 🎲 Generate new keys with current timestamp seed
- 📁 Load/save key JSON files
- 🔍 View current login code and preview next code
- ⏭️ Advance counter and download updated key
- 📱 Responsive design works on desktop and mobile
Both C++ CLI and web interface use identical algorithms:
- Field: GF(257) with 4x4 matrices
- PRNG: SplitMix64 seeded by
seedHex+ login index - Transform Generation: Retries until
det(T(i)) ≠ 0 (mod 257) - Login Code:
SHA-256(username || flattened(M_k))
This ensures perfect interoperability between implementations.
MATRIX_ENCRYPTION/
├── cpp/ # C++ command-line implementation
│ ├── main.cpp # CLI entry point
│ ├── matrix.cpp/hpp # Matrix operations
│ ├── gf257.cpp/hpp # Galois Field arithmetic
│ ├── key.cpp/hpp # Key management
│ ├── sha256.cpp/hpp # SHA-256 hashing
│ └── Makefile # Build configuration
├── web/ # Web interface
│ ├── index.html # Main web page
│ ├── logic.js # Core authentication logic
│ ├── app.js # UI interactions
│ └── styles.css # Styling
└── README.md # This file
- Server Integration: Store expected counters server-side for true authentication
- Matrix Dimensions: Configurable matrix sizes (currently 4x4)
- Field Selection: Support for different prime fields beyond GF(257)
- Key Derivation: Generate
m0purely from seed for smaller key files - Security Analysis: Formal cryptographic analysis of the scheme
This project is released under the MIT License. See the project for educational and research purposes.
Made with ❤️ for the cryptographic community