added chop & stack method, optimizations

This commit is contained in:
randogoth 2024-12-28 23:18:41 +02:00
parent c737460cce
commit 9f3d56c50a
4 changed files with 139 additions and 72 deletions

View file

@ -1,41 +1,50 @@
# ocelli: Camera-Based TRNG
**Ocelli** is a Rust application that uses a camera to generate high-quality random entropy by analyzing pixel intensity differences between consecutive frames.
**Ocelli** is a Rust application that generates high-quality entropy using a camera feed. The application supports two entropy generation methods (`get_entropy` and `chop_and_stack`) and optionally applies Van Neumann whitening for enhanced randomness. Generated entropy is saved as a binary file.
## Features
- **Camera-Based Entropy**: Leverages grayscale pixel intensity differences to produce entropy bits.
- **Shannon Entropy Validation**: Filters entropy data to ensure high randomness quality.
- **Van Neumann Whitening**: Optional bias removal for unbiased entropy output.
- **Dynamic Frame Handling**: Automatically captures frames based on resolution and entropy requirements.
## Requirements
- OpenCV (with Rust bindings)
- **Entropy Methods**:
- `get_entropy`: Compares pixel values between frames.
- `chop_and_stack`: Combines and processes pixel data with reversed rows.
- **Van Neumann Whitening**: Optional, enabled via the `-w` flag.
- **Shannon Entropy Test**: Ensures the randomness quality of generated entropy.
## Usage
Run the program with the desired parameters:
```bash
cargo run -- <entropy_length> <resolution_width> <resolution_height> [-w]
```
### Parameters:
- `<entropy_length>`: Number of bytes of entropy to generate.
- `<resolution_width>`: Camera resolution width.
- `<resolution_height>`: Camera resolution height.
- `-w`: (Optional) Enable Van Neumann whitening for unbiased entropy.
### Example:
Generate 1000 bytes of entropy at 1920x1080 resolution with whitening enabled:
```bash
cargo run -- 1000 1920 1080 -w
cargo run --release -- <entropy_length_in_bytes> <resolution_width> <resolution_height> [-w]
```
---
### Example
```bash
cargo run --release -- 1024 640 480 -w
```
This generates 1024 bytes of whitened entropy using a 640x480 resolution.
## Requirements
- OpenCV 4.x
## Installation
1. Install Rust: https://www.rust-lang.org/tools/install
2. Install OpenCV: Follow the [official guide](https://docs.opencv.org/).
3. Clone the repository:
```bash
git clone <repository_url>
cd ocelli-entropy-generator
```
4. Run the application:
```bash
cargo run --release -- <arguments>
```
## Output
- **Hexadecimal Entropy**: Generated entropy is output as a hexadecimal string.
- **Processing Time**: Reports how long the entropy generation took.
- **Shannon Entropy**: Displays the Shannon entropy of the final output.
Generated entropy files are saved in the current directory with a name format:
```
<method>[_whitened]_YYYYMMDD_HHMMSS.bin
```