Skip to main content

Crate rlnc_simdx

Crate rlnc_simdx 

Source
Expand description

§rlnc-simdx — Random Linear Network Coding over GF(2⁸)

High-performance, no_std-compatible RLNC implementation with maximum SIMD acceleration across all major architectures.

Crate: rlnc-simdx · use as use rlnc_simdx::....

§⚠️ Security & cryptography warning

This is a network-coding acceleration library, not a cryptography library.

  • Do not use it to “encrypt” or obfuscate confidential data.
  • Field arithmetic is not constant-time — no side-channel resistance.
  • Built-in SimpleRng is a fast LFSR for coding coefficients, not a CSPRNG.
  • Authenticate and protect coded packets with external crypto (TLS, AEAD, etc.).

§Kernel safety (public API)

  • kernel::axpy / kernel::scale: equal lengths and non-overlapping buffers are asserted in release (cheap pointer-range check).
  • For in-place scale use kernel::scale_inplace.
  • Raw SIMD tier functions are crate-private; only the safe wrappers above are part of the supported public surface.

§SIMD Tier Hierarchy

With std, the library selects the best available kernel at runtime and caches that choice. Without std, it selects from compile-time target features.

TierFeature flagsWidthThroughput
1GFNI + AVX-512BW512-bit~64 B/cy
2GFNI + AVX2256-bit~32 B/cy
3GFNI + SSE4.2128-bit~16 B/cy
4AVX-512BW + SSSE3512-bit~11 B/cy
5AVX2 + SSSE3256-bit~5 B/cy
6SSSE3128-bit~3 B/cy
7NEON (AArch64)128-bit~3 B/cy
8WASM SIMD128128-bit~3 B/cy
9Scalar (all targets)1 byte~0.3 B/cy

SVE is experimental, has no production kernel, and is not selected by dispatch.

§Feature Flags

FlagDefaultEffect
alloconEnables heap-backed RLNC APIs and GfMatrix
stdonEnables runtime CPU dispatch; implies alloc
bench-internalsoffUnstable scalar/direct-tier benchmark APIs

§Quick Start

use rlnc_simdx::{Encoder, Decoder, SimpleRng};

let k = 4;   // generation size (number of source symbols)
let n = 128; // symbol size (bytes)

// Source data
let source: Vec<Vec<u8>> = (0..k).map(|i| vec![i as u8; n]).collect();
let refs: Vec<&[u8]> = source.iter().map(|v| v.as_slice()).collect();

// Encode
let enc = Encoder::new(k, n).unwrap();
let mut rng = SimpleRng::new(42);
let packets: Vec<_> = (0..k+2)
    .map(|_| enc.encode_random(&refs, &mut rng).unwrap())
    .collect();

// Decode
let mut dec = Decoder::new(k, n).unwrap();
for pkt in packets {
    dec.receive(pkt).unwrap();
    if dec.is_complete() { break; }
}
let decoded = dec.decode().unwrap().unwrap();
assert_eq!(decoded[0], source[0]);

Re-exports§

pub use error::RlncError;
pub use field::Gf8;
pub use aligned::AlignedBuffer;
pub use decoder::Decoder;
pub use encoder::CodedPacket;
pub use encoder::Encoder;
pub use encoder::SimpleRng;
pub use matrix::GfMatrix;
pub use recoder::Recoder;

Modules§

aligned
Aligned memory buffer — 64-byte aligned heap storage for hot paths.
decoder
RLNC Decoder — in-place pivot-based Gaussian elimination over GF(2⁸).
encoder
RLNC Encoder — produces random linear coded packets over GF(2⁸).
error
Error types for the rlnc-simdx crate.
field
GF(2⁸) finite field arithmetic.
kernel
Kernel dispatch layer — safe public API + runtime CPU feature detection.
matrix
GF(2⁸) matrix — row-major layout, 64-byte aligned backing store.
recoder
RLNC Recoder — re-encodes already-coded packets into new coded packets.

Functions§

active_kernel
Returns the name of the SIMD kernel tier active for this build.