Encode data to enable recovery from a subset of fragments.
A Zig port of commonware's
commonware-coding.
ALPHA upstream: breaking changes are expected. See commonware's stability levels. The zigware port is complete. docs/lanes/coding.md tracks it, including its test audit.
Config,assert_scheme(root.zig): shard counts, and the comptimeSchemeinterface every coding scheme provides.reed_solomon,ReedSolomon(H)(reed_solomon/mod.zig): a Reed-Solomon scheme whose shards are provable against a binary Merkle tree.fuzz(fuzz.zig): thereed_solomonfuzz target of commonware'scoding/fuzz.
zig build test-coding # unit tests, including the minifuzz searches
zig build bench -Dbench-filter=reed_solomon # coding's and cryptography's Reed-Solomon bencheszig build test also runs each benchmark once on its smoke inputs. For long, coverage-guided
fuzzing, run zig build test --fuzz -Doptimize=ReleaseSafe.
All of these are recorded in the coding lane decisions.
- Errors carry no payload. Their names match commonware's
Errorvariants. - Shards and checked shards borrow their bytes from the encoding's
codewordor the decoded input, instead of holding aBytesrefcount.Encoding.deinitfrees them. - Each stripe task creates its own coder and reuses it across its tiles. Commonware caches one encoder and decoder per thread.
- The engine is chosen at compile time (
DefaultEngine = Simd, which isScalarwithout AVX2 or NEON) instead of by runtime CPU detection. Every engine produces identical bytes. Chunk.write_bufspushes the shard bytes as their own chunk forruntime.iobuf.encode_iobufs.