libgfshare implements Shamir secret sharing [SHAMIR] over the field GF(28), instead of GF(p) for a prime p as suggested by Shamir’s paper. This document aims to prove the security and integrity of this scheme.
Note that while I believe this document to be correct, I accept no responsibility for loss or damage caused by relying on the correctness of my proof.
Let F be a field with multiplicative identity 1 and additive identity 0.
If A = {(a1,b1),,(an,bn)}, with the ai distinct nonzero elements of F and the bi elements of F, indexed by
I = {1,
,n}, then define
a polynomial of degree at most n - 1. (By distinctness of the ai, the inverses required exist.) This is the Lagrange interpolating polynomial for the points in A.
Let a1,,at ∈ F be distinct and nonzero; let b1,
,bt-1,c ∈ F be arbitrary. Then there exists bt ∈ F such that if
A = {(a1,b1),
,(at,bt)} then PA(0) = c.
Let I = {1,,t}. We have
Let
Then
as required.
For any x1,,xt distinct and nonzero elements of F, and any y1,
,yt,u arbitrary elements of F, let
and
Then PX = PU,i.e.PX(x) = PU(x) for all x ∈ F.
Let Sa,b = . Then
Hence if we let di,j = xi -xj and ei = u-xi (both of which are necessarily nonzero, by distinctness of the xi and u) we have
and if we also let fi = x - xi,
Expanding,
Now
Hence
as required.
Let s be the number of “shares” and t be the required threshold to recover the shared secret (i.e. we construct a “t of s” share).
Given a secret f ∈ F we may construct a Lagrange interpolating polynomial PX of degree no more than t - 1, with PX(0) = f, as follows:
- choose distinct nonzero x1,,xs ∈ F
- choose arbitrary (and unpredictable) y1,,yt-1 ∈ F
- use Lemma 1 to select yt such that X = {(x1,y1),,(xt,yt)} has the desired intercept f
To obtain additional shares, calculate yt+1 = PX(xt+1),,ys = PX(xs).
In libgfshare the construction used is as follows:
- construct a polynomial P by choosing arbitrary and unpredictable coefficients of x,,xt-1 from F, and setting the
coefficient of x0 to f: this therefore has the desired intercept f
- choose distinct nonzero x1,,xs ∈ F and evaluate y1 = P(x1),
,ys = P(xs)
Suppose F is finite, as is the case in libgfshare, and that in each construction, arbitrary choices are made from among all possible values in F.
In the alternate construction, given x1,,xt,f we choose a polynomial P(x) = f + m1x +
+ mt-1xt-1 by choosing
arbitrary coefficients m1,
,mt-1 ∈ F, i.e. choosing arbitrarily from among the
t-1 distinct polynomials of degree no
more than t - 1 with intercept f.
In the first construction, given x1,,xt,f we obtain a polynomial by choosing arbitrary y1,
,yt-1 ∈ F. The
polynomials chosen are necessarily distinct since no polynomial can pass through both (xi,p) and (xi,q) for any p≠q, so by
choosing each yi from among the
elements of F, we choose arbitrarily from a set of
t-1 distinct polynomials whose
intercepts are all f.
Since there are only t-1 such polynomials, each construction chooses arbitrarily from among the same set, and by
the pigeonhole principle there exists a bijective mapping between sets of arbitrary y values in the first construction and sets
of arbitrary coefficients in the second.
Let B ⊂ with |B| = t. Then PB(0) = c.
Further, if B′⊂ with |B′| > t, then for every subset B of B′ with |B| = t, PB(0) = f.
The second part is trivially implied by the first.
Recall that X = and that PX(0) = f. If B = X the result is true. If not, repeatedly
apply Lemma 2 to replace an element of X not in B with an element of B not in X, preserving the value of
P(0).
Let C ⊂ with |C| < t. Then for each d ∈ F, there exists D ⊃ C, |D| = t, such that
d = PD(0).
(In other words, any d ∈ F remains a possible value for the secret, so an attacker with fewer than t shares has gained no information.)
Let ai, bi be such that C = , some n < t. Choose arbitrary an+1,
,at and arbitrary bn+1,
,bt-1.
Let bt be chosen by applying Lemma 1 with c := d. Then by choice of bt, PC(0) = d as required.
The program test_gfshare_isfield, compiled and run by make check, demonstrates that the calculations done by libgfshare are indeed performed in a field.
This document has not addressed the following:
- Attacks based on the use of a predictable or partially predictable pseudorandom number generator might be possible.
- In the implementation used in libgfshare, the field F is the field of byte values, with addition being bitwise exclusive-or, and multiplication as usual; each byte of the secret is shared separately by applying this algorithm separately. This means that when a secret file is shared, the length in bytes of each share equals the length in bytes of the secret. If the length of the secret is itself secret, it should be padded to some standard length before sharing.
[SHAMIR] Adi Shamir, ”How to share a secret”, Communications of the ACM, 22(1), pp612–613, 1979. Available at http://www.cs.tau.ac.il/~bchor/Shamir.html
Copyright 2006 Simon McVittie, http://smcv.pseudorandom.co.uk/
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ”Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ”AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.