Shamir Secret Sharing Calculator

Enter a secret, share count, threshold and prime to generate shares.

How it is calculated

The secret S becomes the constant term of a polynomial of degree k−1: f(x) = S + a1x + … + ak−1xk−1 (mod p). Share number i is the pair (i, f(i)), for i = 1 … n, and any k shares determine the polynomial and so recover S = f(0). Here p is the prime modulus, and the secret must be a whole number from 0 up to p−1.

Unlike a real implementation, the coefficients are not random: each ai is computed from a CRC-32 checksum of the text “seed#i” taken mod p, so the same inputs and seed always give the same shares. This makes the output repeatable, which suits learning and checking by hand, but it is not secure. All numbers must be whole and no larger than about 3 billion. The threshold must be at least 2 and no larger than the share count, the share count must be between 1 and 1,000 and smaller than p, and p must be prime. Any input that breaks these rules shows no result.

Worked example

Secret S = 1234, n = 4 shares, threshold k = 3, prime p = 7919, seed “demo”. The seed gives a1 = 6415 and a2 = 1485, so f(x) = 1234 + 6415x + 1485x² (mod 7919). f(1) = 9134 − 7919 = 1215. f(2) = 20004 − 2×7919 = 4166. f(3) = 33844 − 4×7919 = 2168. f(4) = 50654 − 6×7919 = 3140. The tool lists the shares as:
1: 1215
2: 4166
3: 2168
4: 3140
Any three of them can be combined by Lagrange interpolation to get 1234 back.

Try this example →

Common mistakes

  • Using the shares as a real secret split. The coefficients come from a public checksum of the seed, so anyone who knows the seed (the default is “demo”) can rebuild the polynomial and even one share would then reveal the secret. Use it to learn the method only.
  • Choosing a modulus that is not prime, such as 7920. The tool rejects it, because division in the recovery step needs a prime field.
  • Entering a secret equal to or larger than the modulus. The secret must be below p, so a 4-digit secret needs a prime above 9999.
  • Making the share count as large as the modulus. Shares are numbered 1 … n and those numbers must be distinct non-zero residues mod p, so n has to be smaller than p; with p = 7, asking for 7 shares shows no result.
  • Setting the threshold to 1 or above the number of shares. Thresholds below 2 give no result, and a threshold above n could never be met.

About this calculator

Introduced by cryptographer Adi Shamir in 1979, Shamir's Secret Sharing splits a secret into n shares so that any k of them reconstruct it exactly, while — when implemented properly — any k−1 or fewer reveal absolutely nothing about it (information-theoretic, not just computational, security). It works by building a polynomial of degree k−1 whose constant term is the secret, with the other coefficients chosen at random, then handing each participant one point (x, f(x)) on that polynomial, evaluated over a finite field defined by a prime modulus.

Recovery uses Lagrange interpolation: any k of the distributed points uniquely determine the degree-(k−1) polynomial, and evaluating it at x = 0 returns the original secret. This threshold scheme underlies real key-management systems — HashiCorp Vault's unseal keys and wallet-recovery standards like SLIP-0039 use it so that no single key holder, and no small subset of them, can reconstruct a master secret alone. This calculator is a learning demonstration: the other coefficients come from a seed text rather than true randomness, so the same inputs always give the same shares. Do not use it to protect real secrets.

Was this helpful?

You can pick up to 3 reactions.

Comments

  • Be the first to comment.

Popular calculators

All Calculators