Shamir's secret sharing

Last updated

Shamir's secret sharing (SSS) is an efficient secret sharing algorithm for distributing private information (the "secret") among a group. The secret cannot be revealed unless a quorum of the group acts together to pool their knowledge. To achieve this, the secret is mathematically divided into parts (the "shares") from which the secret can be reassembled only when a sufficient number of shares are combined. SSS has the property of information-theoretic security, meaning that even if an attacker steals some shares, it is impossible for the attacker to reconstruct the secret unless they have stolen the quorum number of shares.

Contents

Shamir's secret sharing is used in some applications to share the access keys to a master secret.

High-level explanation

SSS is used to secure a secret in a distributed form, most often to secure encryption keys. The secret is split into multiple shares, which individually do not give any information about the secret.

To reconstruct a secret secured by SSS, a number of shares is needed, called the threshold. No information about the secret can be gained from any number of shares below the threshold (a property called perfect secrecy). In this sense, SSS is a generalisation of the one-time pad (which can be viewed as SSS with a two-share threshold and two shares in total). [1]

Application example

A company needs to secure their vault. If a single person knows the code to the vault, the code might be lost or unavailable when the vault needs to be opened. If there are several people who know the code, they may not trust each other to always act honestly.

SSS can be used in this situation to generate shares of the vault's code which are distributed to authorized individuals in the company. The minimum threshold and number of shares given to each individual can be selected such that the vault is accessible only by (groups of) authorized individuals. If fewer shares than the threshold are presented, the vault cannot be opened.

By accident, coercion or as an act of opposition, some individuals might present incorrect information for their shares. If the total of correct shares fails to meet the minimum threshold, the vault remains locked.

Use cases

Shamir's secret sharing can be used to

Properties and weaknesses

SSS has useful properties, but also weaknesses [5] that means that it is unsuited to some uses.

Useful properties include:

  1. Secure: The scheme has information-theoretic security.
  2. Minimal: The size of each piece does not exceed the size of the original data.
  3. Extensible: For any given threshold, shares can be dynamically added or deleted without affecting existing shares
  4. Dynamic: Security can be enhanced without changing the secret, but by changing the polynomial occasionally (keeping the same free term) and constructing a new share for each of the participants.
  5. 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:

  1. No verifiable secret sharing : During the share reassembly process, SSS does not provide 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.
  2. Single point of failure: The secret must exist in one 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.

History

Adi Shamir, an Israeli scientist, first formulated the scheme in 1979. [6]

Mathematical principle

The scheme exploits the Lagrange interpolation theorem, specifically that points on the polynomial uniquely determines a polynomial of degree less than or equal to . For instance, 2 points are sufficient to define a line, 3 points are sufficient to define a parabola, 4 points to define a cubic curve and so forth.

Mathematical formulation

Shamir's secret sharing is an ideal and perfect - threshold scheme based on polynomial interpolation over finite fields. In such a scheme, the aim is to divide a secret (for example, the combination to a safe) into pieces of data (known as shares) in such a way that:

  1. Knowledge of any or more shares makes computable. That is, the entire secret can be reconstructed from any combination of shares.
  2. Knowledge of any or fewer shares leaves completely undetermined, in the sense that the possible values for remain as likely with knowledge of up to shares as with knowledge of shares. The secret cannot be reconstructed with fewer than shares.

If , then all of the shares are needed to reconstruct the secret .

One can draw an infinite number of polynomials of degree 2 through 2 points. 3 points are required to uniquely determine a polynomial of degree 2. This image is for illustration purposes only -- Shamir's scheme uses polynomials over a finite field, which are not easy to represent in a 2-dimensional plane. 3 polynomials of degree 2 through 2 points.svg
One can draw an infinite number of polynomials of degree 2 through 2 points. 3 points are required to uniquely determine a polynomial of degree 2. This image is for illustration purposes only — Shamir's scheme uses polynomials over a finite field, which are not easy to represent in a 2-dimensional plane.

Assume that the secret can be represented as an element of a finite field (where is greater than the number of shares being generated). Randomly choose elements, , from and construct the polynomial . Compute any points out on the curve, for instance set to find points . Every participant is given a point (a non-zero input to the polynomial, and the corresponding output). [7] Given any subset of of these pairs, can be obtained using interpolation, with one possible formula for doing so being , where the list of points on the polynomial is given as pairs of the form . Note that is equal to the first coefficient of polynomial .

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 .

In this example, the secret will be split into 6 shares , where any subset of 3 shares is sufficient to reconstruct the secret. numbers are taken at random. Let them be 166 and 94.

This yields coefficients where is the secret

The polynomial to produce secret shares (points) is therefore:

Six points from the polynomial are constructed as:

Each participant in the scheme receives a different point (a pair of and ). Because is used instead of the points start from and not . This is necessary because is the secret.

Reconstruction

In order to reconstruct the secret, any 3 points are sufficient

Consider using the 3 points.

Computing the Lagrange basis polynomials:

Using the formula for polynomial interpolation, is:

Recalling that the secret is the free coefficient, which means that , and the secret has been recovered.

Computationally efficient approach

Using polynomial interpolation to find a coefficient in a source polynomial using Lagrange polynomials is not efficient, since unused constants are calculated.

Considering this, an optimized formula to use Lagrange polynomials to find is defined as follows:

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 with every that she finds.

Suppose that she finds the 2 points and . She still does not have points, so in theory she should not have gained any more information about . But she could combine the information from the 2 points with the public information: . Doing so, Eve could perform the following algebra:

  1. Fill the formula for with and the value of
  2. Fill (1) with the values of 's and
  3. Fill (1) with the values of 's and
  4. Subtract (3)-(2): and rewrite this as .
  5. Now, Eve can replace the result from (4) into (2): which leads her to the information that S is even.

Solution using finite field arithmetic

This is a polynomial curve over a finite field - the order of the polynomial has seemingly little to do with the shape of the graph. Polynomial over a finite field as per SSSS.png
This is a polynomial curve over a finite field – the order of the polynomial has seemingly little to do with the shape of the graph.

The above attack exploits constraints on the values that the polynomial may take by virtue of how it was constructed: the polynomial must have coefficients that are integers, and the polynomial must take an integer as value when evaluated at each of the coordinates used in the scheme. This reduces its possible values at unknown points, including the resultant secret, given fewer than shares.

This problem can be remedied by using finite field arithmetic. A finite field always has size , where is a prime and is a positive integer. The size of the field must satisfy , and that is greater than the number of possible values for the secret, though the latter condition may be circumvented by splitting the secret into smaller secret values, and applying the scheme to each of these. In our example below, we use a prime field (i.e. r = 1). The figure shows a polynomial curve over a finite field.

In practice this is only a small change. The order q of the field (i.e. the number of values that it has) must be chosen to be greater than the number of participants and the number of values that the secret may take. All calculations involving the polynomial must also be calculated over the field (mod p in our example, in which is taken to be a prime) instead of over the integers. Both the choice of the field and the mapping of the secret to a value in this field are considered to be publicly known.

For this example, choose , so the polynomial becomes which gives the points:

This time Eve doesn't gain any information when she finds a (until she has points).

Suppose again that Eve finds and , and the public information is: . Attempting the previous attack, Eve can:

  1. Fill the -formula with and the value of and :
  2. Fill (1) with the values of 's and
  3. Fill (1) with the values of 's and
  4. Subtract (3)-(2): and rewrite this as

There are possible values for . She knows that always decreases by 3, so if were divisible by she could conclude . However, is prime, so she can not conclude this. Thus, using a finite field avoids this possible attack.

Also, even though Eve can conclude that , it does not provide any additional information, since the "wrapping around" behavior of modular arithmetic prevents the leakage of "S is even", unlike the example with integer arithmetic above.

Python code

For purposes of keeping the code clearer, a prime field is used here. In practice, for convenience a scheme constructed using a smaller binary field may be separately applied to small substrings of bits of the secret (e.g. GF(256) for byte-wise application), without loss of security. The strict condition that the size of the field must be larger than the number of shares must still be respected (e.g., if the number of shares could exceed 255, the field GF(256) might be replaced by say GF(65536)).

"""The following Python implementation of Shamir's secret sharing isreleased 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-0See the bottom few lines for usage. Tested on Python 2 and 3."""from__future__importdivisionfrom__future__importprint_functionimportrandomimportfunctools# 12th Mersenne Prime_PRIME=2**127-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=0forcoeffinreversed(poly):accum*=xaccum+=coeffaccum%=primereturnaccumdefmake_random_shares(secret,minimum,shares,prime=_PRIME):"""    Generates a random shamir pool for a given secret, returns share points.    """ifminimum>shares:raiseValueError("Pool secret would be irrecoverable.")poly=[secret]+[_RINT(prime-1)foriinrange(minimum-1)]points=[(i,_eval_at(poly,i,prime))foriinrange(1,shares+1)]returnpointsdef_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=0last_x=1y=1last_y=0whileb!=0:quot=a//ba,b=b,a%bx,last_x=last_x-quot*x,xy,last_y=last_y-quot*y,yreturnlast_x,last_ydef_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)returnnum*invdef_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)assertk==len(set(x_s)),"points must be distinct"defPI(vals):# upper-case PI -- product of inputsaccum=1forvinvals:accum*=vreturnaccumnums=[]# avoid inexact divisiondens=[]foriinrange(k):others=list(x_s)cur=others.pop(i)nums.append(PI(x-oforoinothers))dens.append(PI(cur-oforoinothers))den=PI(dens)num=sum([_divmod(nums[i]*den*y_s[i]%p,dens[i],p)foriinrange(k)])return(_divmod(num,den,p)+p)%pdefrecover_secret(shares,prime=_PRIME):"""    Recover the secret from share points    (points (x,y) on the polynomial).    """iflen(shares)<3:raiseValueError("need at least three shares")x_s,y_s=zip(*shares)return_lagrange_interpolate(0,x_s,y_s,prime)defmain():"""Main function"""secret=1234shares=make_random_shares(secret,minimum=3,shares=6)print('Secret:                                                     ',secret)print('Shares:')ifshares:forshareinshares: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

Related Research Articles

<span class="mw-page-title-main">Chinese remainder theorem</span> Theorem for solving simultaneous congruences

In mathematics, the Chinese remainder theorem states that if one knows the remainders of the Euclidean division of an integer n by several integers, then one can determine uniquely the remainder of the division of n by the product of these integers, under the condition that the divisors are pairwise coprime.

<span class="mw-page-title-main">Factorization</span> (Mathematical) decomposition into a product

In mathematics, factorization (or factorisation, see English spelling differences) or factoring consists of writing a number or another mathematical object as a product of several factors, usually smaller or simpler objects of the same kind. For example, 3 × 5 is an integer factorization of 15, and (x – 2)(x + 2) is a polynomial factorization of x2 – 4.

In mathematics, a generating function is a representation of an infinite sequence of numbers as the coefficients of a formal power series. Unlike an ordinary series, the formal power series is not required to converge: in fact, the generating function is not actually regarded as a function, and the "variable" remains an indeterminate. Generating functions were first introduced by Abraham de Moivre in 1730, in order to solve the general linear recurrence problem. One can generalize to formal power series in more than one indeterminate, to encode information about infinite multi-dimensional arrays of numbers.

<span class="mw-page-title-main">Chebyshev polynomials</span> Polynomial sequence

The Chebyshev polynomials are two sequences of polynomials related to the cosine and sine functions, notated as and . They can be defined in several equivalent ways, one of which starts with trigonometric functions:

In numerical analysis, polynomial interpolation is the interpolation of a given bivariate data set by the polynomial of lowest possible degree that passes through the points of the dataset.

<span class="mw-page-title-main">Trapdoor function</span> One-way cryptographic tool

In theoretical computer science and cryptography, a trapdoor function is a function that is easy to compute in one direction, yet difficult to compute in the opposite direction without special information, called the "trapdoor". Trapdoor functions are a special case of one-way functions and are widely used in public-key cryptography.

<span class="mw-page-title-main">Lagrange polynomial</span> Polynomials used for interpolation

In numerical analysis, the Lagrange interpolating polynomial is the unique polynomial of lowest degree that interpolates a given set of data.

<i>p</i>-adic analysis Branch of number theory

In mathematics, p-adic analysis is a branch of number theory that deals with the mathematical analysis of functions of p-adic numbers.

The NTRUEncrypt public key cryptosystem, also known as the NTRU encryption algorithm, is an NTRU lattice-based alternative to RSA and elliptic curve cryptography (ECC) and is based on the shortest vector problem in a lattice.

The quadratic sieve algorithm (QS) is an integer factorization algorithm and, in practice, the second-fastest method known. It is still the fastest for integers under 100 decimal digits or so, and is considerably simpler than the number field sieve. It is a general-purpose factorization algorithm, meaning that its running time depends solely on the size of the integer to be factored, and not on special structure or properties. It was invented by Carl Pomerance in 1981 as an improvement to Schroeppel's linear sieve.

<span class="mw-page-title-main">Schönhage–Strassen algorithm</span> Multiplication algorithm

The Schönhage–Strassen algorithm is an asymptotically fast multiplication algorithm for large integers, published by Arnold Schönhage and Volker Strassen in 1971. It works by recursively applying fast Fourier transform (FFT) over the integers modulo 2n+1. The run-time bit complexity to multiply two n-digit numbers using the algorithm is in big O notation.

In mathematics, the jet is an operation that takes a differentiable function f and produces a polynomial, the truncated Taylor polynomial of f, at each point of its domain. Although this is the definition of a jet, the theory of jets regards these polynomials as being abstract polynomials rather than polynomial functions.

In mathematics, Hensel's lemma, also known as Hensel's lifting lemma, named after Kurt Hensel, is a result in modular arithmetic, stating that if a univariate polynomial has a simple root modulo a prime number p, then this root can be lifted to a unique root modulo any higher power of p. More generally, if a polynomial factors modulo p into two coprime polynomials, this factorization can be lifted to a factorization modulo any higher power of p.

In additive number theory, Fermat's theorem on sums of two squares states that an odd prime p can be expressed as:

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 well-defined secret that the players can later reconstruct. The concept of verifiable secret sharing (VSS) was first introduced in 1985 by Benny Chor, Shafi Goldwasser, Silvio Micali and Baruch Awerbuch.

In cryptography, the Feige–Fiat–Shamir identification scheme is a type of parallel zero-knowledge proof developed by Uriel Feige, Amos Fiat, and Adi Shamir in 1988. Like all zero-knowledge proofs, it allows one party, the Prover, to prove to another party, the Verifier, that they possess secret information without revealing to Verifier what that secret information is. The Feige–Fiat–Shamir identification scheme, however, uses modular arithmetic and a parallel verification process that limits the number of communications between Prover and Verifier.

The digital root of a natural number in a given radix is the value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-digit number is reached. For example, in base 10, the digital root of the number 12345 is 6 because the sum of the digits in the number is 1 + 2 + 3 + 4 + 5 = 15, then the addition process is repeated again for the resulting number 15, so that the sum of 1 + 5 equals 6, which is the digital root of that number. In base 10, this is equivalent to taking the remainder upon division by 9, which allows it to be used as a divisibility rule.

In mathematics, the discrete Fourier transform over a ring generalizes the discrete Fourier transform (DFT), of a function whose values are commonly complex numbers, over an arbitrary ring.

In mathematics, elliptic curve primality testing techniques, or elliptic curve primality proving (ECPP), are among the quickest and most widely used methods in primality proving. It is an idea put forward by Shafi Goldwasser and Joe Kilian in 1986 and turned into an algorithm by A. O. L. Atkin the same year. The algorithm was altered and improved by several collaborators subsequently, and notably by Atkin and François Morain, in 1993. The concept of using elliptic curves in factorization had been developed by H. W. Lenstra in 1985, and the implications for its use in primality testing followed quickly.

In mathematics and computer algebra the factorization of a polynomial consists of decomposing it into a product of irreducible factors. This decomposition is theoretically possible and is unique for polynomials with coefficients in any field, but rather strong restrictions on the field of the coefficients are needed to allow the computation of the factorization by means of an algorithm. In practice, algorithms have been designed only for polynomials with coefficients in a finite field, in the field of rationals or in a finitely generated field extension of one of them.

References

  1. Krenn, Stephan; Loruenser, Thomas (2023). An Introduction to Secret Sharing: A Systematic Overview and Guide for Protocol Selection. doi:10.1007/978-3-031-28161-7. ISBN   978-3-031-28160-0.
  2. "Seal/Unseal". Vault by HashiCorp . Retrieved 2022-10-02.
  3. "PreVeil Review". PCMag . Retrieved 2022-10-02.
  4. Rusnak, Pavol; Kozlik, Andrew; Vejpustek, Ondrej; Susanka, Tomas; Palatinus, Marek; Hoenicke, Jochen (2017-12-18). "SLIP-0039 : Shamir's Secret-Sharing for Mnemonic Codes". GitHub . SatoshiLabs. Retrieved 2022-10-03. This SLIP describes a standard and interoperable implementation of Shamirs secret-sharing (SSS) and a specification for its use in backing up Hierarchical Deterministic Wallets described in BIP-0032.
  5. Lopp, Jameson (2020-10-01). "Shamir's Secret Sharing shortcomings" . Retrieved 2022-10-03. Variations of Shamir's Secret Sharing (SSS) have been implemented several times in the cryptocurrency space, only for developers to later realize that the additional complexity ended up reducing the security of the system.
  6. Shamir, Adi (1979), "How to share a secret", Communications of the ACM, 22 (11): 612–613, doi: 10.1145/359168.359176 , S2CID   16321225
  7. Knuth, D. E. (1997), The Art of Computer Programming , vol. II: Seminumerical Algorithms (3rd ed.), Addison-Wesley, p. 505.

Further reading