Skip to main content

RGE-256: ARX-based pseudorandom number generator with geometric entropy from Recursive Division Tree analysis

Project description

RGE-256: Geometric Entropy PRNG

PyPI version Python 3.8+ License: MIT

A novel ARX-based pseudorandom number generator (PRNG) with rotation schedules derived from Recursive Division Tree (RDT) entropy constants.

Features

  • 256-bit State: 8 × 32-bit words for large period and good distribution
  • ARX Architecture: Add-Rotate-XOR operations for efficient mixing
  • RDT-Derived Constants: Rotation schedule based on mathematical entropy constants
  • Multiple Output Formats: 32-bit, 64-bit, floats, ranges, bytes
  • State Serialization: Save and restore generator state
  • Utility Functions: Shuffle, choice, sample

Installation

pip install rge256-core

Quick Start

from rge256_core import RGE256

# Create a generator with a seed
rng = RGE256(seed=12345)

# Generate random numbers
print(rng.next32())           # Random 32-bit integer
print(rng.next_float())       # Random float in [0, 1)
print(rng.next_range(1, 100)) # Random int in range [1, 100]

# Generate random bytes
random_bytes = rng.next_bytes(16)
print(random_bytes.hex())

# Shuffle a list
deck = list(range(52))
shuffled = rng.shuffle(deck)

API Reference

Constructor

RGE256(
    seed=None,          # int, bytes, str, or None (uses system entropy)
    rounds=3,           # Number of mixing rounds (1-10)
    zetas=(1.585, 1.926, 1.262),  # RDT entropy constants
    domain="rge256-default"       # Domain separation string
)

Methods

Method Returns Description
next32() int Random 32-bit unsigned integer
next64() int Random 64-bit unsigned integer
next_float() float Random float in [0, 1)
next_double() float High-precision random double
next_range(min, max) int Random integer in [min, max]
next_bytes(n) bytes n random bytes
shuffle(list) list Fisher-Yates shuffled copy
choice(list) any Random element from list
sample(list, k) list k unique random elements

Design Notes

RGE-256 is a statistical PRNG, not a cryptographically secure RNG. Do not use for cryptographic applications.

Author

Steven Reid - ORCID: 0009-0003-9132-3410

License

MIT License

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

rge256_core-1.0.7.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

rge256_core-1.0.7-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file rge256_core-1.0.7.tar.gz.

File metadata

  • Download URL: rge256_core-1.0.7.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for rge256_core-1.0.7.tar.gz
Algorithm Hash digest
SHA256 1d87eb507c63ca2d2a6c72aed8900270d5c6e3fbf0a67ac4c7b1ec9a977fbc08
MD5 129c4ccfc8d75eb02a9ddaec7c99af15
BLAKE2b-256 812a2f5be4a2cd2d85aae24cbe3e4a6ed34c7199eefb81fac68a9c34582e0a83

See more details on using hashes here.

File details

Details for the file rge256_core-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: rge256_core-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for rge256_core-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 155825f3150b5a8bb18964f4eaf02b0507489f260cb5af4fd9baee31a854c4af
MD5 5482eb3c5b872793d6eddab92c3ab3e4
BLAKE2b-256 73c1614a13182a0a4fe0dfaeb8f07f38fb0f4b4ad22aba45cd078a8714f1d0b7

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