Shamir's Secret Sharing Scheme

Consider a scenario where you need to secure a bank vault. It is considered absolutely impregnable without a key, which is given to you on the first day of work. Your goal is to securely store the key.

Suppose you decide to keep the key with you at all times, providing access to the vault as needed. But you will quickly realize that such a solution does not scale well in practice, because every time you need to be physically present to open the vault. What about the vacation you were promised? In addition, the question is even more frightening: what if you lost the only key?

With the idea of ​​a vacation, you decide to make a copy of the key and entrust it to another employee. However, you understand that this is also not ideal. By doubling the number of keys, you have also doubled the chances of key theft.

Desperate, you destroy the duplicate and decide to split the original key in half. Now, you think two trusted people with key fragments must be physically present to collect the key and open the vault. This means that the thief needs to steal two fragments, which is twice as difficult as stealing one key. However, you soon realize that this scheme is not much better than just one key, because if someone loses half of the key, the full key cannot be recovered.

The problem can be solved with a series of additional keys and locks, but this approach will quickly require lot keys and locks. You decide that the ideal scheme is to share the key so that security doesn't rely entirely on one person. You also conclude that there must be some threshold for the number of fragments so that if one fragment is lost (or if the person goes on vacation), the entire key remains functional.

How to share a secret

This type of key management scheme was thought of by Adi Shamir in 1979 when he published his work "How to Share a Secret". The article briefly explains the so-called Shamir's Secret Sharing Scheme thresholding scheme for effectively dividing a secret value (for example, a cryptographic key) into Shamir's Secret Sharing Scheme parts. Then, when and only when at least Shamir's Secret Sharing Scheme in the Shamir's Secret Sharing Scheme parts are assembled, you can easily restore the secret Shamir's Secret Sharing Scheme.

From a security point of view, an important property of this scheme is that an attacker should learn absolutely nothing if he does not have at least Shamir's Secret Sharing Scheme parts. Even the presence Shamir's Secret Sharing Scheme parts should not give any information. We call this property semantic security.

Polynomial Interpolation

Threshold Shamir scheme Shamir's Secret Sharing Scheme built around the concept polynomial interpolation. If you're not familiar with this concept, it's actually quite simple. In general, if you have ever drawn points on a chart and then connected them with lines or curves, you have already used it!

Shamir's Secret Sharing Scheme
Through two points, you can draw an unlimited number of polynomials of degree 2. To choose the only one from them, you need a third point. Illustration: Wikipedia

Consider a polynomial with degree one, Shamir's Secret Sharing Scheme. If you want to plot this function on a graph, how many points do you need? Well, we know that this is a linear function that forms a line and therefore we need at least two points. Next, consider a polynomial function with degree two, Shamir's Secret Sharing Scheme. This is a quadratic function, so at least three points are required to plot the graph. How about a polynomial with degree three? At least four dots. And so on and so forth.

The really cool thing about this property is that, given the degree of the polynomial function and at least Shamir's Secret Sharing Scheme points, we can derive additional points for this polynomial function. We call the extrapolation of these additional points polynomial interpolation.

Making a secret

You may have already figured out that this is where Shamir's clever scheme comes into play. Suppose our secret Shamir's Secret Sharing Scheme - Is Shamir's Secret Sharing Scheme. We can turn Shamir's Secret Sharing Scheme to the point on the graph Shamir's Secret Sharing Scheme and come up with a polynomial function with a degree Shamir's Secret Sharing Scheme, which satisfies this point. Recall that Shamir's Secret Sharing Scheme will be our threshold of required fragments, so if we set the threshold to three fragments, we must choose a polynomial function with a degree of two.

Our polynomial will have the form Shamir's Secret Sharing SchemeWhere Shamir's Secret Sharing Scheme и Shamir's Secret Sharing Scheme are randomly chosen positive integers. We just build a polynomial with a degree Shamir's Secret Sharing Scheme, where the free coefficient Shamir's Secret Sharing Scheme - This is our secret Shamir's Secret Sharing Scheme, and each of the subsequent Shamir's Secret Sharing Scheme terms is a randomly chosen positive coefficient. If we return to the original example and assume that Shamir's Secret Sharing Scheme, then we get the function Shamir's Secret Sharing Scheme.

At this point, we can generate fragments by connecting Shamir's Secret Sharing Scheme unique integers in Shamir's Secret Sharing SchemeWhere Shamir's Secret Sharing Scheme (because it's our secret). In this example, we want to distribute four fragments with a threshold of three, so we randomly generate points Shamir's Secret Sharing Scheme and send one point to each of the four trusted people, the keepers of the key. We also tell people that Shamir's Secret Sharing Scheme, as it is considered public information and is necessary for recovery Shamir's Secret Sharing Scheme.

Secret Recovery

We have already discussed the concept of polynomial interpolation and how it underlies Shamir's thresholding scheme. Shamir's Secret Sharing Scheme. When any three out of four trustees want to restore Shamir's Secret Sharing Scheme, they only need to interpolate Shamir's Secret Sharing Scheme with their unique points. To do this, they can define their points Shamir's Secret Sharing Scheme and calculate the Lagrange interpolation polynomial using the following formula. If programming is clearer to you than mathematics, then pi is essentially an operator for, which multiplies all results, and sigma is forthat adds up everything.

Shamir's Secret Sharing Scheme

Shamir's Secret Sharing Scheme

For Shamir's Secret Sharing Scheme we can solve it like this and return our original polynomial function:

Shamir's Secret Sharing Scheme

Since we know that Shamir's Secret Sharing Scheme, recovery Shamir's Secret Sharing Scheme is done simply:

Shamir's Secret Sharing Scheme

Using unsafe integer arithmetic

Although we have successfully applied the basic idea of ​​Shamir Shamir's Secret Sharing Scheme, we are left with a problem that we have ignored until now. Our polynomial function uses unsafe integer arithmetic. Note that for every additional point an attacker gets on our function graph, there are fewer possibilities for other points. You can see this with your own eyes when you plot an increasing number of points for a polynomial function using integer arithmetic. This is counterproductive to our stated security goal, because an attacker should know absolutely nothing until they have at least Shamir's Secret Sharing Scheme fragments.

To demonstrate how weak the integer arithmetic scheme is, consider a scenario in which the attacker received two points Shamir's Secret Sharing Scheme and knows public information that Shamir's Secret Sharing Scheme. From this information, he can infer Shamir's Secret Sharing Scheme, equal to two, and connect the known values ​​\uXNUMXb\uXNUMXbto the formula Shamir's Secret Sharing Scheme и Shamir's Secret Sharing Scheme.

Shamir's Secret Sharing Scheme

The attacker can then find Shamir's Secret Sharing Scheme, counting Shamir's Secret Sharing Scheme:

Shamir's Secret Sharing Scheme

Since we have defined Shamir's Secret Sharing Scheme as randomly chosen positive integers, there is a limited number of possible Shamir's Secret Sharing Scheme. With this information, an attacker can deduce Shamir's Secret Sharing Scheme, because anything greater than 5 will make Shamir's Secret Sharing Scheme negative. This turns out to be true, since we have determined Shamir's Secret Sharing Scheme

The attacker can then calculate the possible values Shamir's Secret Sharing Schemereplacing Shamir's Secret Sharing Scheme в Shamir's Secret Sharing Scheme:

Shamir's Secret Sharing Scheme

With limited options for Shamir's Secret Sharing Scheme it becomes clear how easy it is to pick up and check values Shamir's Secret Sharing Scheme. There are only five options here.

Solving the problem with unsafe integer arithmetic

To fix this vulnerability, Shamir suggests using modular arithmetic by replacing Shamir's Secret Sharing Scheme + Shamir's Secret Sharing SchemeWhere Shamir's Secret Sharing Scheme и Shamir's Secret Sharing Scheme is the set of all prime numbers.

Let's quickly recall how modular arithmetic works. Hand clocks are a familiar concept. She uses a watch that is Shamir's Secret Sharing Scheme. As soon as the hour hand passes twelve, it returns to one. An interesting property of this system is that just by looking at the clock, we cannot deduce how many revolutions the hour hand has made. However, if we know that the hour hand has passed 12 four times, we can fully determine the number of hours that have elapsed with a simple formula Shamir's Secret Sharing SchemeWhere Shamir's Secret Sharing Scheme is our divisor (here Shamir's Secret Sharing Scheme), Shamir's Secret Sharing Scheme - this is the coefficient (how many times the divisor without a remainder goes into the original number, here Shamir's Secret Sharing Scheme), and Shamir's Secret Sharing Scheme is the remainder, which usually returns a call to the modulo operator (here Shamir's Secret Sharing Scheme). Knowing all these values ​​allows us to solve the equation for Shamir's Secret Sharing Scheme, but if we skip the coefficient, we will never be able to restore the original value.

We can demonstrate how this improves the security of our circuit by applying the circuit to our previous example and using Shamir's Secret Sharing Scheme. Our new polynomial function Shamir's Secret Sharing Scheme, and the new points Shamir's Secret Sharing Scheme. Now the key keepers can once again use polynomial interpolation to reconstruct our function, only this time the addition and multiplication operations must be followed by modulo reduction. Shamir's Secret Sharing Scheme (eg Shamir's Secret Sharing Scheme).

Using this new example, suppose the attacker has learned two of these new points, Shamir's Secret Sharing Scheme, and public information Shamir's Secret Sharing Scheme. This time, the attacker, based on all the information he has, displays the following functions, where Shamir's Secret Sharing Scheme is the set of all positive integers, and Shamir's Secret Sharing Scheme represents the modulus coefficient Shamir's Secret Sharing Scheme.

Shamir's Secret Sharing Scheme

Now our intruder finds again Shamir's Secret Sharing Scheme, calculating Shamir's Secret Sharing Scheme:

Shamir's Secret Sharing Scheme

Then he tries again to withdraw Shamir's Secret Sharing Schemereplacing Shamir's Secret Sharing Scheme в Shamir's Secret Sharing Scheme:

Shamir's Secret Sharing Scheme

This time he has a serious problem. Formula missing values Shamir's Secret Sharing Scheme, Shamir's Secret Sharing Scheme и Shamir's Secret Sharing Scheme. Since there are an infinite number of combinations of these variables, he cannot obtain any additional information.

Security Considerations

Shamir's secret sharing scheme suggests information security. This means that the math is strong even against an attacker with unlimited computing power. However, the schema still contains several known issues.

For example, the Shamir scheme does not create fragments to be checked, that is, people are free to present fake fragments and interfere with the recovery of the correct secret. A hostile fragment keeper with enough information can even produce another fragment by changing Shamir's Secret Sharing Scheme at your discretion. This problem is solved with verifiable secret sharing schemes, such as the Feldman scheme.

Another problem is that the length of any fragment is equal to the length of the corresponding secret, so the length of the secret is easy to determine. This problem is solved by the trivial padding secret by arbitrary numbers up to a fixed length.

Finally, it's important to note that our security concerns may go beyond the scheme itself. For real cryptographic applications, there is often a threat of side-channel attacks, when an attacker tries to extract useful information from the application's execution time, caching, crashes, etc. If this is a concern, you should carefully consider the use of safeguards during development, such as functions and constant-time lookups, prevent saving memory to disk, and consider a number of other things that are beyond the scope of this article.

Demo

For this page there is an interactive demonstration of Shamir's secret sharing scheme. The demonstration was made on the basis of the library ssss-js, which itself is a JavaScript port of a popular program ssss. Note that calculating large values Shamir's Secret Sharing Scheme, Shamir's Secret Sharing Scheme и Shamir's Secret Sharing Scheme may take some time.

Source: habr.com

Buy reliable hosting for sites with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster