Sharing a secret
Making a backup of a secret can be tricky. For instance: I have a lot of passwords stored in an encrypted file, which I can edit through my password manager. The data in that file is both very sensitive and crucial. I currently have some offline backups (which are updated every once in a while) in different locations and one online backup in case I lose access to my passwords and I am not able to go to one of the locations where other backups are kept.
The problem with having an online backup is that such sensitive data must be kept away from untrusted third parties and, so far, there's no third party I would trust with all those passwords. My solution is to distribute the trust. The encrypted file is encrypted again multiple times with very long random passwords. Those passwords are distributed across different services, and the file in another one, so no one service has access to the encrypted file.
This seems like a reasonably secure system (considering the diversity of parties that should agree to attack me/get hacked). However, a couple of days ago, I was introduced to a much simpler and convenient method to "distribute" a secret: Shamir's Secret Sharing.
Shamir's Secret Sharing
Shamir's Secret Sharing was created by Adi Shamir, a cryptographer who is also the co-inventor of the—probably more widely known—RSA algorithm (yes, that S stands for Shamir!). Here, I'll try to briefly explain how it works.
Given a secret
Shamir's method is based on the fact that given
Let's put it into practice. Given a secret
where
If we want to recover the secret from
where
Now, evaluating on
Final notes
Now we have a method to share our secret between multiple parties and being able to retrieve it with only some of them. This method is not too hard to code yourself, however, there are implementations online if you would rather not do that (make sure you are running trusted code!).
- This is not completely true when working with positive integers, but it can be solved by working with finite fields. ↩
-
Let's quickly prove that the
defined in Lagrange's form ( from now on) is the same as the previously defined . is clearly a polynomial of degree (at most) , since it is the sum of polynomials of degree , so we only need to prove that it interpolates the points given (we'll asume that the fact that there is only one polynomial of degree at most that interpolates points is true). That is easy to prove since and , therefore having . ↩