Compression dictionary
A compression dictionary supplies reusable prior content or coding state that an encoder and decoder use to represent data more compactly.
Zstandard accepts raw-content and formatted dictionaries. A zero ZSTD_getDictID_fromFrame result can mean no dependency, omitted ID, insufficient bytes or invalid input; it does not prove independence. [1]
Raw-dictionary controls returned wrong bytes without a checksum; the checked version rejected that mismatch. A formatted-dictionary control retained ID 123456 with changed content: unchecked output was wrong, while changing only the ID caused rejection. A numeric ID is not a digest. [2]
In liblz4 1.9.4, the dictionary API uses supplied bytes without comparing their identity to the frame ID. Different or omitted IDs decoded correctly with the same bytes; block-only checks allowed wrong-dictionary output. [3] [4] [5]
liblz4 1.9.4 retains the initialization-time dictionary pointer within a frame; a later argument does not rebind it. Mutating retained bytes can alter independent-block output. Keep bytes stable; completion clears the binding, so supply the selected dictionary again for each dependent frame. [3] [4] [5]
For zlib, DICTID is Adler-32 over the preset dictionary; the trailer checks decoded content. The API requires the original dictionary. A constructed control completes with three wrong output bytes despite both checks passing: a designed collision, not a failure-rate estimate or codec defect. Bind exact dictionary and intended output to trusted metadata; a digest needs a trusted reference. [6] [7] [8]
Relations
- related
- Zstandard, Backup manifest, Restore test, Cryptographic hash function, Zstandard dictionary ID, LZ4 frame, Block-independent compression, Virtual eXecutable Archive, Lossless compression, FSST, Re-Pair compression, Tunstall coding, Byte-pair encoding, LZ78, LZW, Adler-32
Citations
- Zstandard v1.5.7 API manual: dictionary identification and decompression
- Hesela: Compressed archives, dictionary dependencies and validation coverage
- LZ4 v1.9.4 frame API: dictionary identification and memory lifetime
- LZ4 v1.9.4 implementation: frame Dict-ID parsing and LZ4F_decompress_usingDict
- Hesela: LZ4 frame checks, dictionary selection and completion
- RFC 1950: zlib DICTID, decoded Adler-32 and checksum recurrence, sections 2.2 and 9
- zlib 1.3.1 manual: deflateSetDictionary and inflateSetDictionary
- Hesela: eight designed zlib dictionary checksum controls, frozen inputs and replay
Sources & caveats
- Separate raw-content and formatted-dictionary experiments use deliberate dependency mutations on one CLI build, not a measured field-failure rate or naturally occurring ID/hash collision.
- The LZ4 supplement is a distinct one-build API experiment; its Dict-ID behavior must not be inferred from Zstandard's formatted-dictionary checks.
- A separate 16-case two-block lifecycle supplement deliberately replaces an argument or mutates retained bytes. Allocations remain live; no use-after-free, concurrency, performance or field-rate result is claimed.
- Ten synthetic multi-frame controls use the same dictionary across data frames; skipped metadata is outside the payload-only acceptance rule. No cross-dictionary switching or wrapper-wide behavior is inferred.
- The zlib supplement retains an unchanged 45-byte stream and a deliberately checksum-preserving dictionary substitution. Eight controls run through C, Python and Node; these are not independent random trials, and C/Python use the same system library.