/** * utils/crc32.ts — checkpoint integrity (CRC-32) + a backward-compatible trailer. * * Checkpoints had no integrity check: a truncated or bit-rotted `.bin` would * either throw deep in the parser or, worse, load corrupt weights silently. This * adds a standard IEEE CRC-32 and a self-describing trailer that callers append * on export and verify on load. * * The trailer is appended AFTER the existing payload as `[magic u32][crc u32]` * (8 bytes, little-endian). Because every checkpoint reader consumes a * length-bounded payload (header declares element counts) and ignores trailing * bytes, an old reader still loads a trailer-bearing file — the trailer is * purely additive. The CRC covers the payload bytes only (everything before the * trailer). */ /** Trailer sentinel: 'EVCR' (Evermind CRc), little-endian uint32. */ export declare const CRC_TRAILER_MAGIC = 1380144709; /** IEEE CRC-32 of a byte buffer, returned as an unsigned 32-bit number. */ export declare function crc32(bytes: Uint8Array): number; /** Return a new ArrayBuffer = `payload` followed by the CRC trailer. */ export declare function appendCrcTrailer(payload: ArrayBuffer): ArrayBuffer; export interface CrcCheck { /** True when a recognised CRC trailer is present. */ hasTrailer: boolean; /** True when no trailer is present, or the trailer's CRC matches the payload. */ ok: boolean; /** The payload with any trailer stripped (safe to parse). */ body: ArrayBuffer; } /** * Inspect a buffer for a CRC trailer. When present, verifies the CRC over the * preceding payload. When absent (legacy file), reports `ok: true` and returns * the buffer unchanged — so verification is opt-in by the writer, never a * hard requirement that would reject pre-CRC checkpoints. */ export declare function verifyCrcTrailer(buffer: ArrayBuffer): CrcCheck; //# sourceMappingURL=crc32.d.ts.map