Skip to main content

AVRNG - GVRSF 2020 submission

An audio-visual random number generator, built for the Vancouver District Science Fair 2020.
Built with Python 3.7, October 2019 - current.
This PIP package is a mirror of the project at the GitHub. This distribution may lag behind development at the GitHub.

Applications

The AVRNG works well in a variety of application, mainly for security and surveillance-based solutions. One example use case is in an office, where security cameras can pass footage to the AVRNG and generate keys for the office's encryption algorithms. These keys are truly random due to the inherent randomness in sensor data when capturing footage, and to unpredictable compression and time-stamps.
To find the key, an attacker would have to obtain the exact data source with the same compression and XOR rate, and hash at the exact time and parameters the program would be running at. This security makes the AVRNG a TRNG.
A main inspiration was unique TRNG creations, such as the ones employed by Cloudflare. A great video on the topic was created by Tom Scott.

How it works

A video is split into audio and video streams. These streams are cut to smaller intervals.
For the audio, it's split on the interval specified in running the AVRNG. This smaller .wav file is hashed with Skein, a next-level hash and former SHA3 candidate.
The video stream is cut with the scenedetect tool, splitting at every unique scene. This works especially well with security footage (main application) with many pauses or intervals of near-identical footage. These smaller videos are then split into individual JPEGS, due to the JPEG's compression algorithm that will preserve the inherent randomness in the camera's sensor data. These photos then are hashed with Skein, as above.
These two data streams are intertwined together along with a time component, using XOR and bit addition algorithms. These outputs are written to a file, which can then be used as keys for cryptosecure applications.

Installation

With PIP

This method requires PIP to be installed and set up on your machine.
Open Terminal, and run pip install avrng to install the package.

With Git / Command Line

This method requires Git to be set up properly and configured on your machine.
Open Terminal, Command Prompt, or Git Bash (or any terminal app), and run git clone https://github.com/kewbish/avrng.git to create a copy of this repo on your local machine.
You should have a folder with the files. Proceed to installing dependencies.

With GitHub.com UI

Navigate to https://github.com/kewbish/avrng and click the green Clone or download button. Choose to Download ZIP. Navigate to the folder downloaded, and unzip the project files. Proceed to installing dependencies.

With GitHub Desktop

This method requires GitHub Desktop.
Open GitHub Desktop. (Alternatively, click Clone or download and select Open with Desktop.)
Click the Add dropdown in the top-left, and select Clone a repository. Open the URL pane, and paste https://github.com/kewbish/avrng into the Repository URL field. Select a local path, and click Clone.
You should now have a copy of the project files. Proceed to installing dependencies.

Dependencies

Install the following via pip:

Documentation

A GUI tool and a CLI are included.

GUI Usage

To run the GUI, open Terminal (or similar) and run python3 main.py in the project root. Alternatively, run main.py in an IDE.
To use the Tkinter GUI, input your desired values. The defaults are what I've tested to be the most consistent.
The end button will open a file dialog. Navigate to your desired source .mp4.
The output file will be generated in the parent directory of the selected video file.

CLI Usage

To use the CLI, open Terminal (or similar) and run python3 hash.py path\to\file.mp4 17 1.
The return_all() function wraps all the functionality of the AVRNG into one function.
Its three arguments are as follows:

  • path: complete path to source file
  • cs: length of individual output number
  • ai: interval to read data, in seconds Sample command - python hash.py \files\video.mp4 17 1 This will generate a text file with individual numbers in videos directory.
    This format is also used when importing and using the avrng pip package.

PIP Package

Add import avrng.avrng as av to the top of your Python file to add the package to your script.
Use the function as av.return_all() with the appropriate arguments.
(If you alternatively only want hashed lists of audio or video streams, you can access these through av.handle_audio() or av.handle_video() with the path and an integer as arguments.)

Comparison

The following comparison is between the AVRNG and the inbuilt Python random.randint() function.

Test AVRNG Inbuilt Python Comments
Runs Test 0.38529 0.15147 AVRNG 2.5 times more random
Entropy / bit 0.984360 0.982485 AVRNG 0.19% more random
Chi square 28742.64 365.44 AVRNG 78.65 times more distributed
Arithmetic mean 0.4265 0.4222 AVRNG closer to target 0.5
Serial correlation 0.018786 0.019704 AVRNG closer to zero, more unexpected
Speed 22.47s 0.03513s Inbuilt Python 639.5 times more efficient

License

Released under the GNU General Public License.

Metadata

Release files for avrng 1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for avrng 1.0
File Size Uploaded Provenance
avrng-1.0.tar.gz 5.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for avrng 1.0
File Interpreter ABI Platform
avrng-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.1 kB

Release files / avrng-1.0.tar.gz

Download URL avrng-1.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
67af7420d8754bfa16c00432ddcd64be39ea63cb95fed1a1f9a69611eb9b49d0
BLAKE2b-256 checksum
How to use checksums
1c788e27bd1a6e13ff6b06123fe87b3d35a6c348884c7a3df41e1089a4e608b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4

Release files / avrng-1.0-py3-none-any.whl

Download URL avrng-1.0-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92f05f51c5d7fc84bac9a01af207775d2b3c12d2e04a663fbc349450d2176a9a
BLAKE2b-256 checksum
How to use checksums
dc16338ef67344eae33c1bbcdfe6e9ad1ddd46e7a385440a5b372736bba6ccde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4

Security for avrng 1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page