Module rlnc

Module rlnc 

Source
Expand description

Random Linear Network Coding (RLNC) over GF(2⁸).

§Encoding — systematic form

A chunk of bytes is split into k equally-sized source symbols. The encoder uses systematic encoding: the first k fragments carry the identity coefficient matrix (each fragment is one source symbol), guaranteeing that frags[..k] always decodes deterministically. The remaining n-k fragments use random GF(2⁸) coefficients for redundancy.

fragment_data[i]    = Σ coeff[i][j] · source_symbol[j]   (over GF(2⁸), byte-wise)
coding_vector[i]    = [coeff[i][0], coeff[i][1], ..., coeff[i][k-1]]
coeff[i][j]         = δ(i,j)  for i < k   (systematic)
                    = random  for i ≥ k   (redundant)

§Recoding — no decompression required

A Pouch holding m fragments can produce new fragments by recombining them:

new_data    = Σ a[i] · fragment_data[i]
new_vector  = Σ a[i] · coding_vector[i]

The result is a valid encoded fragment of the same chunk. The Pouch never touches the original chunk.

§Decoding

Any k linearly independent fragments suffice. Gaussian elimination over GF(2⁸) on the [coding_vectors | fragment_data] augmented matrix yields the source symbols, which are then concatenated to recover the chunk.

Structs§

EncodedFragment
A single RLNC-encoded fragment of a chunk.

Functions§

chunk_hash
BLAKE3 hash of a chunk, hex-encoded, first 16 chars (64-bit prefix).
decode
Reconstruct the original chunk from k (or more) linearly independent fragments.
encode
Split chunk into k source symbols and produce n encoded fragments.
recode
Produce count new fragments by recombining existing ones.