Skip to main content

Cryptography-inspired random generation experiment

Project description

senol-randomizer

An RNG-core-based random data generator written in a cryptographic style — but lacking any cryptographic proof — which creates an information asymmetry between the program and /dev/urandom.


logo

Python License Status GitHub PyPI


Table of Contents


Overview

senol-randomizer is a Python library that wraps /dev/urandom entropy with a modular exponentiation layer using large 256-bit prime numbers. The result is a pseudorandom stream that passes all 15 NIST SP 800-22 Rev. 1a statistical tests, while deliberately not claiming cryptographic security — the transformation adds complexity at the cost of provable properties.


Installation

pip install senol-randomizer

How It Works

  1. Entropy source: Reads 256-bit raw values from /dev/urandom.
  2. Transformation: Applies powmod(a, b, n) via the gmpy2 library — performing modular exponentiation for each value of n.
  3. Prime moduli: The set of n values consists exclusively of 256-bit prime numbers.
  4. Derived types: All higher-level data types (str, float, bool, etc.) are derived from this core output.

The design intentionally introduces an asymmetry: the consumer of the output has less information about the internal state than /dev/urandom alone would expose, but this property is structural, not mathematically proven.


API Reference

Function Description Arguments Returns
RNG() Core function. Generates a random large integer with no range constraint. int
newint() Random integer within a given range. min_val: int, max_val: int int
newfloat() Random float within a given range. min_val: int, max_val: int float
newbool() Random boolean. bool
newbyte() Random bytes of a given length. num: int bytes
newstr() Random string sampled from the full Unicode range. num: int, min_val: int, max_val: int str
newtoken() Random URL-safe string. length: int str
choice() Selects a random element from a list. lst: list any
shuffle() Shuffles a list in-place and returns it. O(n). lst: list list
compress() Maps a value into [min, max] while minimizing modulo bias. value, min_val: int, max_val: int int

Statistical Test Results

Results from the NIST SP 800-22 Rev. 1a test suite, run against 1 Mibibit (33,554,432 bits) of RNG() output.

Test P-Value Result
monobit_test 0.046613138703915244 ✅ PASS
frequency_within_block_test 0.6787903492122158 ✅ PASS
runs_test 0.33232036052397196 ✅ PASS
longest_run_ones_in_a_block_test 0.21020703185565603 ✅ PASS
binary_matrix_rank_test 0.2571877713800565 ✅ PASS
dft_test 0.8685773273998374 ✅ PASS
non_overlapping_template_matching_test 0.893926430778068 ✅ PASS
overlapping_template_matching_test 0.7796009868841686 ✅ PASS
maurers_universal_test 0.9802530560443485 ✅ PASS
linear_complexity_test 0.4685290247356243 ✅ PASS
serial_test 0.5630465232357214 ✅ PASS
approximate_entropy_test 0.5631130245829565 ✅ PASS
cumulative_sums_test 0.039939937090386124 ✅ PASS
random_excursion_test 0.5178616373360564 ✅ PASS
random_excursion_variant_test 0.14694060874229203 ✅ PASS

15 / 15 PASS — Work in progress.


Links

GitHub Repository · PyPI Package

Author on GitHub · Author on PyPI


— Batuhan Şenol

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

senol_randomizer-0.2.5.tar.gz (12.6 kB view details)

Uploaded Source

Built Distribution

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

senol_randomizer-0.2.5-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file senol_randomizer-0.2.5.tar.gz.

File metadata

  • Download URL: senol_randomizer-0.2.5.tar.gz
  • Upload date:
  • Size: 12.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for senol_randomizer-0.2.5.tar.gz
Algorithm Hash digest
SHA256 953da39a72641996e1260e0ece04af1642a138d9d3ff6c9d20b2090d31aa2122
MD5 02a4568904dbff837fd5d377da34fcf0
BLAKE2b-256 4cd2a259b45b476bf6ea943054ed5762ccac407de7a5e1ca603e7424df8f2896

See more details on using hashes here.

File details

Details for the file senol_randomizer-0.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for senol_randomizer-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f287c94f38094f53d17987880684be7edfb8922ee61385ab296d11ac72dfcb75
MD5 f5fda463a7322c399547ca0de164e58d
BLAKE2b-256 96422b70d7267075ff7539bcdb1ca6de9bb883a2fff4d98df307a27c84eb76c5

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