Package: avrng
AVRNG - GVRSF 2020 submissionAn 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 atthe GitHub. This distribution may lag behind development at the GitHub.ApplicationsThe 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 aretruly randomdue 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 aTRNG.A main inspiration was unique TRNG creations, such as the ones employed byCloudflare. A great video on the topic was created byTom Scott.How it worksA 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 withSkein, a next-level hash and former SHA3 candidate.The video stream is cut with thescenedetecttool, 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.InstallationWith PIPThis method requires PIP to be installed and set up on your machine.Open Terminal, and runpip install avrngto install the package.With Git / Command LineThis 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 rungit clone https://github.com/kewbish/avrng.gitto 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 UINavigate tohttps://github.com/kewbish/avrngand click the greenClone or downloadbutton. Choose toDownload ZIP. Navigate to the folder downloaded, and unzip the project files. Proceed to installing dependencies.With GitHub DesktopThis method requires GitHub Desktop.Open GitHub Desktop. (Alternatively, clickClone or downloadand selectOpen with Desktop.)Click theAdddropdown in the top-left, and selectClone a repository. Open theURLpane, and pastehttps://github.com/kewbish/avrnginto theRepository URLfield. Select a local path, and clickClone.You should now have a copy of the project files. Proceed to installing dependencies.DependenciesInstall the following via pip:PydubPyskeinScenedetect(requiresnumpy,opencv2, andffmpeg)
Alternatively, runpip install -r requirements.txtwith the prepackaged requirements file.DocumentationA GUI tool and a CLI are included.GUI UsageTo run the GUI, open Terminal (or similar) and runpython3 main.pyin the project root. Alternatively, runmain.pyin 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 UsageTo use the CLI, open Terminal (or similar) and runpython3 hash.py path\to\file.mp4 17 1.Thereturn_all()function wraps all the functionality of the AVRNG into one function.Its three arguments are as follows:path: complete path to source filecs: length of individual output numberai: interval to read data, in seconds
Sample command -python hash.py \files\video.mp4 17 1This will generate a text file with individual numbers invideosdirectory.This format is also used when importing and using theavrngpip package.PIP PackageAddimport avrng.avrng as avto the top of your Python file to add the package to your script.Use the function asav.return_all()with the appropriate arguments.(If you alternatively only want hashed lists of audio or video streams, you can access these throughav.handle_audio()orav.handle_video()with the path and an integer as arguments.)ComparisonThe following comparison is between the AVRNG and the inbuilt Python random.randint() function.TestAVRNGInbuilt PythonCommentsRuns Test0.385290.15147AVRNG 2.5 times more randomEntropy / bit0.9843600.982485AVRNG 0.19% more randomChi square28742.64365.44AVRNG 78.65 times more distributedArithmetic mean0.42650.4222AVRNG closer to target 0.5Serial correlation0.0187860.019704AVRNG closer to zero, more unexpectedSpeed22.47s0.03513sInbuilt Python 639.5 times more efficientLicenseReleased under theGNU General Public License.