Harnessing the Hustle: Generating Randomness from Shibuya Crossing

In the realm of data security, true randomness serves as a cornerstone. Traditional methods of generating random numbers often fall short, lacking the unpredictability required for robust encryption.

Enter an unlikely hero: the bustling Shibuya Crossing in Tokyo. This project, inspired by CloudFlare's innovative approach using lava lamps for entropy, captures the kinetic energy of one of the world's busiest intersections to fuel cryptographic operations.

CloudFlare's Lava Lamps

CloudFlare, in their quest for enhancing security, turned to an unconventional method: a wall of lava lamps at their San Francisco office. Cameras record the random, ever-changing patterns formed by the floating blobs inside these lamps, and the footage is used to generate cryptographic keys. This method leverages physical randomness, which is challenging to simulate digitally.

Lava Lamp Wall in CloudFlare's Office
Lava Lamp Wall in CloudFlare's Office

Why Shibuya?

Shibuya Crossing is an epitome of perpetual motion. Hundreds of people crisscross in myriad directions, each step and movement a testament to unpredictability. By tapping into this dynamic visual scene, we gain access to a high entropy source that's perfect for cryptographic applications.

Shibuya Crossing, Tokyo
Shibuya Crossing, Tokyo

How It Works

The process begins with capturing a frame from a live video feed of Shibuya Crossing using yt-dlp and ffmpeg. This snapshot, rich in colors and minute details, is more than just a picture; it's a data mine ripe for entropy extraction.

Each pixel in this image carries information—its color values (red, green, and blue). These values are converted into a byte array, which serves as the raw material for the entropy generation process. The SHA-256 hashing algorithm then takes over, processing this array to produce a hash with a fixed 256-bit length.

To add an extra layer of complexity, we don't just use the hash directly. Instead, we encode it in base64 and cherry-pick 32 characters at random to form our final cryptographic key. This method ensures that the outcome is not only secure but also unique with each execution.

Diverse Sources for Randomness

The quest for better randomness doesn't have to stop at Shibuya Crossing or lava lamps. In fact, the potential sources for generating entropy are as varied as the world around us. Anything that exhibits unpredictable, dynamic movement can serve as a rich source of entropy.

Examples of Alternative Entropy Sources:

  • Pet Streams: Live streams of pets, such as dogs or cats, provide a continuous display of random behavior. Whether it’s a cat chasing a laser pointer or dogs playfully wrestling, the unpredictability of pets makes them excellent candidates for generating randomness.

  • Gaming Streams: Live broadcasts of video games, especially those involving multiple players and chaotic gameplay, are another great source. The spontaneous decisions made by players, combined with the game's inherent unpredictability, create a complex array of movements and outcomes.

  • Nature Cams: Streams showing natural scenes like forests, oceans, or bird feeders can also be utilized. The random movement of wildlife, changes in weather, and seasonal variations contribute to a constantly changing scene.

Installation and Usage

Installation Steps:

  1. Dependencies: Ensure you have Python installed, then use pip to install necessary packages:

    pip install Pillow yt-dlp
    
  2. FFmpeg: Install FFmpeg through your system's package manager (e.g., apt for Ubuntu, brew for macOS):

    sudo apt-get install ffmpeg
    
  3. Clone the Repository:

    git clone https://github.com/yu-jeffy/shibuya-entropy.git
    

Usage Instructions:

  1. Execute the Script: Run the script from your command line:

    python generateEntropy.py
    

    This command triggers the process to capture an image, extract entropy, and display the generated cryptographic key.

Implementing Your Own Source:

To use an alternative source of entropy:

  1. Select a Dynamic Stream: Choose a video stream that features high variability and unpredictability. Ensure the stream is a continuous Youtube livestream.

  2. Capture the Video: In shibuyaStream.py, modify the video_id parameter. Input the Youtube video ID of your chosen livestream.

  3. Process the Data: Run generateEntropy.py and the script will be updated to your source.

Subscribe to jeffy yu
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.