Skip to main content

Client library for unbiased random integers backed by Geiger counter entropy.

Project description

Nuclear Random

Experimental Python random integers backed by Geiger counter click timing.

pip install nuclear-random
from nuclear_random import choice, nuclear_random, randint, random_bytes, service_status

print(nuclear_random(100))      # 0..100 inclusive
print(nuclear_random(10_000))   # 0..10000 inclusive
print(randint(10, 20))          # 10..20 inclusive
print(random_bytes(16).hex())   # 16 bytes from the entropy pool
print(choice(["red", "green", "blue"]))

status = service_status()
print(status.pool_size_bytes, status.estimated_cpm)

How It Works

The public API consumes entropy bytes collected from an ESP32-C3 connected to a Geiger counter on GPIO 6. For any request nuclear_random(max_value), the API reads max_value.bit_length() bits and returns the candidate only if it is <= max_value. Candidates above the requested maximum are rejected and the API reads the next bits.

This rejection-sampling step avoids modulo bias.

Configuration

By default the client uses:

https://nuclear-api.datanode.live

Override it while testing:

export NUCLEAR_RANDOM_API_URL=http://127.0.0.1:19000

or per call:

nuclear_random(131, api_url="http://127.0.0.1:19000")

Server

The server stack is Docker-only and includes:

  • FastAPI API
  • Redis entropy byte pool
  • InfluxDB telemetry
  • Wi-Fi ingest endpoint for the ESP32-C3
  • serial collector fallback for USB deployments
  • status metrics for the future website
  • Redis-backed public API rate limiting
cp server/.env.example server/.env
docker compose -p nuclear-random --project-directory server up -d redis influxdb api
docker compose -p nuclear-random --project-directory server --profile collector up -d collector

See docs/architecture.md, docs/deployment.md, and docs/hardware.md. See docs/publishing.md for PyPI release steps.

The ESP32-C3 firmware posts click events to https://nuclear-api.datanode.live/v1/entropy/click. Its INGEST_TOKEN must match the server INGEST_TOKEN in /home/server/nuclear_random/server/.env. It should still be built with CDCOnBoot=cdc so the USB serial debug stream is visible on /dev/ttyACM0.

Useful API endpoints:

GET  /healthz
GET  /v1/status
GET  /v1/random/int?max=100
GET  /v1/random/bytes?length=16
POST /v1/entropy/click

Status

This project is alpha-quality. It is suitable for experimentation and public demos, but it has not been cryptographically audited.

License

MIT

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

nuclear_random-0.1.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

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

nuclear_random-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file nuclear_random-0.1.0.tar.gz.

File metadata

  • Download URL: nuclear_random-0.1.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nuclear_random-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b18772cd8b2770f96061c71c791e9a2dbdaf2658375847486aebf103617ec51c
MD5 bdd9bf48f947cee342ffa4216876efab
BLAKE2b-256 462729947a96fe65c45c744b4cd4b8bc33f941fbf586ff7530a5c61834fb7afd

See more details on using hashes here.

Provenance

The following attestation bundles were made for nuclear_random-0.1.0.tar.gz:

Publisher: publish.yml on TimofeySukh/nuclear-random

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nuclear_random-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nuclear_random-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nuclear_random-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 04a05d69b1e1bb3aac4f8d618f0e77483e402cc5f9a76db9f009e8c786c6cb6c
MD5 a60ebcb1a3d86c3034da60deda501e59
BLAKE2b-256 e683195a4368cc15f1f78a0d5cd75dcd0aa8560c259bdae1bc368a2622ec596f

See more details on using hashes here.

Provenance

The following attestation bundles were made for nuclear_random-0.1.0-py3-none-any.whl:

Publisher: publish.yml on TimofeySukh/nuclear-random

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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