ZFEC Forward Error Correction¶
Added in version 3.0.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.
Warning
If a corrupted share is provided to the decoding algorithm, the resulting decoding will be invalid. It is recommended to protect shares using a technique such as a MAC or public key signature, if corruption is likely in your application.
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.
An example application that adds padding and a hash checksum is available
in src/cli/zfec.cpp
and invokable using botan fec_encode
and
botan fec_decode
.

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)¶