Cryptography Module
⚠️ WARNING: This document is not finished. The details in this document are subject to change.
The Cryptography Module is a comprehensive browser-based cryptographic library designed as a reusable microfrontend component. It provides an intuitive wrapper around the Web Crypto API, making advanced cryptographic operations accessible and easy to use in modern web applications.
🔗 Quick Links
- Live Interactive Demo - Explore all features with interactive Storybook demos
- GitHub Repository - Source code and documentation
- NPM Package - Install and use in your projects
📚 What Is This?
This module serves as the cryptographic foundation for the chat application, providing all the security primitives needed for:
- End-to-end encrypted messaging using the Signal Protocol
- Secure key exchange between peers
- Data integrity verification with cryptographic hashing
- Password-based encryption for local data storage
- Random generation for unique identifiers and nonces
It's built with security, modularity, and ease of use as core principles, wrapping complex Web Crypto API operations into simple, intuitive functions.
✨ Core Features
🎲 Random Generation
- Cryptographically Secure Random Strings: Generate unpredictable random values for security-critical operations
- Deterministic Generation with Seeds: Reproducible randomness using Chance.js for testing and specific use cases
- Configurable Length: Customize random string length for different purposes
#️⃣ Hashing Functions
- SHA-256: Industry-standard 256-bit cryptographic hash
- SHA-512: Enhanced 512-bit hash for higher security requirements
- SHA3-512: Modern Keccak-based hash algorithm
- Use Cases: Data integrity verification, password hashing (with salt), content addressing
🔑 Asymmetric Encryption (RSA)
- 4096-bit RSA-OAEP: Military-grade public key cryptography
- Key Pair Generation: Create public/private key pairs in JWK format
- Import/Export: Seamlessly serialize and deserialize keys
- Use Cases: Secure key exchange, digital signatures, identity verification
🔒 Symmetric Encryption (AES)
- AES-256-GCM: Fast, authenticated encryption with integrity checking
- Initialization Vector (IV) Management: Automatic secure IV generation
- Password-Based Encryption: Derive encryption keys from user passwords
- Use Cases: File encryption, bulk data encryption, local storage security
📡 Signal Protocol Implementation
- X3DH Key Agreement: Extended Triple Diffie-Hellman for initial key exchange
- Double Ratchet: Forward secrecy and break-in recovery for ongoing messaging
- Ed25519 Signatures: Fast, secure digital signatures for authentication
- X25519 Key Exchange: Elliptic curve Diffie-Hellman for perfect forward secrecy
- Use Cases: End-to-end encrypted chat, secure P2P communication
⚡ Performance Tools
- Algorithm Benchmarking: Compare speed of different cryptographic operations
- Bulk Operation Testing: Measure performance under load
- Visual Charts: Interactive performance comparisons in Storybook demos