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 N-K 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
kandn. Both must be less than 256, andkmust be less thann.
Encode
Kshares inshareseach of lengthshare_sizeintoNshares, also each of lengthshare_size. Theoutput_cbfunction will be called once for each output share (in some unspecified and possibly non-deterministic order).The parameters to
output_cbare: 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_sizebytes. The shares are identified by a small integer (between 0 and 255).The parameters to
output_cbare similar to that ofencode_shares.
-
ZFEC(size_t k, size_t n)¶