On this page
In November 1979 Adi Shamir published a two-page paper, How to share a secret, in Communications of the ACM. It opens with a puzzle from C. L. Liu's combinatorics textbook: eleven scientists want a cabinet that opens only when six or more of them are present. Shamir notes that the minimal solution with real locks uses 462 locks and 252 keys per scientist. His answer replaces the locks with a polynomial, and it is small enough to work by hand.
What is Shamir secret sharing?
A (k, n) threshold scheme splits a secret D into n pieces so that any k pieces make D easy to compute, while any k − 1 pieces leave all possible values of D equally likely, as defined in Shamir's paper. The same paper notes that G. R. Blakley had recently developed a different, somewhat less efficient threshold scheme.
The trick rests on a fact you already use in school: two points fix a line, three points fix a parabola, and k points with different x-values fix exactly one polynomial of degree k − 1. If that fact is new, our guide to Lagrange interpolation through any set of points builds it up first.
How does the polynomial hide the secret?
The recipe, step for step as in the 1979 paper:
Choose a prime p bigger than both the secret D and the number of people n.
Pick a random polynomial q(x) = a₀ + a₁x + … + aₖ₋₁xᵏ⁻¹ with a₀ = D and the other coefficients chosen at random from 0 to p − 1.
Give person i the share (i, q(i) mod p).
Any k people interpolate q and read off the secret as q(0).
Why a prime? Shamir works modulo p because the integers modulo a prime form a field, where every non-zero number has an inverse, so the divisions inside interpolation always work. Our post on finite fields built by hand shows what a field is.
Worked example: a (3, 5) scheme mod 11
Say the secret is D = 7, there are five people, and any three should be able to open it. Take p = 11, which is bigger than 7 and 5. Pick random coefficients a₁ = 2 and a₂ = 5, so q(x) = 7 + 2x + 5x² mod 11.
First, make the five shares:
q(1) = 14, which is 3 mod 11, so share (1, 3)
q(2) = 31, which is 9 mod 11, so share (2, 9)
q(3) = 58, which is 3 mod 11, so share (3, 3)
q(4) = 95, which is 7 mod 11, so share (4, 7)
q(5) = 142, which is 10 mod 11, so share (5, 10)
Now recover the secret from three shares. People 1, 3 and 5 meet. Lagrange's formula at x = 0 gives q(0) = 3·L₁ + 3·L₃ + 10·L₅, where each weight is a product of (0 − xⱼ)/(xᵢ − xⱼ) over the other two people:
L₁ = (−3)(−5) / ((1 − 3)(1 − 5)) = 15/8
L₃ = (−1)(−5) / ((3 − 1)(3 − 5)) = 5/(−4)
L₅ = (−1)(−3) / ((5 − 1)(5 − 3)) = 3/8
Dividing mod 11 means multiplying by an inverse. Since 8 × 7 = 56 = 5 × 11 + 1, the inverse of 8 is 7. Also −4 is 7 mod 11, and the inverse of 7 is 8. So L₁ = 15 × 7 = 105, which is 6; L₃ = 5 × 8 = 40, which is 7; L₅ = 3 × 7 = 21, which is 10.
Then q(0) = 3 × 6 + 3 × 7 + 10 × 10 = 139 = 12 × 11 + 7. The secret 7 comes back.
Try it yourself with people 2, 4 and 5: the weights come out as 7, 6 and 10, and you should get 7 again. For more practice with problems like this, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.
Why do two shares reveal nothing?
Suppose a thief steals shares (1, 3) and (2, 9). Test the guess D = 0: you need b₁ + b₂ = 3 and 2b₁ + 4b₂ = 9 mod 11, which gives b₂ = 7 and b₁ = 7, a perfectly good quadratic 7x + 7x². The true secret 7 fits too, with 2x + 5x².
That is the general argument in Shamir's paper: for every candidate value from 0 to p − 1 there is exactly one polynomial of degree k − 1 through the stolen points, all equally likely, so nothing can be deduced about D.
Where is Shamir secret sharing used?
Shamir wrote it for key management. In the paper he points out that with n = 2k − 1 the key survives the loss of k − 1 pieces, yet opponents who expose k − 1 of the remaining pieces still cannot rebuild it. His other example is a company that digitally signs its cheques and requires three signatures: with a (3, n) scheme, a dishonest executive needs at least two accomplices to forge the signature. Shares can also be refreshed by choosing a new polynomial with the same constant term, so stolen pieces from different editions cannot be combined.
The idea still runs real systems. HashiCorp's Vault secrets manager, by default, uses Shamir's secret sharing to split the key that unseals it into shares, and the vault operator init command defaults to 5 key shares with a threshold of 3, the same shape as the example above. Vault's seal documentation describes operators adding shares one at a time, in any order, until there are enough to rebuild the key.
If modular inverses or interpolation still feel shaky, the Fermi Concept Library covers concepts across mathematics and computing, each with its own lesson, and the Vandermonde determinant post shows why k points always fix one polynomial.



