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 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.
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 - kand- n. Both must be less than 256, and- kmust be less than- n.
 - Encode - Kshares in- shareseach of length- share_sizeinto- Nshares, also each of length- share_size. The- output_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 to- share_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 of- encode_shares.
 
- 
ZFEC(size_t k, size_t n)¶