DevTools Logo

Shamir Secret Sharing

Shamir Secret Sharing

Split a secret into N independently useless shares; any M of them reconstruct it — offline, over GF(2^8).

Runs in your browser
Try an example

Secret & threshold

0 / 4,096 bytes

0 bytes will be split.

Coefficients come from the browser CSPRNG — no seed, no repeat. Each share is independently useless; integrity is checked on reconstruction, not proven authentic.

Share distributor

Enter a secret and a threshold

Try an example above to see a full ceremony.

How Shamir sharing works (and what it does not)

Each secret byte becomes the constant term of a random polynomial of degree M−1 over GF(2^8) (primitive polynomial 0x11D). Share x is the polynomial evaluated at x = 1..N. Any M points determine the polynomial; M−1 points are consistent with every possible secret, so a single share reveals nothing.

Reconstruction is Lagrange interpolation at x = 0. A 4-byte SHA-256 prefix is appended to the secret before splitting and checked afterwards: it detects wrong or mixed shares, but anyone can compute it, so it is tamper detection, not authentication. Shares are not encrypted, and this tool does not manage their storage or rotation.

Enter a UTF-8 secret (or hex/base64 bytes), choose N total shares and an M-of-N threshold, and get self-describing SSS1 shares in base64 or hex. Each share is the evaluation of a random degree M−1 polynomial over GF(2^8) at x = 1..N; any M shares reconstruct via Lagrange interpolation at x = 0. A 4-byte SHA-256 prefix appended before splitting detects wrong or mixed shares. Label and print one card per holder, then paste any M cards back into the Combine tab. Random coefficients come from the browser CSPRNG, nothing leaves the tab, and the secret is cleared on unload.

  • Three of five for a team key: N=5 · M=3 · secret: 'correct horse battery staple' — Five labelled shares are generated; any three holders can reconstruct, two cannot.
  • Lost share recovery: Paste shares x=1, x=3 and x=5 (any order) into Combine — The output secret matches the original byte-for-byte and the integrity badge shows a matching SHA-256 prefix.
  • Binary secret: Secret format: hex · deadbeefcafebabe0123456789abcdef — Hex mode splits exact bytes; reconstruction offers both the original bytes in hex and a UTF-8 view when valid.

Examples

3-of-5 key ceremony

Input
Secret: correct horse battery staple · N=5 · M=3
Output
5 SSS1 shares; any 3 reconstruct the original bytes with integrity ✓

Two holders can be absent or lose their cards without blocking recovery.

Combine out of order

Input
Paste share x=5, then x=1, then x=3
Output
correct horse battery staple · tag matches

Lagrange interpolation does not depend on the order or on which M subset is supplied.

Binary secret

Input
Hex secret: deadbeefcafebabe0123456789abcdef · N=4 · M=2
Output
Recovered hex matches the input; UTF-8 view is flagged as binary

Field arithmetic is byte-wise, so arbitrary bytes survive the round trip without encoding loss.

About this tool

Shamir Secret Sharing splits a secret into N shares so that any M of them (the threshold) reconstruct it, while M−1 shares reveal nothing. This tool implements Shamir's 1979 scheme byte-for-byte over GF(2^8) with the primitive polynomial 0x11D, the field convention used by ssss. Each byte of the secret is the constant term of a fresh random polynomial of degree M−1; share number x is that polynomial evaluated at x = 1..N.

Reconstruction uses Lagrange interpolation at x = 0 and works with any subset of M or more shares, in any order. A four-byte SHA-256 prefix is appended to the secret before splitting, so reconstruction can report whether the recovered bytes pass an integrity check. The check detects wrong or mixed-up shares, not a maliciously crafted substitute: anyone can recompute the prefix. All coefficients come from the browser's CSPRNG, all arithmetic happens in the tab, and nothing is uploaded or persisted.

What this tool does not do

  • Shares are not encrypted at rest: protecting each card or file is the holder's responsibility.
  • The 4-byte SHA-256 prefix detects tampering and mixed share sets but is not a message authentication code or a signature.
  • The SSS1 packet is version-tagged and self-describing; it does not import or export ssss CLI share files byte-for-byte.
  • Only GF(2^8) byte-wise splitting is supported — no prime-field variant, weighted shares, share rotation or multi-secret ceremonies.
  • Secrets are capped at 4 KB; nothing is saved to disk or localStorage and the in-memory values are cleared on page unload.
  • There is no per-share checksum, so a corrupted share is only detected after reconstruction via the integrity verdict.

How to use this tool

  1. Choose a ceremony

    On the Split tab, set N (2–16 holders) and M (the number needed to rebuild). A 3-of-5 split tolerates two lost shares.

  2. Enter the secret

    Type UTF-8 text, or switch the input format to hex/base64 to split exact binary bytes. The byte counter shows what will be split; the 4 KB cap protects the browser.

  3. Distribute the shares

    Name each holder on a share card, copy or export all cards as text, and print one card per holder. Store them separately — a single share is useless on its own.

  4. Reconstruct

    On the Combine tab, paste any M or more SSS1 share lines (or a JSON array, or printed-card text). The result shows the secret, its hex bytes and the integrity verdict.

Use cases

Root API key handover

Give a production key to several team leads so no single person can use or lose it alone.

Recovery phrase backup

Split a wallet recovery phrase across family members or locations with an explicit quorum.

Learning the scheme

Inspect the documented SSS1 packet and verify the shares against Shamir's construction.

Formats and share packet

FieldMeaning
SSS1Four ASCII magic bytes identifying version 1 of this share format.
N / MOne byte each: total holders and the reconstruction threshold, repeated in every share so a mixed set is detectable.
xOne byte: the share's point index, 1 through N. Duplicate x values are rejected on combine.
yThe evaluated polynomial: one field byte per secret byte plus the four-byte SHA-256 prefix.
base64 / hexThe SSS1 packet is encoded as 'SSS1:<base64>' or 'SSS1:<hex>'; labels and whitespace around the token are ignored when pasting.

Each share string is self-describing, so a holder only needs one line to know its index, the total and the threshold.

Common mistakes

Mistake:Treating a share as encrypted data.

Fix:A share is not ciphertext. Splitting removes information from any single share; it does not protect a share that is stored carelessly.

Mistake:Setting M = 1 and assuming shares are private.

Fix:With M = 1 each share is the secret plus a public tag. Use M ≥ 2.

Mistake:Pasting shares from two different ceremonies.

Fix:Check the N/M header and payload length printed in the error; the tool rejects mixed sets before interpolation.

Mistake:Assuming the integrity badge authenticates the holders.

Fix:It only detects inconsistent shares. Anyone who can compute a SHA-256 prefix can forge a tag; authenticate holders out of band.

Mistake:Losing more than N − M shares.

Fix:Write the tolerance on every card: with 3-of-5, two losses are survivable and a third is fatal.

Frequently asked questions

How many shares can be lost before the secret is gone?

Exactly N − M. In a 3-of-5 ceremony two shares may be lost and any of the remaining three still reconstruct the secret; losing a third makes it unrecoverable. Pick N and M around how many holders you can reliably keep, not around how many you would like to invite.

Does a single share reveal anything about the secret?

No. Shamir's scheme is information-theoretically secure below the threshold: for any M−1 shares, every possible secret is equally consistent with them. That property assumes the polynomial coefficients are truly random — this tool generates them with crypto.getRandomValues and never from a seed.

What happens if someone loses a share?

Nothing happens to the secret as long as at least M valid shares remain. Reconstruct with any M of the surviving shares. The tool refuses to interpolate from fewer than M shares, because a sub-threshold result would not be a real secret.

Is this encryption — can I use it for a wallet seed?

Splitting is not encryption: there is no single key to steal, and each share must still be stored carefully. You can split a wallet recovery phrase as bytes or text, but the shares are not encrypted at rest and this tool does not verify them against your wallet. Keep a tested recovery path and never rely on an untested ceremony for your only backup.

What does the integrity ✓ badge actually prove?

It proves the recovered bytes hash to the four-byte SHA-256 prefix that was embedded at split time. It detects a corrupted share, a share pasted from another ceremony, or a below-threshold attempt. It is tamper detection, not authentication: anyone can compute the prefix, so verify share provenance out of band.

Can I paste printed share cards back into the tool?

Yes. Each card contains a labelled SSS1 token on one line; the Combine parser accepts those labels and surrounding whitespace, one line per share, a JSON array of share strings, or bare tokens. It also accepts base64 and hex shares, and reports parse errors per line.

Is this compatible with the ssss command-line tool?

The field convention matches ssss (GF(2^8), primitive polynomial 0x11D), but the SSS1 packet and its integrity tag are this tool's own version-tagged format. It does not read or write ssss CLI share files byte-for-byte.

Where are my secret and shares stored?

Nowhere. There is no account, upload or localStorage write; input and results live in this tab's memory and are cleared on page unload or when you press Clear all. Explicitly copy, export or print the shares if you want a record — that export is the only durable copy.

References & standards