->SSSS
cryptoThe ->SSSS
function splits a byte array into N
shares so K
of them can reconstruct the original byte array.
The splitting is done using a Shamir Secret Sharing Scheme as described in the seminal paper by Adi Shamir.
The principle is based on the fact that a polynomial P
of degree K-1
can be fully determined by K
points (X
,Y
), where Y = P(X)
. All computations are performed using arithmetic in the Galois Field GF(256)
used for QR/Code Reed Solomon error correction, its generator is 2
and its primitive polynomial 0x11D
(x^8 + x^4 + x^3 + x^2 + 1
).
For each byte B
to encode, a random polynomial P
over GF(256)
is chosen with the constraint that P(0) = B
. Then N
random values of GF(256)
are selected and for each X
such value, the two bytes X
and P(X)
are output to a share. If X
was 0, a random value is emitted instead of P(X)
and a new X
value is selected. This is done to ensure the randomness of the output. It may therefore be possible that a split is longer than twice the size of the original input.