Inspiration

As the saying goes, a fence is only as strong as its weakest link. This holds true not just for physical security, but for cyber security as well. All of your emails and text messages rely on strong encryption to keep your information safe, and that's why we still possess at least some notion of privacy.

At the heart of strong encryption is the ability to generate random numbers. Unfortunately, the random number generators software developers typically use are purely deterministic -- once the generator has been seeded, all future values are fixed until the next seed. On a desktop, high-entropy data typically comes from a combination of time, mouse movement, and network data. That type of high-entropy seeding is strikingly lacking when it comes to mobile devices. If a malicious entity is able to collect a sufficient amount of generated numbers, they can predict all of the future random numbers generated by your phone. (The crux of it's encryption technology!) A successful attacker would be able to predict your keys, and read all of your messages.

The best way around these potential security vulnerabilities is to use a True Random Number Generator (TRNG), which uses hardware to generate numbers, as opposed to a Pseudo Random Number Generator (PRNG), which uses software. By relying on a high-entropy physical process instead of deterministic software, a TRNG's results are completely unpredictable. While some specialized devices are equipped with a TRNG, the vast majority of our devices -- for instance, our cell phones -- rely on inferior PRNGs.

What it does

Rando Shot First is able to quickly generate large amounts of truly random data by extracting the noise out of several photographs taken on an iPhone. We employ an algorithm that computes a one-way transform over the the RGB values of a number of photos' pixels and other methods for "harvesting" the entropy from several pixels. The original picture is completely destroyed, leaving only random noise due to both sensor imprecision and physical randomness. Each set of pictures are able to generate approximately 10,000 truly random bits. We ran several randomness benchmarks over the data such as the Wald–Wolfowitz runs test, which confirmed that our bitmaps have high degrees of randomness.

After completing its scan, the app itself displays a bitmap representation of the random bits generated as well as a sample 64 bit random integer.

How we built it

We used Swift and Xcode to create the iOS app, grabbing raw, uncompressed images from the camera sensors.

Challenges we ran into

When we initially ran the app, we only used one picture to generate our random numbers. However, regions of the image with low entropy, such places as by light sources, created large sections of white patterns in the resulting bitmap, not the random behavior we anticipated. In order to solve this, we have the user take several photos in different positions. All regions of high entropy are superposed and combine to form a highly random bitmap.

Additionally, it took a while to figure out how to have the camera interact with our app and read pixels from the camera since both Swift and the APIs we needed to use have changed quite a bit over the past couple years. It was difficult finding current example code to reference.

Accomplishments that I'm proud of

The end result is smooth and streamlined. It works consistently with a fluid, easy-to-use interface, and it provides an interesting solution to a problem many people don't usually think about.

What I learned

Over the course of this project, we learned a good bit about random number generation, Swift, and Xcode. I feel a lot more comfortable working with iOS design as well.

What's next for Rando Shot First

Implementation of a messaging client that uses the random numbers for public key encryption. Additionally now that we've published our open source code, any number of other applications could implement this random number generation algorithm.

Built With

Share this project:

Updates