HOME

TheInfoList



OR:

Shamir's Secret Sharing (SSS) is an efficient secret sharing algorithm for distributing
private information Privacy (, ) is the ability of an individual or group to seclude themselves or information about themselves, and thereby express themselves selectively. The domain of privacy partially overlaps with security, which can include the concepts of a ...
(the "secret") in such a way that no individual holds intelligible information about the secret. To achieve this, the secret is converted into parts (the "shares") from which the secret can be reassembled when a sufficient number of shares are combined but not otherwise. SSS has the unusual property of information theoretic security, meaning an adversary without enough shares cannot reconstruct the secret even with infinite time and computing capacity. A standard SSS specification for cryptocurrency wallets has been widely implemented.


High-level explanation

SSS is used to secure a secret in a distributed way, most often to secure other encryption keys. The secret is split into multiple shares, which individually do not give any information about the secret. To unlock a secret secured by SSS a minimum number of shares are needed, called the ''threshold''. No additional information about the secret can be gained by examining any number of shares fewer than the threshold (a property called
perfect secrecy A cryptosystem is considered to have information-theoretic security (also called unconditional security) if the system is secure against adversaries with unlimited computing resources and time. In contrast, a system which depends on the computatio ...
)''.'' In this sense, SSS is a generalisation of the
one-time pad In cryptography, the one-time pad (OTP) is an encryption technique that cannot be cracked, but requires the use of a single-use pre-shared key that is not smaller than the message being sent. In this technique, a plaintext is paired with a r ...
(which can be viewed as SSS with a two-share threshold and two shares in total).


Application example

A company needs to secure their vault's code. A single person knowing the code could act dishonestly or be unavailable when the vaults needs to be opened. SSS can be used in this situation to generate shares from the vault's code which are distributed to executives in the Company. The selected threshold and number of shares given to each executive can be selected such that the vault is accessible only by (groups of) authorized individuals. If less than the threshold of shares were compromised, these shares alone would not be enough to determine the code.


Properties and weaknesses

SSS has useful properties, but also weaknesses that mean there are some situations where it should not be used. Useful properties include: # Secure: The scheme has Information theoretic security. # Minimal: The size of each piece does not exceed the size of the original data. # Extensible: For any given threshold, shares can be dynamically added or deleted without affecting existing shares # Dynamic: Security can be easily enhanced without changing the secret, but by changing the polynomial occasionally (keeping the same free term) and constructing new shares for the participants. # Flexible: In organizations where hierarchy is important, each participant can be issued different numbers of shares according to their importance inside the organization. For instance, with a ''threshold'' of 3, the president could unlock the safe alone if given three shares, while three secretaries with one share each must combine their shares to unlock the safe. Weaknesses include: # No
verifiable secret sharing In cryptography, a secret sharing scheme is verifiable if auxiliary information is included that allows players to verify their shares as consistent. More formally, verifiable secret sharing ensures that even if the dealer is malicious there is a ...
: During the share reassembly process, SSS does not have a way to verify the correctness of each share being used. Verifiable secret sharing aims to verify that shareholders are honest and not submitting fake shares. # Single point of failure: The secret must exist in one single place when it is split into shares, and again in one place when it is reassembled. These are attack points, and other schemes including multisignature eliminate at least one of these
single points of failure A single point of failure (SPOF) is a part of a system that, if it fails, will stop the entire system from working. SPOFs are undesirable in any system with a goal of high availability or reliability, be it a business practice, software ap ...
.


History

Adi Shamir Adi Shamir ( he, עדי שמיר; born July 6, 1952) is an Israeli cryptographer. He is a co-inventor of the Rivest–Shamir–Adleman (RSA) algorithm (along with Ron Rivest and Len Adleman), a co-inventor of the Feige–Fiat–Shamir identifica ...
first formulated the scheme in 1979.


Mathematical principle

The essential idea of the scheme is based on the Lagrange interpolation theorem, specifically that k\,\! points is enough to uniquely determine a
polynomial In mathematics, a polynomial is an expression consisting of indeterminates (also called variables) and coefficients, that involves only the operations of addition, subtraction, multiplication, and positive-integer powers of variables. An ex ...
of
degree Degree may refer to: As a unit of measurement * Degree (angle), a unit of angle measurement ** Degree of geographical latitude ** Degree of geographical longitude * Degree symbol (°), a notation used in science, engineering, and mathemati ...
less than or equal to k-1\,\!. For instance, 2 points are sufficient to define a
line Line most often refers to: * Line (geometry), object with zero thickness and curvature that stretches to infinity * Telephone line, a single-user circuit on a telephone communication system Line, lines, The Line, or LINE may also refer to: Art ...
, 3 points are sufficient to define a
parabola In mathematics, a parabola is a plane curve which is mirror-symmetrical and is approximately U-shaped. It fits several superficially different mathematical descriptions, which can all be proved to define exactly the same curves. One descri ...
, 4 points to define a cubic curve and so forth.


Mathematical formulation

Shamir's Secret Sharing is an ideal and perfect ''\left(k,n\right)-
threshold scheme Secret sharing (also called secret splitting) refers to methods for distributing a secret among a group, in such a way that no individual holds any intelligible information about the secret, but when a sufficient number of individuals combine th ...
'' based on
polynomial interpolation In numerical analysis, polynomial interpolation is the interpolation of a given data set by the polynomial of lowest possible degree that passes through the points of the dataset. Given a set of data points (x_0,y_0), \ldots, (x_n,y_n), with n ...
over
finite fields In mathematics, a finite field or Galois field (so-named in honor of Évariste Galois) is a field that contains a finite number of elements. As with any field, a finite field is a set on which the operations of multiplication, addition, subt ...
. In such a scheme, the aim is to divide a secret S (for example, the combination to a
safe A safe (also called a strongbox or coffer) is a secure Lock (security device), lockable box used for securing valuable objects against theft or fire. A safe is usually a hollow cuboid or cylinder, with one face being removable or hinged to form ...
) into n pieces of data S_1,\ldots,S_n (known as ''shares'') in such a way that: # Knowledge of any k or more shares S_i makes S easily computable. That is, the complete secret S can be reconstructed from any combination of k shares of data. # Knowledge of any k-1 or fewer shares S_i leaves S completely undetermined, in the sense that the possible values for S seem as likely with knowledge of up to k-1 shares as with knowledge of 0 shares. The secret S cannot be reconstructed with fewer than k shares. If n=k, then every piece of the original secret S is required to reconstruct the secret. Assume that the secret S can be represented as an element a_0 of a
finite field In mathematics, a finite field or Galois field (so-named in honor of Évariste Galois) is a field that contains a finite number of elements. As with any field, a finite field is a set on which the operations of multiplication, addition, subt ...
GF(q) (where q is larger than the number of shares being generated). Randomly choose k-1 elements, a_1,\cdots,a_\,\!, from GF(q) and construct the polynomial f\left(x\right)=a_0+a_1x+a_2x^2+a_3x^3+\cdots+a_x^\,\!. Compute any n\,\! points out on the curve, for instance set i=1,\ldots,n\,\! to find points \left(i,f\left(i\right)\right)\,\!. Every participant is given a point (a non-zero input to the polynomial, and the corresponding output). Given any subset of k\,\! of these pairs, a_0 can be obtained using
interpolation In the mathematical field of numerical analysis, interpolation is a type of estimation, a method of constructing (finding) new data points based on the range of a discrete set of known data points. In engineering and science, one often has ...
, with one possible formula for doing so being a_0 = f(0) = \sum_^ y_j \prod_^ \frac , where the list of points on the polynomial is given as k pairs of the form (x_i, y_i). Note that f(0) is equal to the first coefficient of polynomial f(x) .


Example calculation

The following example illustrates the basic idea. Note, however, that calculations in the example are done using integer arithmetic rather than using finite field arithmetic to make the idea easier to understand. Therefore the example below does not provide perfect secrecy and is not a proper example of Shamir's scheme. The next example will explain the problem.


Preparation

Suppose that the secret to be shared is 1234 (S=1234)\,\!. In this example, the secret will be split into 6 shares (n=6)\,\!, where any subset of 3 shares (k=3)\,\! is sufficient to reconstruct the secret. k-1=2 numbers are taken at random. Let them be 166 and 94. : This yields coefficients (a_0=1234;a_1=166;a_2=94),\,\! where a_0 is the secret The polynomial to produce secret shares (points) is therefore: : f(x)=1234+166x+94x^2\,\! Six points D_=(x, f(x)) from the polynomial are constructed as: : D_0=(1, 1494);D_1=(2, 1942);D_2=(3, 2578);D_3=(4, 3402); D_4= (5, 4414);D_5=(6, 5614)\,\! Each participant in the scheme receives a different point (a pair of x\,\! and f(x)\,\!). Because D_ is used instead of D_x the points start from (1, f(1)) and not (0, f(0)). This is necessary because f(0) is the secret.


Reconstruction

In order to reconstruct the secret, any 3 points are sufficient Consider using the 3 points\left(x_0,y_0\right)=\left(2,1942\right);\left(x_1,y_1\right)=\left(4,3402\right);\left(x_2,y_2\right)=\left(5,4414\right)\,\!. Computing the Lagrange basis polynomials: : \ell_0(x)=\frac\cdot\frac=\frac\cdot\frac=\fracx^2-\fracx+\frac\,\! : \ell_1(x)=\frac\cdot\frac=\frac\cdot\frac=-\fracx^2+\fracx-5\,\! : \ell_2(x)=\frac\cdot\frac=\frac\cdot\frac=\fracx^2-2x+\frac\,\! Using the formula for polynomial interpolation, f(x) is: : \begin f(x) & =\sum_^2 y_j\cdot\ell_j(x) \\ pt& =y_0\ell_0(x)+y_1\ell_1(x)+y_2\ell_2(x) \\ pt& =1942\left(\fracx^2-\fracx+\frac\right) + 3402\left(-\fracx^2+\fracx-5\right) + 4414\left(\fracx^2-2x+\frac\right) \\ pt& =1234+166x+94x^2 \end Recalling that the secret is the free coefficient, which means that S=1234\,\!, and the secret has been recovered.


Computationally efficient approach

Using polynomial interpolation to find a coefficient in a source polynomial S=f(0) using
Lagrange polynomials In numerical analysis, the Lagrange interpolating polynomial is the unique polynomial of lowest degree that interpolates a given set of data. Given a data set of coordinate pairs (x_j, y_j) with 0 \leq j \leq k, the x_j are called ''nodes'' an ...
is not efficient, since unused constants are calculated. Considering this, an optimized formula to use Lagrange polynomials to find f(0) is defined as follows: : f(0) = \sum_^ y_j \prod_^ \frac


Problem of using integer arithmetic

Although the simplified version of the method demonstrated above, which uses integer arithmetic rather than finite field arithmetic, works, there is a security problem: Eve gains information about S with every D_i that she finds. Suppose that she finds the 2 points D_0=(1,1494) and D_1=(2,1942). She still does not have k=3 points, so in theory she should not have gained any more information about S. But she could combine the information from the 2 points with the public information: n=6, k=3, f(x)=a_0+a_1x+\cdots+a_x^, a_0=S, a_i\in\mathbb. Doing so, Eve could perform the following algebra: # Fill the formula for f(x) with S and the value of k: f(x)=S+a_1x+\cdots+a_x^\Rightarrowf(x)=S+a_1x+a_2x^2 # Fill (1) with the values of D_0's x and f(x): 1494=S+a_1+a_1^2\Rightarrow1494=S+a_1+a_2 # Fill (1) with the values of D_1's x and f(x): 1942=S+a_2+a_2^2\Rightarrow1942=S+2a_1+4a_2 # Subtract (3)-(2): (1942-1494)=(S-S)+(2a_1-a_1)+(4a_2-a_2)\Rightarrow448=a_1+3a_2 and rewrite this as a_1=448-3a_2. Eve knows that a_2\in\mathbb so she starts replacing a_2 in (4) with 0, 1, 2, 3, ... to find all possible values for a_1: ## a_2=0\rightarrowa_1=448-3\times0=448 ##a_2=1\rightarrowa_1=448-3\times1=445 ##a_2=2\rightarrowa_1=448-3\times2=442 ##\,\,\,\,\,\,\,\,\,\vdots ##a_2=148\rightarrowa_1=448-3\times148=4 ##a_2=149\rightarrowa_1=448-3\times149=1 #After checking a_2=149, she stops because would get negative values for a_1 with larger values of a_2 (which is impossible because a_1\in\mathbb). Eve can now conclude a_2\in ,1,\dots,148,149/math> #Now, Eve can replace a_1 by (4) in (2): 1494=S+(448-3a_2)+a_2\RightarrowS=1046+2a_2. Now, replacing a_2 in (6) by the values found in (5), she gets S\in 046+2\times0,1046+2\times1,\dots,1046+2\times148,1046+2\times149/math> which leads her to the information: S\in 046,1048,\dots,1342,1344 Eve now only has 150 numbers to guess from instead of an infinite quantity of natural numbers.


Solution using finite field arithmetic

Geometrically this attack exploits the fact that the order of the polynomial is known and thus gives information into the paths the polynomial take between known points. This reduces possible values of unknown points since the points must lie on a
smooth curve In mathematics, a curve (also called a curved line in older texts) is an object similar to a line, but that does not have to be straight. Intuitively, a curve may be thought of as the trace left by a moving point. This is the definition that ...
, and the polynomial must have coefficients that are natural numbers. This problem can be fixed by using finite field arithmetic. A field of size p\in\mathbb:p>S,p>n is used. The figure shows a polynomial curve over a finite field. In contrast to a smooth curve it appears disorganised and disjointed. In practice this is only a small change. A prime p must be chosen that is bigger than the number of participants and every a_i (including a_0=S). The points on the polynomial must also be calculated as (x, f(x)\bmod p) instead of (x, f(x)). Everybody who receives a point must also know the value of p, so it is considered to be publicly known. Therefore, one should select a value for p that is not too low to prevent attacks where somebody guesses every possible value for S. For this example, choose p=1613, so the polynomial becomes f(x)=1234+166x+94x^2\bmod which gives the points: (1,1494);(2,329);(3,965);(4,176);(5,1188);(6,775) This time Eve doesn't gain any information when she finds a D_x (until she has k points). Suppose again that Eve finds D_0=\left(1,1494\right) and D_1=\left(2,329\right), and the public information is: n=6, k=3, p=1613, f(x)=a_0+a_1x+\dots+a_x^\mod, a_0=S, a_i\in\mathbb. Attempting the previous attack, Eve can: # Fill the f(x)-formula with S and the value of k and p: f(x)=S+a_1x+\dots+a_x^\mod1613\Rightarrowf(x)=S+a_1x+a_2x^2-1613m_x: m_x\in\mathbb # Fill (1) with the values of D_0's x and f(x): 1494=S+a_1 1+a_2 1^2-1613m_1\Rightarrow 1494=S+a_1+a_2-1613m_1 # Fill (1) with the values of D_1's x and f(x): 1942=S+a_2+a_2^2-1613m_2\Rightarrow1942=S+2a_1+4a_2-1613m_2 # Subtracts (3)-(2): (1942-1494)=(S-S)+(2a_1-a_1)+(4a_2-a_2)+(1613m_1-1613m_2)\Rightarrow448=a_1+3a_2+1613(m_1-m_2) and rewrites this as a_1=448-3a_2-1613(m_1-m_2) # Using a_2\in\mathbb so she starts replacing a_2 in (4) with 0, 1, 2, 3, ... to find all possible values for a_1: ## a_2=0\rightarrowa_1=448-3\times0-1613(m_1-m_2)=448-1613(m_1-m_2) ## a_2=1\rightarrowa_1=448-3\times1-1613(m_1-m_2)=445-1613(m_1-m_2) ##a_2=2\rightarrowa_1=448-3\times2-1613(m_1-m_2)=442-1613(m_1-m_2) ##\,\,\,\,\,\,\,\,\,\vdots This time she is not able to stop because (m_1-m_2) could be any integer modulo p (even negative if m_2>m_1) so there are p possible values for a_1. She knows that 48,445,442,\ldots/math> always decreases by 3, so if 1613 was divisible by 3 she could conclude a_1\in , 4, 7, \ldots/math>. However, p is prime she can not conclude this. Thus, using a finite field avoids this possible attack.


Usage examples

Shamir's Secret Sharing is used in: * Vault
password manager A password manager is a computer program that allows users to store and manage their passwords for local applications and online services. In many cases software used to manage passwords allow also generate strong passwords and fill forms. Pas ...
by Hashicorp * Passwordless authentication by Secret Double Octopus * Key Recovery in PreVeil's
email encryption Email encryption is encryption of email messages to protect the content from being read by entities other than the intended recipients. Email encryption may also include authentication. Email is prone to the disclosure of information. Most emails a ...
* Wallet management of
cryptocurrencies A cryptocurrency, crypto-currency, or crypto is a digital currency designed to work as a medium of exchange through a computer network that is not reliant on any central authority, such as a government or bank, to uphold or maintain it. It ...


Python code

""" The following Python implementation of Shamir's Secret Sharing is released into the Public Domain under the terms of CC0 and OWFa: https://creativecommons.org/publicdomain/zero/1.0/ http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0 See the bottom few lines for usage. Tested on Python 2 and 3. """ from __future__ import division from __future__ import print_function import random import functools # 12th Mersenne Prime # (for this application we want a known prime number as close as # possible to our security level; e.g. desired security level of 128 # bits -- too large and all the ciphertext is large; too small and # security is compromised) _PRIME = 2 ** 127 - 1 # The 13th Mersenne Prime is 2**521 - 1 _RINT = functools.partial(random.SystemRandom().randint, 0) def _eval_at(poly, x, prime): """Evaluates polynomial (coefficient tuple) at x, used to generate a shamir pool in make_random_shares below. """ accum = 0 for coeff in reversed(poly): accum *= x accum += coeff accum %= prime return accum def make_random_shares(secret, minimum, shares, prime=_PRIME): """ Generates a random shamir pool for a given secret, returns share points. """ if minimum > shares: raise ValueError("Pool secret would be irrecoverable.") poly = ecret+ RINT(prime - 1) for i in range(minimum - 1) points = i, _eval_at(poly, i, prime)) for i in range(1, shares + 1) return points def _extended_gcd(a, b): """ Division in integers modulus p means finding the inverse of the denominator modulo p and then multiplying the numerator by this inverse (Note: inverse of A is B such that A*B % p

1). This can be computed via the extended Euclidean algorithm http://en.wikipedia.org/wiki/Modular_multiplicative_inverse#Computation """ x = 0 last_x = 1 y = 1 last_y = 0 while b != 0: quot = a // b a, b = b, a % b x, last_x = last_x - quot * x, x y, last_y = last_y - quot * y, y return last_x, last_y def _divmod(num, den, p): """Compute num / den modulo prime p To explain this, the result will be such that: den * _divmod(num, den, p) % p

num """ inv, _ = _extended_gcd(den, p) return num * inv def _lagrange_interpolate(x, x_s, y_s, p): """ Find the y-value for the given x, given n (x, y) points; k points will define a polynomial of up to kth order. """ k = len(x_s) assert k

len(set(x_s)), "points must be distinct" def PI(vals): # upper-case PI -- product of inputs accum = 1 for v in vals: accum *= v return accum nums = [] # avoid inexact division dens = [] for i in range(k): others = list(x_s) cur = others.pop(i) nums.append(PI(x - o for o in others)) dens.append(PI(cur - o for o in others)) den = PI(dens) num = sum( divmod(nums[i* den * y_s[i">.html" ;"title="divmod(nums[i">divmod(nums[i* den * y_s[i% p, dens[i], p) for i in range(k)]) return (_divmod(num, den, p) + p) % p def recover_secret(shares, prime=_PRIME): """ Recover the secret from share points (points (x,y) on the polynomial). """ if len(shares) < 3: raise ValueError("need at least three shares") x_s, y_s = zip(*shares) return _lagrange_interpolate(0, x_s, y_s, prime) def main(): """Main function""" secret = 1234 shares = make_random_shares(secret, minimum=3, shares=6) print('Secret: ', secret) print('Shares:') if shares: for share in shares: print(' ', share) print('Secret recovered from minimum subset of shares: ', recover_secret(shares 3) print('Secret recovered from a different minimum subset of shares: ', recover_secret(shares 3:) if __name__

'__main__': main()


See also

* Secret sharing * Secure multi-party computation *
Lagrange polynomial In numerical analysis, the Lagrange interpolating polynomial is the unique polynomial of lowest degree that interpolates a given set of data. Given a data set of coordinate pairs (x_j, y_j) with 0 \leq j \leq k, the x_j are called ''nodes'' an ...
*
Homomorphic secret sharing In cryptography, homomorphic secret sharing is a type of secret sharing algorithm in which the secret is encrypted via homomorphic encryption. A homomorphism is a transformation from one algebraic structure into another of the same type so that th ...
– A simplistic decentralized voting protocol. * Two-man rule * Partial Password


References


Further reading

*. *{{citation, last=Benzekki, first=K., title= A Verifiable Secret Sharing Approach for Secure MultiCloud Storage, publisher=Springer, journal=In Ubiquitous Networking, series=Lecture Notes in Computer Science, location=Casablanca, volume=10542, year=2017, pages=225–234, doi=10.1007/978-3-319-68179-5_20, isbn=978-3-319-68178-8.


External links


Shamir's Secret Sharing
in the
Crypto++ Crypto++ (also known as CryptoPP, libcrypto++, and libcryptopp) is a free and open-source C++ class library of cryptographic algorithms and schemes written by Wei Dai. Crypto++ has been widely used in academia, student projects, open-source, and ...
library
Shamir's Secret Sharing Scheme (ssss)
– a
GNU GPL The GNU General Public License (GNU GPL or simply GPL) is a series of widely used free software licenses that guarantee end users the four freedoms to run, study, share, and modify the software. The license was the first copyleft for general ...
implementation
sharedsecret
– implementation in Go
s4
- online shamir's secret sharing tool utilizing HashiCorp's shamir secret sharing algorithm Secret sharing Information-theoretically secure algorithms Articles with example JavaScript code Articles with example Python (programming language) code