Shamir secret sharing

Split a secret into shares so that any K of N shares rebuild it and fewer reveal nothing (Shamir over GF(256), the same layout as HashiCorp Vault).

loading Shamir secret sharing
About this tool

What is Shamir secret sharing?

Shamir secret sharing splits a secret into N pieces, called shares, so that any K of them rebuild it and fewer than K reveal nothing at all. It is the method behind the unseal keys of HashiCorp Vault, and a common way to protect a master password, a recovery key or the passphrase of a wallet. Nobody holds the whole secret, and losing a few shares does not lose it.

The idea is a polynomial. For a threshold of K, the secret becomes the constant term of a random polynomial of degree K minus 1. Each share is a point on that curve. K points fix the curve and give back the constant term; K minus 1 points leave every possible secret equally likely. This page does the arithmetic byte by byte in the finite field GF(256), with the same polynomial as AES. A share is the computed bytes followed by one byte with the position number, from 1 to 255, so it is one byte longer than the secret. That is the same layout Vault uses.

You can split text or hexadecimal bytes, with up to 255 shares and a secret of up to 65,536 bytes. Shares are written as hexadecimal or Base64, and when you join them the page reads either.

Two things it does not do. The shares do not say how many are needed, so write K down next to them. And there is no check value: with fewer than K shares, or with a wrong share, the page gives you meaningless bytes, not an error. The randomness comes from the secure generator of your browser and nothing is sent anywhere. For a secret that guards real money, split it on an offline machine.

How to split and join

  1. In What to do, choose Split a secret or Join shares.
  2. To split, type the secret in Secret:. Under The secret is: pick Text or Hexadecimal bytes, and under Write shares as: pick Hex or Base64.
  3. Set Shares (N):, the total number of pieces, and Needed to rebuild (K):, how many are enough. The page states the rule, for example that any 3 of the 5 shares rebuild the secret.
  4. Use Copy all shares and give each share to a different person or place. Write K down with them.
  5. To join, choose Join shares, paste at least two shares in Shares, one per line:, and read Rebuilt secret. Use The secret is: to show the result as text or as hex, then Copy secret.

Examples

Rebuilding a known secret

These shares come from a 3-of-5 split of the three bytes 0102ff. The last byte of each is its position.

3172cf01
a179c402
9109f403
77aefe04
47dece05

In Join shares, choose Hexadecimal bytes and paste the first three lines. The result is 0102ff. Any other three lines give the same result. Only the first two give different bytes, which is expected.

Splitting a recovery phrase between three people

Choose 3 shares with a threshold of 2. Give one share to each person. Any two can rebuild the phrase, so one person being away or losing their share is not a disaster, and one person alone learns nothing. Remember that someone who gets a second share has the secret, so choose people who will not collude.

Using the output with Vault

The layout matches Vault, so shares of a Vault-style 3-of-5 scheme can be joined here in hex or Base64, for example in a recovery drill. Do this only with test data; never paste real unseal keys on a website.

A secret with accents

Text is encoded as UTF-8 before it is split. A secret like chave mestra ✓ comes back exactly when you join with Text selected.

Common mistakes

  • "Type the secret to split." The secret is empty.
  • "The number of shares must be a whole number from 2 to 255."
  • "The number needed to rebuild must be from 2 to the number of shares." K cannot be larger than N.
  • "The secret is not hexadecimal: use only 0-9 and a-f, in pairs." Switch to Text, or fix the digits.
  • "Paste at least two shares."
  • "The shares have different lengths. They are not from the same secret, or one was cut." Copy the shares again.
  • "Two shares are the same. Each share counts once."
  • "A share is damaged: its last byte (the position) cannot be zero."
  • Garbage output. You gave fewer than K shares, or a share from another secret. Add more.

Frequently asked questions

Is it safe if someone has K minus 1 shares?

Yes, in the information-theoretic sense. With fewer than K shares every possible secret is equally likely, so even unlimited computing power learns nothing.

Does it protect against a wrong or fake share?

No. Plain Shamir has no integrity check, so a changed share only gives a wrong result. Keep a checksum or hash of the secret to confirm the rebuilt value, for example with the hash generator.

How is this different from splitting a file in parts?

Each part of a split file helps an attacker. Here any group smaller than K is useless. For passphrases that you must remember or guess strength of, see the diceware generator.

Can I split a seed phrase?

You can, but the BIP39 generator explains the format. A seed phrase has its own scheme for sharing (SLIP-39), which this page does not implement.

Equivalent commands

# Vault: 5 shares, 3 needed (same scheme)
vault operator init -key-shares=5 -key-threshold=3
Report a problem