ZFEC Forward Error Correction¶
New in version 2.19.0.
The ZFEC
class provides forward error correction compatible
with the zfec library.
Forward error correction takes an input and creates multiple “shares”,
such that any K
of N
shares is sufficient to recover the
entire original input.
Note
Specific to the ZFEC format, the first K
generated shares are
identical to the original input data, followed by NK
shares of
error correcting code. This is very different from threshold secret
sharing, where having fewer than K
shares gives no information
about the original input.
ZFEC
requires that the input length be exactly divisible by K
;
if needed define a padding scheme to pad your input to the necessary
size.

class ZFEC¶

ZFEC(size_t k, size_t n)¶
Set up for encoding or decoding using parameters
k
andn
. Both must be less than 256, andk
must be less thann
.
Encode
K
shares inshares
each of lengthshare_size
intoN
shares, also each of lengthshare_size
. Theoutput_cb
function will be called once for each output share (in some unspecified and possibly nondeterministic order).The parameters to
output_cb
are: the share being output, the share contents, and the length of the encoded share (which will always be equal toshare_size
).
Decode some set of shares into the original input. Each share is of
share_size
bytes. The shares are identified by a small integer (between 0 and 255).The parameters to
output_cb
are similar to that ofencode_shares
.

ZFEC(size_t k, size_t n)¶