Documentation

qedshare

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

ModuleWhat it contains
QedShare.FieldGF(2⁸): the GF256 type, constant-time multiply and inverse, field laws
QedShare.Field.TowerGF(2¹²⁸) as four quadratic extensions of GF(2⁸), for the AMD tag
QedShare.PolyPolynomials as coefficient lists, Horner evaluation, Lagrange interpolation
QedShare.Shamir.Splitsplit: one random polynomial per secret byte, evaluated at x = 1 … n
QedShare.Shamir.Combinecombine: checks, consistency of extra shares, interpolation at 0
QedShare.Shamir.SecrecyPerfect secrecy: k − 1 shares reveal nothing
QedShare.EncodingCRC-32, the AMD tag, the share tokens, hex, the qs3 (and older qs2, qs1) share format, word shares
QedShareCliThe command-line tool: arguments, files, OS randomness

Headline theorems

GuaranteeTheorem
GF(2⁸) satisfies the field lawsmul_assoc, mul_add, mul_inv, …
Constant-time multiply equals textbook multiply, for every inputmul_eq_mulSpec
split never makes a share at x = 0; indices are distinctsplit_no_zero_index, split_distinct_indices
Any k or more shares of one split rebuild the exact secretcombine_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 rejectedParams.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 refusedcombine_detects_forgery ¹, combine_consistent_split ¹, combine_rejects_inconsistent
GF(2¹²⁸), built as a tower over GF(2⁸), is a field with 2¹²⁸ elementsGF2_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¹²⁸ keysAmd.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 ordercombine_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 lengthperfect_secrecy_tok ¹
CLI round trip: whatever qedshare split writes, qedshare combine on any k or more of those strings returns exactly the secretrecoverSecret_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 oneoddOneOut_names_bad ¹
Hex shares round-tripEncoding.decode_encode, stripTag_withTag
Word shares round-tripMnemonic.decode_encode, Bits.unpack_pack
The word list: 2048 distinct words, 4 letters identify a wordwords_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.