RNGneProcessor , Random Number Generator from Natural Entropy

milky-way
Image by Neverlan from Pixabay

RNGneProcessor: True Randomness from Natural Entropy

Introduction: The True Randomness Approach

The RNGneProcessor class embodies the core concept that physical, chaotic phenomena are the ideal source for generating True Random Numbers (TRNGs). While algorithmic generators (PRNGs) are fast, they are mathematically predictable. True security, especially in cryptography, requires unpredictability drawn from the physical world.

The RNGne project implements a robust two-phase approach to leverage this natural chaos for secure applications:

  1. Extraction Phase (TRNG): Uses an image of a chaotic natural scene (like waves or lightning) to capture the random thermal noise of the camera sensor.
  2. Amplification Phase (CSPRNG Seed): Converts the extracted raw entropy into a tiny, high-quality Cryptographic Master Seed via a cryptographic hash. This seed can then be mathematically amplified into an infinite stream of secure random numbers using a CSPRNG.

RNGneProcessor PHP Class, Documentation

Core Operations and Methodology

The system operates by extracting the most volatile and noisy part of the image data: the Least Significant Bit (LSB).

1. Entropy Extraction (LSB Method)

The processImageForRandomBits() method performs the following low-level data extraction:

  • Pixel Iteration: The function iterates through every pixel in the uploaded image.
  • Grayscale Conversion: It averages the Red, Green, and Blue (RGB) components to find the single grayscale intensity value for that pixel.
  • LSB Isolation: It isolates the Least Significant Bit (LSB) of the grayscale value using the modulo operator (% 2). This LSB is the part of the pixel data most likely to be affected by the unpredictable thermal and quantum noise of the camera sensor, making it the purest source of entropy.

2. Entropy Quality Test (Shannon’s Formula)

The calculateShannonEntropy() method is the validation metric for the quality of the raw bits:

  • Purpose: It measures the uncertainty or the average information content of the bit stream.
  • Metric: The result is given in . A value of signifies a statistically perfect, uniform distribution of ‘0’s and ‘1’s (i.e., maximum randomness). Any deviation below indicates a measurable bias or pattern.

3. Cryptographic Extractor (SHA-256)

The extractMasterSeed() method performs the critical security transition:

  • Input: The long string of raw, high-entropy bits.
  • Process: It passes the entire bit string through the irreversible and collision-resistant SHA-256 hash function.
  • Output: The result is a 256-bit Cryptographic Master Seed (a 64-character hexadecimal string). This process cleanses any remaining weak bias from the raw source and ensures the final seed is uniformly random and secure.

Validation Results: Proving Purity and Precision

To validate the RNGneProcessor, tests were conducted using sources ranging from zero entropy (control) to maximum entropy (ideal source).

Source Image Description Result (Shannon H) Conclusion
Waves High-complexity natural scene (Chaos, thermal noise). bits/pixel Ideal Source Validation. Confirms the LSB of chaotic natural images yields maximum, unbiased entropy.
White square
Artificially uniform, pure white image (Control). bits/pixel Zero Entropy Control. Confirms that predictable data (all LSBs are ‘1’s) results in zero uncertainty.
Black Square
Artificially uniform, pure black image (Control). bits/pixel Zero Entropy Control. Confirms that predictable data (all LSBs are ‘0’s) results in zero uncertainty

The project’s precision is demonstrated by its ability to accurately measure the entire range: from perfect predictability () to the highest level of natural chaos ().

Requirements and Usage

RNGneProcessor is distributed for free under an open-source license.

Requirements:

  • PHP 7.0+
  • GD Extension (for image manipulation)

Best Practices for High Entropía Sources: To ensure the best possible Master Seed, users should prioritize images that maximize the sensor noise:

  • Photos of chaotic elements: Lightning, ocean waves, dense foliage.
  • Photos taken in low light conditions (which amplifies thermal noise).
  • Use PNG or RAW image formats (lossless) to avoid compression artifacts that reduce real entropy.

Installation and Testing Guide for RNGne

This guide will walk you through setting up and validating the RNGne (Random Number Generator from Natural Entropy)

Step 1: File Setup

  1. Create the Project Folder: Navigate to your web server’s root directory and create a new folder named rngne.
  2. Save the Code: Place the two PHP files inside this new rngne folder.
    • RNGneProcessor.php (The class containing the LSB extraction and SHA-256 logic).
    • upload_and_process.php (The web interface and controller).
  3. Create the Upload Directory: Inside the rngne folder, create a new subdirectory named uploads.
  4. Permissions: Ensure the uploads folder has write permissions (This is usually automatic on local Windows setups, but is essential for Linux/production servers).

Your Folder Structure Should Look Like This:

/rngne
|-- RNGneProcessor.php
|-- upload_and_process.php
|-- /uploads (Empty folder, must be writable)

Step 2: Acquire a Test Image

To perform validation tests, you’ll need two types of images:

  1. High-Entropy Image (Ideal Source): An image of pure chaos, like ocean waves, static, deep-sky photography, or lightning. This should yield a Shannon Entropy of .
  2. Zero-Entropy Image (Control Source): A solid black or solid white image. This should yield a Shannon Entropy of .

Step 3: Execution and Validation

  1. Start Your Server: Ensure your Apache web server is running.
  2. Open the Tool: Open your web browser and navigate to your project URL (e.g., http://yourtestdomain/rngne/upload_and_process.php).
  3. Perform Control Test (Zero Entropy):
    • Click «Select Image File» and upload your solid black or white control image.
    • Click «Extract & Generate Seed».
    • Validation Check: The Shannon Entropy Test (H) result should be near .
  4. Perform Entropy Test (Ideal Source):
    • Click «Select Image File» and upload your high-entropy image (e.g., the image of the waves).
    • Click «Extract & Generate Seed».
    • Validation Check: The Shannon Entropy Test (H) result should be near .

If both tests pass, your RNGne system is correctly installed and functioning, and it is accurately converting the physical chaos of the image into a high-quality Cryptographic Master Seed.

Publicado el 07 Oct, 2025

Compartir en FacebookCompartir en XCompartir en LinkedinCompartir en PinterestCompartir en Whatsapp