True random numbers sourced from live cryptocurrency market data
Project description
coinrandom
True random numbers sourced from live cryptocurrency market data.
import coinrandom
coinrandom.random() # 0.7182818...
coinrandom.randint(1, 100) # 42
coinrandom.choice(["a", "b", "c"])
Why coinrandom?
Cryptocurrency markets trade 24/7 globally. At the tick level — individual trade prices, quantities, timestamps, and buyer/seller direction — the data is highly unpredictable. The Efficient Market Hypothesis (EMH) says no one can consistently predict short-term market movements. coinrandom uses this unpredictability as an entropy source.
Trust Model
Even with the full source code published, no one can predict the output in advance — because no one can predict the coin market.
This is an application of Kerckhoffs's principle: security depends on the unpredictability of the market, not on keeping the algorithm secret. Each value generated by Heavy/SuperHeavy comes with a RandomProof — a verifiable audit trail showing exactly which market data produced the result.
Honest limits: coinrandom provides computational security (like AES/RSA), not information-theoretic security (like Chainlink VRF). The trust model is economic, not mathematical. For cryptographic key generation, use secrets. For smart contract RNG, use Chainlink VRF.
Installation
pip install coinrandom # Light + Heavy
pip install "coinrandom[superheavy]" # + SuperHeavy (numpy, scipy)
No API keys. No configuration.
Three Tiers
| Tier | Speed | Entropy source | Proof | Use case |
|---|---|---|---|---|
| Light | ~1ms | Binance tick + Argon2 | No | High-volume generation |
| Heavy | ~2s | 3 exchanges + ETH block hash + Argon2 | Yes | Raffles, NFT mints, DAO votes |
| SuperHeavy | ~30s | Portfolio-optimized coins + Heavy pipeline | Yes | Maximum entropy, auditable |
All tiers return the same API — drop-in replacement for Python's random module.
Usage
Light (default)
import coinrandom
coinrandom.random() # float in [0.0, 1.0)
coinrandom.uniform(1.5, 9.5)
coinrandom.randint(1, 100)
coinrandom.choice(["a", "b", "c"])
coinrandom.choices(["a", "b", "c"], k=5)
coinrandom.sample(range(100), k=10)
lst = [1, 2, 3, 4, 5]
coinrandom.shuffle(lst)
coinrandom.gauss(mu=0.0, sigma=1.0)
Heavy — with proof
from coinrandom.heavy import HeavyEngine
engine = HeavyEngine()
value, proof = engine.random_with_proof()
print(value) # 0.3571428...
print(proof.exchanges) # [{"name": "binance", "symbols": [...], ...}, ...]
print(proof.block_hash) # "0xabc123..."
print(proof.final_hash) # SHA-512 of the combined entropy
SuperHeavy — portfolio-optimized entropy
from coinrandom.superheavy import SuperHeavyEngine
engine = SuperHeavyEngine()
value, proof = engine.random_with_proof()
print(proof.selected_symbols) # coins selected by inverse portfolio optimization
print(proof.correlation_matrix) # correlation matrix of candidates
print(proof.optimization_result) # scipy SLSQP result
SuperHeavy runs inverse Markowitz portfolio optimization to select the least-correlated coins as entropy sources — maximizing entropy diversity.
Design Principles
- No API keys — works out of the box with
pip install - Uniform API — every tier exposes the same functions as
random - No stdlib random — custom HashDRBG (SHA-512 counter-based), Mersenne Twister not used anywhere
- Open-source safe — Kerckhoffs's principle: publishing the algorithm doesn't compromise security
- Intentionally heavy — Heavy/SuperHeavy: each call runs the full entropy pipeline. "Slow = costly to manipulate."
Internals
coinrandom/
├── __init__.py # Light tier as default API
├── core.py # fetch_binance_entropy, mix_entropy
├── proof.py # RandomProof, SuperProof dataclasses
├── light/ # HashDRBG + Argon2 (t=1, m=8MB) reseed cache
├── heavy/ # 3 exchanges parallel + ETH block hash + Argon2 (t=4, m=64MB)
└── superheavy/ # Inverse portfolio optimization → Heavy pipeline
HashDRBG
Custom SHA-512 counter-based DRBG. No import random anywhere in the codebase.
# Simplified
state = argon2(mix_entropy(coin_data, os.urandom(32)))
output = sha512(state + counter) # per call
Manipulation resistance
Heavy mode requires simultaneously moving 32+ coins across Binance, Upbit, and Coinbase in the exact direction needed — estimated cost: billions of dollars. SuperHeavy additionally hides the target coins until optimization runs.
Versioning
This project follows Semantic Versioning:
PATCH— bug fixes, internal improvementsMINOR— new features, backward-compatibleMAJOR— stable API declaration or breaking changes
Current status: 0.x (API stabilizing, not yet guaranteed stable)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file coinrandom-0.1.0.tar.gz.
File metadata
- Download URL: coinrandom-0.1.0.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b1fc11a8f114f4477f037274df1048c6b18294394dee3250a68c125cfc45cbe
|
|
| MD5 |
100f94c6496384d01878ccab12fddc17
|
|
| BLAKE2b-256 |
873cb830b8625d7f44b1be30103e9af46e4c21ad48c7e8e7b4007748fa4807ec
|
Provenance
The following attestation bundles were made for coinrandom-0.1.0.tar.gz:
Publisher:
cd.yml on LETUED/coinrandom
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coinrandom-0.1.0.tar.gz -
Subject digest:
2b1fc11a8f114f4477f037274df1048c6b18294394dee3250a68c125cfc45cbe - Sigstore transparency entry: 1553378886
- Sigstore integration time:
-
Permalink:
LETUED/coinrandom@f9ca572e2ad7755e7ccaf575b6983789c8488ee7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/LETUED
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@f9ca572e2ad7755e7ccaf575b6983789c8488ee7 -
Trigger Event:
push
-
Statement type:
File details
Details for the file coinrandom-0.1.0-py3-none-any.whl.
File metadata
- Download URL: coinrandom-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8c184ff6bb35bd71255f47581e805366c07bb739da7fc57d88fd7a44b3a4dfc
|
|
| MD5 |
eb1e70abdacf1c218cae6df4ff93f74f
|
|
| BLAKE2b-256 |
d0bd849cd72ec102e602fe2d478857e91dbee5d7dd1ce7764333cd07bd723df3
|
Provenance
The following attestation bundles were made for coinrandom-0.1.0-py3-none-any.whl:
Publisher:
cd.yml on LETUED/coinrandom
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coinrandom-0.1.0-py3-none-any.whl -
Subject digest:
c8c184ff6bb35bd71255f47581e805366c07bb739da7fc57d88fd7a44b3a4dfc - Sigstore transparency entry: 1553378890
- Sigstore integration time:
-
Permalink:
LETUED/coinrandom@f9ca572e2ad7755e7ccaf575b6983789c8488ee7 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/LETUED
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@f9ca572e2ad7755e7ccaf575b6983789c8488ee7 -
Trigger Event:
push
-
Statement type: