Skip to main content

Production-ready hybrid cryptography combining classical (RSA/ECDSA) with post-quantum (Kyber/Dilithium) algorithms for quantum resistance and backward compatibility

Project description

๐Ÿ” RightsToSecure Hybrid Crypto Wrapper

Practical Hybrid Post-Quantum Cryptography Implementation
Developed by RightsToSecure
Founder: Praveen Naidu


๐Ÿ›ก๏ธ Overview

The RightsToSecure Hybrid Crypto Wrapper is a production-ready Python library that implements hybrid cryptography by combining classical algorithms (RSA/ECDSA) with post-quantum cryptography (Kyber/Dilithium). This approach provides quantum resistance while maintaining backward compatibility with existing cryptographic infrastructure.

๐ŸŽฏ Key Benefits

  • Quantum-Resistant: Protects against future quantum attacks
  • Backward Compatible: Works with existing RSA/ECC systems
  • Production Ready: Includes comprehensive testing and error handling
  • Easy Integration: Simple Python API with mock OQS support for development
  • Crypto-Agile: Designed for easy algorithm updates and migrations

โœ… Core Features

๐Ÿ” Hybrid Key Encapsulation (KEM)

  • RSA + Kyber: Combines RSA-2048/4096 with Kyber-512/768/1024
  • ECC + Kyber: Combines ECDSA (P-256/P-384/P-521) with Kyber
  • Session Key Derivation: Uses SHAKE256 for secure key generation
  • Multiple Security Levels: Choose from different Kyber security levels

โœ๏ธ Hybrid Digital Signatures

  • ECDSA + Dilithium: Dual signature scheme for maximum security
  • Compact & Structured Formats: Flexible signature representation
  • Tamper Detection: Built-in verification for message integrity
  • Multiple Curves: Support for secp256r1, secp384r1, secp521r1

๐Ÿ› ๏ธ Developer-Friendly Features

  • Mock OQS Implementation: Test without installing liboqs-python
  • Comprehensive Documentation: Detailed examples and API reference
  • Docker Support: Containerized deployment ready
  • REST API: FastAPI-based web service included
  • Console Scripts: Easy command-line demonstrations

๐Ÿš€ Quick Start

Installation

pip install rights-to-secure-hybrid-crypto

Basic Usage

from src import hybrid_kem, hybrid_signature, utils

# Generate hybrid keys
rsa_pub, rsa_priv = utils.generate_rsa_keys(2048)
kyber_pub, kyber_priv = utils.generate_kyber_keys("Kyber512")

# Perform hybrid key exchange
session_key, ciphertext = hybrid_kem.perform_key_exchange(
    "RSA", rsa_pub, "Kyber512", kyber_pub
)

# Create hybrid signature
message = b"Hello, Quantum World!"
ecdsa_pub, ecdsa_priv = utils.generate_ecdsa_keys("secp256r1")
dilithium_pub, dilithium_priv = utils.generate_dilithium_keys("Dilithium2")

signature = hybrid_signature.create_hybrid_signature(
    message, ecdsa_priv, dilithium_priv
)

๐Ÿ“ Project Structure

rights_to_secure_hybrid_crypto/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ hybrid_kem.py         # Hybrid Key Exchange implementation
โ”‚   โ”œโ”€โ”€ hybrid_signature.py   # Hybrid Digital Signatures
โ”‚   โ”œโ”€โ”€ utils.py              # Key generation, hashing, KDF
โ”‚   โ””โ”€โ”€ mock_oqs.py           # Mock OQS for testing
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ demo_key_exchange.py  # KEM demonstration
โ”‚   โ”œโ”€โ”€ demo_signing.py       # Signature demonstration
โ”‚   โ””โ”€โ”€ api_example.py        # FastAPI REST service
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ test_hybrid_kem.py    # KEM unit tests
โ”‚   โ””โ”€โ”€ test_hybrid_signature.py # Signature unit tests
โ”œโ”€โ”€ Dockerfile                # Container configuration
โ”œโ”€โ”€ docker-compose.yml        # Multi-service orchestration
โ””โ”€โ”€ USAGE.md                  # Comprehensive usage guide

๐Ÿ”ง Technical Implementation

Hybrid Key Exchange Process

  1. Classical Encryption: Encrypt random secret with RSA/ECC
  2. PQC Encapsulation: Use Kyber to encapsulate PQC secret
  3. Secret Combination: Concatenate both secrets
  4. Key Derivation: Apply SHAKE256 to generate final session key

Hybrid Signature Process

  1. Dual Signing: Sign message with both ECDSA and Dilithium
  2. Signature Combination: Concatenate both signatures
  3. Verification: Independently verify both signature components

Security Considerations

  • Cryptographically Secure Random: Uses secrets module
  • Secure Key Derivation: SHAKE256 and HKDF implementation
  • Private Key Protection: No hardcoded keys or weak defaults
  • Algorithm Agility: Easy to update cryptographic algorithms

๐Ÿงฐ Requirements

Core Dependencies

cryptography>=41.0.0    # Classical cryptography (RSA, ECC, ECDSA)
liboqs-python>=0.7.2    # Post-quantum cryptography (Kyber, Dilithium)
pytest>=7.0.0          # Testing framework

Optional Dependencies

# For API functionality
pip install rights-to-secure-hybrid-crypto[api]

# For web framework support
pip install rights-to-secure-hybrid-crypto[web]

# For development tools
pip install rights-to-secure-hybrid-crypto[dev]

๐Ÿณ Docker Deployment

Quick Start with Docker

# Build and run the API service
docker-compose up api

# Run with all services
docker-compose --profile full up

Available Services

  • API Service: FastAPI REST interface
  • Development: Hot-reload development environment
  • Testing: Automated test suite
  • Demo: Interactive demonstrations

๐Ÿ“Š Performance & Security Levels

Supported Algorithms

Classical Post-Quantum Security Level Use Case
RSA-2048 Kyber512 128-bit Development
RSA-3072 Kyber768 192-bit Production
RSA-4096 Kyber1024 256-bit High Security
ECDSA-P256 Dilithium2 128-bit Standard
ECDSA-P384 Dilithium3 192-bit Enhanced
ECDSA-P521 Dilithium5 256-bit Maximum

๐Ÿ” Testing & Validation

Test Coverage

  • โœ… Unit Tests: All core functions tested
  • โœ… Integration Tests: End-to-end workflows
  • โœ… Mock Testing: OQS-free testing environment
  • โœ… Performance Tests: Algorithm benchmarking
  • โœ… Security Tests: Cryptographic validation

Run Tests

# Run all tests
python -m pytest tests/

# Run with coverage
python -m pytest --cov=src tests/

# Run specific test suites
python test_simple.py      # Basic functionality
python test_core.py        # Core components
python test_comprehensive.py # Full feature set

๐Ÿš€ Production Deployment

Best Practices

  1. Use Real OQS: Install liboqs-python for production
  2. Secure Key Storage: Implement proper key management
  3. Regular Updates: Keep dependencies updated
  4. Monitoring: Monitor for security advisories
  5. Backup Strategy: Implement key backup and recovery

Integration Examples

  • TLS/SSL: Hybrid certificate generation
  • API Security: Request/response signing
  • File Encryption: Secure file storage
  • Message Security: End-to-end encryption
  • Blockchain: Quantum-resistant signatures

๐Ÿ“ž Support & Community

Documentation

  • API Reference: Comprehensive function documentation
  • Examples: Real-world usage scenarios
  • Tutorials: Step-by-step implementation guides
  • Best Practices: Security and deployment recommendations

Getting Help


๐Ÿ“„ License

MIT License - See LICENSE file for details.


๐Ÿ”— Links


Made with โค๏ธ by RightsToSecure Team

Project details


Download files

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

Source Distribution

rights_to_secure_hybrid_crypto-1.0.1.tar.gz (30.8 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file rights_to_secure_hybrid_crypto-1.0.1.tar.gz.

File metadata

File hashes

Hashes for rights_to_secure_hybrid_crypto-1.0.1.tar.gz
Algorithm Hash digest
SHA256 79381f1459b3e3e72728349dc990e0c3dbd55ca24547521526354f9c1922c0ae
MD5 7467f44a7ae6ef4308bdc9133f50e176
BLAKE2b-256 2e90623006315fd781bbd281c3d2c4263e1878f89a38ea03bbcf1bdc1fa5dada

See more details on using hashes here.

File details

Details for the file rights_to_secure_hybrid_crypto-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for rights_to_secure_hybrid_crypto-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e26dacad84065fb96da7a980e32431848491b8038430c99dc93452d07f6eca54
MD5 7ecc32c0c51b60b5ccb2825d3f110976
BLAKE2b-256 f1a0496fc09dc6c8b6f1b5f3cc9833daca7a94f88f49bb837535883010c1ee8e

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