Programming

Secret Sharing

In this project, I implemented a secret sharing scheme between myself and two other fake users. If any three valid users submit three valid shards (identifiers) within a 30-second window, my web browser reveals a GIF of my choice that should be available until the 30-second window has passed. At all other times, the web browser displays a frowny face :(

Background on Secret Sharing

The Secret Sharing scheme is a way to ensure multiple parties are in agreement in order to allow an action to be carried out. For example, say you run a big company with four chief officers (CEO, CTO, etc…) and you only want to be able to pay out money to vendors if all four chief officers agree to do so. Using the secret sharing scheme, you’d give a special identifier to each officer, and have the program only pay out vendors if it receives all four identifiers (meaning all four officers agree) and that the four identifiers are valid (meaning they belong to the officers, and not impostors).

Identifiers

I generated a random polynomial that has three keys (identifiers). Each user was given a shard, i.e. a point on that polynomial that corresponds to one of these three keys. Thus, each shard stores both an x and a y-coordinate.

How I ensured enough shards (aka keys or identifiers) have been submitted

In my code, I first retrieve all of the shards that have been submitted in the past 30 seconds from the database I created. I then check if there are three unique shards by adding the shards to a new array if they are not already present in it. If the length of this array is less than three, then I automatically return :( since I know it is not possible for fewer than three shards to unlock the gif.

Handling bad shards

The second-order polynomial I created is stored in my as a variable in my code. Then I then take the x and y coordinates of the shards that have been submitted within the last thirty seconds and fit all the points to a new second-order polynomial. I then check if the y-intercept of the two polynomials are the same. If this is true, then I return the gif, but otherwise, I return :(


Recent Work