@shelby-protocol/clay-codes-ffi
v0.2.4
Published
Native Node.js bindings for the Clay erasure codec via [koffi](https://github.com/Koromix/koffi) and `libclay_ffi.so`.
Readme
@shelby-protocol/clay-codes-ffi
Native Node.js bindings for the Clay erasure codec via koffi and libclay_ffi.so.
Use @shelby-protocol/clay-codes for WASM (browser and Node). Install this package only when you need the native FFI backend on Linux.
Requirements
- Linux x86_64
- Optional:
CLAY_LIB_PATHto override the bundled shared library
Published npm packages include four ISA flavors (baseline, avx2, avx2-sha, avx512 under native/linux-x64/). The loader picks the best match at runtime using the same rules as docker/select-clay-ffi.sh. avx2-sha covers hosts with the SHA extensions but no AVX-512, such as AMD Zen and Intel Goldmont+.
For development from the Shelby repo, you can still build libclay_ffi.so with make or ./scripts/build-clay-ffi-flavors.sh.
Install
npm install @shelby-protocol/clay-codes-ffi @shelby-protocol/clay-codesUsage
import { createEncoder, createDecoder } from '@shelby-protocol/clay-codes-ffi';
const encoder = await createEncoder({
n: 16,
k: 10,
d: 13,
chunkSizeBytes: 1_048_576,
});Types and helpers (flattenSystematic, EncoderOptions, etc.) are re-exported from @shelby-protocol/clay-codes.
Benchmark CLI
pnpm exec clay-bench encode input.bin ./chunks --backend ffi