Skip to content

Commit 89dcdaf

Browse files
committed
docs(readme): add Hybrid Mode section with tuning guidelines
1 parent 68090d6 commit 89dcdaf

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,44 @@ print_health_report(get_pool())
149149
> **Note**: Offline mode provides reduced entropy diversity. For security-critical applications, consider using all available sources when network access is available.
150150
151151

152+
## Direct vs Hybrid Mode
153+
154+
TrueEntropy offers two modes of operation to balance security and performance:
155+
156+
| Mode | Entropy Source | Performance | Use Case |
157+
|------|---------------|-------------|----------|
158+
| **DIRECT** (Default) | Directly from entropy pool | Slower, blocking | Cryptographic keys, wallets, severe security |
159+
| **HYBRID** | PRNG seeded by pool | Extremely fast | Simulations, games, UI, general purpose |
160+
161+
### Using Hybrid Mode
162+
163+
Hybrid mode uses the TrueEntropy pool to periodically re-seed a fast pseudo-random number generator (PRNG). This provides the best of both worlds: the speed of standard Python random numbers with the entropy quality of our harvesters.
164+
165+
```python
166+
import trueentropy
167+
168+
# Configure Hybrid Mode (re-seed every 60 seconds)
169+
trueentropy.configure(mode="HYBRID", hybrid_reseed_interval=60.0)
170+
171+
# Generate numbers at max speed
172+
# Generate numbers at max speed
173+
# The internal PRNG is automatically re-seeded from the entropy pool
174+
for _ in range(1000000):
175+
val = trueentropy.random()
176+
```
177+
178+
### Tuning Hybrid Mode
179+
180+
The `hybrid_reseed_interval` should be chosen based on your `offline_mode` setting:
181+
182+
* **Online (Default)**: Network harvesters take time to collect entropy (latency). Set the interval to **10.0s or higher** to allow the pool to refill between reseeds.
183+
* **Offline (`offline_mode=True`)**: Local sources are near-instant. You can use lower intervals (e.g., **1.0s - 2.0s**) for frequent reseeding.
184+
185+
> **Tip**: If `health()` reports degraded status with low entropy bits, increase your reseed interval.
186+
187+
188+
189+
152190
## Advanced Features
153191

154192
### Async Support

0 commit comments

Comments
 (0)