Caloogy Article
中文

Shamir's Secret Sharing: Split a Private Key into nn Shares, Recover It from Any kk

Date
Oct 20, 2026
Series
Cryptography
Reading
4 min
Topics
Secret sharingShamirLagrange interpolationThreshold

The one-sentence version

Hide the secret in the constant term f(0)f(0) of a polynomial of degree k−1k-1, and give each person one point (i,f(i))(i, f(i)) on the polynomial. Any kk points determine the polynomial uniquely by Lagrange interpolation, recovering the secret; with fewer than kk points, every possible value of the secret is equally likely, and not a bit of information leaks.

This article has three layers:

  1. The intuition: two points determine a line
  2. Real-world use: wallet backups, MPC wallets, threshold signatures, the DNSSEC root key
  3. The mathematics: polynomials over finite fields, Lagrange interpolation, perfect security and a worked example

Layer 1: The Intuition

1.1 Why "split" a private key

If a Bitcoin private key is stored in only one place:

Keeping several copies protects against loss but multiplies the risk of theft. What we want is: split it into 5 shares for 5 people (or 5 places), so that any 3 together can recover it, while any 2 together are useless. This is called a (3,5)(3, 5) threshold scheme.

1.2 Two points determine a line

Start with the simplest (2,n)(2, n) scheme:

  1. Plot the secret SS on the yy-axis, as the point (0,S)(0, S);
  2. Draw any line (with a random slope) through this point;
  3. Take the points on the line at x=1,2,…,nx = 1, 2, \dots, n, and give one to each person.

Any two people put their points together; two points determine a line, and extending it to the yy-axis reveals SS. But someone holding just one point sees infinitely many lines through it, meeting the yy-axis at any value at all, so they can't guess SS at all.

For a threshold of 3, replace the line with a parabola (three points determine a parabola); for a threshold of kk, use a polynomial of degree k−1k-1.

1.3 The same thing as Reed–Solomon codes

Reed–Solomon error correction treats data as polynomial coefficients and sends the polynomial's values at many points, so the data can be interpolated back even if some points are lost. Shamir's secret sharing uses the same evaluation map with a different emphasis: error-correcting codes care about "recovering what was lost", while secret sharing also cares that "too few points reveal nothing".


Layer 2: Real-World Use

Where How it's used
Split backups of recovery phrases (SLIP-39, hardware wallets such as Trezor) A wallet seed is split into several recovery phrases, such as "any 3 of 5"
Corporate / exchange cold wallets The private key is divided among several executives or safes, guarding against one person acting alone or a single point of loss
MPC wallets and threshold signatures One step further: the private key never appears whole anywhere, and the parties jointly compute a signature from their shares (such as the FROST and GG20 protocols)
The DNSSEC root key Recovery credentials for the internet's root zone signing key are held by trusted community representatives around the world, and several must be present
HashiCorp Vault The unseal master key is split into 5 shares with a threshold of 3 by default

How it differs from multisig

Bitcoin multisig specifies on-chain that "signatures from 3 different private keys are required", and the rule is publicly visible. Threshold signatures use secret sharing off-chain and produce one ordinary signature, which on-chain looks just like a single-person wallet, with lower fees and more privacy.

Two weaknesses of plain Shamir

  1. At the moment of recovery, the complete secret appears on some machine, which becomes a target. The point of MPC wallets is to avoid even this moment.
  2. If the person distributing shares (the dealer) cheats and hands out inconsistent shares, the recipients can't tell. Verifiable secret sharing (Feldman / Pedersen VSS) solves this by attaching a commitment to each coefficient.

Layer 3: The Mathematics

3.1 Working in a finite field

Polynomials over the real numbers leak information (the size of a share can hint at the range of the secret), so everything happens in a finite field Fp\mathbb{F}_p, where pp is a prime larger than the secret.

Distribution: the secret is S∈FpS \in \mathbb{F}_p, with threshold kk. Randomly choose a1,…,ak−1∈Fpa_1, \dots, a_{k-1} \in \mathbb{F}_p and let

f(x)=S+a1x+a2x2+⋯+ak−1xk−1,f(x) = S + a_1 x + a_2 x^2 + \cdots + a_{k-1} x^{k-1},

and person ii receives the share (i,f(i))(i, f(i)), for i=1,…,ni = 1, \dots, n.

3.2 Why kk points determine the polynomial uniquely

A nonzero polynomial of degree at most k−1k-1 over a field has at most k−1k-1 roots (abstract algebra: F[x]F[x] is an integral domain, and the factor theorem). If two polynomials of degree ≤k−1\le k-1 agree at kk points, their difference has kk roots and must be the zero polynomial. So it is unique.

3.3 Lagrange interpolation

Given kk points (xj,yj)(x_j, y_j), construct

Lj(x)=∏m≠jx−xmxj−xm,L_j(x) = \prod_{m \ne j} \frac{x - x_m}{x_j - x_m},

which equals 11 at xjx_j and 00 at the other xmx_m. Then f(x)=∑jyjLj(x)f(x) = \sum_j y_j L_j(x). We only need the constant term:

S=f(0)=∑jyj Lj(0),Lj(0)=∏m≠j−xmxj−xm.S = f(0) = \sum_j y_j \, L_j(0),\qquad L_j(0) = \prod_{m \ne j} \frac{-x_m}{x_j - x_m}.

Note that SS is a linear combination of the shares. This is crucial: in threshold signatures, the parties needn't hand over their shares; each computes only the part "share ×Lj(0)\times L_j(0)", and these are added in the exponent or as elliptic curve points.

3.4 Why k−1k-1 shares reveal nothing

Fix any k−1k-1 shares. For every candidate value of the secret S′∈FpS' \in \mathbb{F}_p, adding the point (0,S′)(0, S') gives kk points in all, which determine exactly one polynomial. So each S′S' corresponds to the same number (exactly one) of coefficient choices, and since coefficients are chosen uniformly at random, each S′S' has probability 1/p1/p.

This is called information-theoretic security (perfect security): it depends on no computational hardness, and no amount of computing power, quantum or otherwise, helps. The reasoning is the same as for the one-time pad.

3.5 A worked example

A (3,5)(3, 5) scheme over F13\mathbb{F}_{13}

The secret is S=7S = 7, with random a1=3a_1 = 3 and a2=5a_2 = 5: f(x)=7+3x+5x2(mod13).f(x) = 7 + 3x + 5x^2 \pmod{13}.

The five shares:

ii Computing f(i)f(i) Share
1 7+3+5=157 + 3 + 5 = 15 (1,2)(1, 2)
2 7+6+20=337 + 6 + 20 = 33 (2,7)(2, 7)
3 7+9+45=617 + 9 + 45 = 61 (3,9)(3, 9)
4 7+12+80=997 + 12 + 80 = 99 (4,8)(4, 8)
5 7+15+125=1477 + 15 + 125 = 147 (5,4)(5, 4)

Recover from shares 1, 3 and 5:

  • L1(0)=(−3)(−5)(1−3)(1−5)=158L_1(0) = \dfrac{(-3)(-5)}{(1-3)(1-5)} = \dfrac{15}{8}. 15≡215 \equiv 2 and 8−1≡58^{-1} \equiv 5 (8⋅5=40≡18 \cdot 5 = 40 \equiv 1), so L1(0)=10L_1(0) = 10
  • L3(0)=(−1)(−5)(3−1)(3−5)=5−4L_3(0) = \dfrac{(-1)(-5)}{(3-1)(3-5)} = \dfrac{5}{-4}. −4≡9-4 \equiv 9 and 9−1≡39^{-1} \equiv 3, so L3(0)=15≡2L_3(0) = 15 \equiv 2
  • L5(0)=(−1)(−3)(5−1)(5−3)=38=3⋅5=15≡2L_5(0) = \dfrac{(-1)(-3)}{(5-1)(5-3)} = \dfrac{3}{8} = 3 \cdot 5 = 15 \equiv 2

S=2⋅10+9⋅2+4⋅2=46≡7(mod13).S = 2 \cdot 10 + 9 \cdot 2 + 4 \cdot 2 = 46 \equiv 7 \pmod{13}.

The result is 77. (Checked with Python.)


Summary

Layer Key points
Intuition kk points determine a polynomial of degree k−1k-1; the secret is its yy-intercept
Algebra Polynomials over a field have a bounded number of roots; Lagrange interpolation; the secret is a linear combination of shares
Security With fewer than kk shares it is information-theoretically secure, and even quantum computers can't help
Engineering Wallet backups, MPC wallets, threshold signatures; dealer cheating must be guarded against (VSS)