Combining shares #
combine k shares checks the shares, then rebuilds each secret byte with Lagrange interpolation
at 0. The Lagrange weights depend only on the (public) share indices, so they are computed once.
Checks, in order:
- at least
kshares, - no share has index
0, - no two shares have the same index,
- all payloads have the same length,
- consistency (README: Forged shares): every share after the first
klies on the polynomials rebuilt from the firstk, i.e. its payload equalsinterpolateSharesAt x (shares.take k)at its indexx.
Check 5 catches a forged or wrong share whenever at least k of the given shares are genuine,
so giving combine more than k shares protects against cheating shareholders. With exactly
k shares there is nothing to compare against, and the check always passes.
Correctness (combine_split) and forgery detection (combine_detects_forgery) are proved in the
proofs/ package, which uses Mathlib (README: Guarantees).
Why combine refused the shares.
- tooFewShares : CombineError
Fewer than
kshares were given. - zeroIndex : CombineError
A share has index
0, whichsplitnever produces. - duplicateIndex : CombineError
Two shares have the same index.
- lengthMismatch : CombineError
The share payloads have different lengths.
- inconsistent : CombineError
The shares do not all lie on one polynomial of degree
< k: at least one of them is wrong or forged (only possible to see with more thankshares).
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Rebuild the secret from shares whose indices and payload lengths are already checked:
byte b is Σᵢ wᵢ · ysᵢ[b] with the Lagrange weights wᵢ of the indices.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Fast version of interpolateShares, used by compiled code. The specification reads byte b
of each payload with List.getD, which walks the list, so the whole rebuild is quadratic in the
secret length. Here every payload is turned into an Array once, and Array.getD is
constant-time.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The fast rebuild computes exactly the specification. Marked @[csimp], so the compiler runs
interpolateSharesFast wherever the code says interpolateShares, while every theorem
(including combine_split) stays about the readable interpolateShares.
The payload that a share at index z would have, rebuilt from shares by Lagrange
interpolation at z: byte b is Σᵢ wᵢ(z) · ysᵢ[b].
Equations
- One or more equations did not get rendered due to their size.
Instances For
Fast version of interpolateSharesAt (payloads as arrays), as for interpolateShares.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The fast version computes exactly the specification (@[csimp]: compiled code runs it).
Equality of two byte lists, without stopping at the first difference: the XOR of each pair is OR-ed into one accumulator, and only the final result is tested. Share payloads are secret, so the time taken should not depend on where they differ.
Equations
- QedShare.Shamir.sameBytes a b = (a.length == b.length && List.foldl (fun (x1 x2 : UInt8) => x1 ||| x2) 0 (List.zipWith (fun (u v : QedShare.GF256) => (u + v).val) a b) == 0)
Instances For
Does share sh lie on the polynomials rebuilt from base?
Equations
- QedShare.Shamir.fits base sh = QedShare.Shamir.sameBytes (QedShare.Shamir.interpolateSharesAt sh.x base) sh.ys
Instances For
Every share after the first k lies on the polynomials rebuilt from the first k.
Equations
- QedShare.Shamir.consistent k shares = (List.drop k shares).all (QedShare.Shamir.fits (List.take k shares))
Instances For
Rebuild a secret from shares, with threshold k. Returns an error instead of a wrong
answer whenever the shares are obviously unusable.
Equations
- One or more equations did not get rendered due to their size.
Instances For
combine never succeeds when a share after the first k does not lie on the polynomials
rebuilt from the first k.