qedshare API docs
qedshare is Shamir's Secret Sharing over GF(2⁸), written in Lean 4, with the
important guarantees proven as theorems. Split a secret into n shares: any
k rebuild it, any k − 1 reveal nothing.
These pages document every definition and theorem of version 0.18.1
(commit a4666ad), each with its exact
statement, a plain-English explanation and a link to its source.
For installation, usage and the threat model, see the
README.
GitHub ·
Releases ·
Changelog
Status: early development, not audited. Do not use it for real secrets yet.
The qs3 share format is frozen: every later version reads the shares written
today (Format stability).
Start here
| Module | What it contains |
|---|---|
| QedShare.Field | GF(2⁸): the GF256 type, constant-time multiply and inverse, field laws |
| QedShare.Field.Tower | GF(2¹²⁸) as four quadratic extensions of GF(2⁸), for the AMD tag |
| QedShare.Poly | Polynomials as coefficient lists, Horner evaluation, Lagrange interpolation |
| QedShare.Shamir.Split | split: one random polynomial per secret byte, evaluated at x = 1 … n |
| QedShare.Shamir.Combine | combine: checks, consistency of extra shares, interpolation at 0 |
| QedShare.Shamir.Secrecy | Perfect secrecy: k − 1 shares reveal nothing |
| QedShare.Encoding | CRC-32, the AMD tag, the share tokens, hex, the qs3 (and older qs2, qs1) share format, word shares |
| QedShareCli | The command-line tool: arguments, files, OS randomness |
Headline theorems
| Guarantee | Theorem |
|---|---|
| GF(2⁸) satisfies the field laws | mul_assoc, mul_add, mul_inv, … |
| Constant-time multiply equals textbook multiply, for every input | mul_eq_mulSpec |
split never makes a share at x = 0; indices are distinct | split_no_zero_index, split_distinct_indices |
Any k or more shares of one split rebuild the exact secret | combine_split ¹ |
Any k − 1 shares are equally consistent with every secret of the same length (perfect secrecy) | perfect_secrecy, perfect_secrecy_card ¹ |
Bad parameters, duplicates, too few shares and x = 0 are rejected | Params.mk?_isSome_iff, combine_rejects_duplicates, combine_rejects_too_few, combine_rejects_zero_index |
With k genuine shares present, any forged or changed share is refused | combine_detects_forgery ¹, combine_consistent_split ¹, combine_rejects_inconsistent |
| GF(2¹²⁸), built as a tower over GF(2⁸), is a field with 2¹²⁸ elements | GF2_128.isField ¹ |
AMD tag: a tagged secret decodes back; a change a·E + Δ (a ≠ 0, not the identity) passes for at most D + 2 of the 2¹²⁸ keys | Amd.decode_encode, amd_detect ¹ |
End to end (qs2): forgers holding at most k − 1 shares get a changed result accepted with probability at most (D + 2) / 2¹²⁸, if only one honest share is given or they only use their own indices (not in every case: see the README) | combine_detects_forgery_whp ¹ |
End to end (qs3, with share tokens): forgers holding at most k − 1 shares and tokens get a changed result accepted with probability at most (D + 2) / 2¹²⁸, whatever they do, next to any number of honest shares, in any order | combine_detects_forgery_tok ¹, combine_detects_forgery_tok_any_order ¹, combine_perm ¹, Token.decode_encode |
Any k − 1 shares with their tokens are equally consistent with every secret of the same length | perfect_secrecy_tok ¹ |
CLI round trip: whatever qedshare split writes, qedshare combine on any k or more of those strings returns exactly the secret | recoverSecret_makeShares ¹, Cli.decodeShare_encodeRecord; and when combine accepts, the secret is exactly the proven core's result: Cli.recoverSecret_ok. The memory-light versions the executable runs return exactly the same results: Cli.makeSharesBytes_eq, Cli.recoverSecretBytes_eq, Cli.describeSharesBytes_eq, Cli.convertSharesBytes_eq |
With exactly one bad share among k + 2 or more, the share qedshare combine names as the odd one out is the bad one | oddOneOut_names_bad ¹ |
| Hex shares round-trip | Encoding.decode_encode, stripTag_withTag |
| Word shares round-trip | Mnemonic.decode_encode, Bits.unpack_pack |
| The word list: 2048 distinct words, 4 letters identify a word | words_injective, prefix_unique |
¹ These theorems use Mathlib, so they live in the separate
proofs/ package and the links go to
their source on GitHub. Documenting proofs/ here would pull in all of Mathlib.
Every headline theorem's axioms are checked in CI by
Axioms.lean; see
What you have to trust.
Built with Lean 4 v4.36.0 and doc-gen4. The library list on the left also contains Lean's own
Init, Std, Lean and Lake, which qedshare's pages link to.