Tsotchke Quantum Random Number Generator (QRNG)
A high-quality quantum random number generator library for Rust applications requiring cryptographically secure randomness. This library provides quantum-enhanced random number generation with specialized modules for cryptography, finance, games, and statistical analysis based on Tsotchke QRNG.
๐ Quick Start
Add this to your Cargo.toml:
[]
= "0.1"
Basic Usage
use quantum_rng;
๐ง Features
- ๐ Cryptographic Security: High-entropy random number generation suitable for cryptographic applications
- ๐ฐ Financial Modeling: Monte Carlo simulations and options pricing with quantum randomness
- ๐ฒ Gaming: Quantum dice and fair random number generation for games
- ๐ Statistical Analysis: Built-in statistical tests and validation functions
- โก Performance: Optimized for both quality and speed
๐ Usage Examples
Cryptography
use ;
// Generate cryptographic keys
let key_pair = generate_keypair;
let derived_key = derive_key;
Finance
use monte_carlo;
// Run Monte Carlo simulation
let simulation = new
.iterations
.initial_value
.volatility
.build;
let results = simulation.run;
println!;
Games
use quantum_dice;
// Roll quantum dice
let dice = new; // 6-sided die
let roll = dice.roll;
println!;
Statistical Testing
use tests;
// Test randomness quality
let mut rng = new;
let samples: = .map.collect;
let chi_square_result = chi_square_test;
println!;
๐ฏ Use Cases
For Cryptographic Applications
- Key Generation: Generate secure cryptographic keys for encryption
- Salt Generation: Create unpredictable salts for password hashing
- Nonce Generation: Generate unique numbers for cryptographic protocols
- Session Tokens: Create secure session identifiers
For Financial Modeling
- Monte Carlo Simulations: Risk assessment and portfolio optimization
- Options Pricing: Calculate fair values for financial derivatives
- Market Risk Models: Stress testing and scenario analysis
- Portfolio Backtesting: Historical performance simulation
For Gaming
- Fair Dice Rolling: Provably fair random number generation
- Card Shuffling: Secure deck randomization
- Lottery Systems: Transparent and verifiable random selection
- Procedural Generation: Random world/level generation
For Scientific Computing
- Statistical Sampling: Generate samples from various distributions
- Hypothesis Testing: Statistical significance testing
- Randomized Algorithms: Algorithm performance optimization
- Simulation Studies: Scientific modeling and analysis
๐ API Reference
Core Module
use quantum_rng;
// Create a new quantum RNG instance
let mut rng = new;
// Generate different types of random numbers
let u64_value = rng.generate_u64; // 64-bit unsigned integer
let f64_value = rng.generate_f64; // 64-bit floating point (0.0 to 1.0)
let bool_value = rng.generate_bool; // Boolean value
let range_value = rng.generate_range; // Integer in range [1, 100)
Cryptography Module
use ;
// Generate RSA key pair
let keypair = generate_keypair;
// Derive key from master key
let derived_key = derive_key;
Finance Module
use ;
// Monte Carlo simulation
let simulation = new
.iterations
.initial_value
.volatility
.drift
.time_horizon
.build;
let results = simulation.run;
println!;
println!;
println!;
// Options pricing
let option_price = black_scholes;
Games Module
use quantum_dice;
// Create quantum dice
let d6 = new;
let d20 = new;
// Roll dice
let roll = d6.roll;
println!;
// Multiple rolls
let rolls = d20.roll_multiple;
println!;
Statistical Module
use tests;
// Generate test data
let mut rng = new;
let samples: =
.map
.collect;
// Perform statistical tests
let chi_square = chi_square_test;
let kolmogorov_smirnov = ks_test;
let runs_test = runs_test;
println!;
println!;
println!;
๐ก๏ธ Security Considerations
- Cryptographic Quality: The quantum RNG provides cryptographically secure random numbers suitable for security-sensitive applications
- Entropy Source: Uses multiple entropy sources to ensure high-quality randomness
- Regular Testing: Built-in statistical tests verify the quality of generated random numbers
- Side-Channel Resistance: Designed to resist timing and other side-channel attacks
๐ Performance
The library is optimized for both quality and performance:
- Generation Speed: ~100M random numbers per second on modern hardware
- Memory Efficiency: Minimal memory footprint with efficient buffering
- Thread Safety: Safe for concurrent use across multiple threads
- Zero Allocation: Core operations avoid heap allocations
๐งช Testing
Run the test suite to verify functionality:
# Run all tests
# Run specific test module
# Run with output
Run benchmarks to measure performance:
๐ Examples
Complete examples are available in the examples/ directory:
# Basic usage
# Cryptographic key generation
# Monte Carlo simulation
# Quantum dice game
# Quantum blockchain
๐ค Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue for any suggestions or improvements.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.