The zlib-rs project leads a shift toward memory-safe compression software at the core of modern computing.

The Trifecta Tech Foundation has launched an ambitious initiative to rewrite some of the world’s most widely used compression libraries in Rust. With a strong focus on memory safety, the project aims to replace traditional C implementations without compromising performance or compatibility.

Safer Compression: From zlib to zstd

The libraries selected for transformation include zlib, zstd, bzip2, and xz — all essential components of protocols, compressed file systems, backup tools, and packaging formats.

At the core of the initiative is zlib-rs, a Rust-based implementation of the popular zlib format. It offers a secure and API-compatible solution for both Rust and C projects. The team has also built libz-rs-sys, a dynamic library compatible with legacy zlib applications that do not yet support Rust.

The first significant integration of zlib-rs took place in April 2024, when it was included as a backend in the widely used flate2 Rust crate. In November, zlib-rs passed a rigorous audit conducted by the Internet Security Research Group (ISRG), further validating its readiness for production.

bzip2 and c2rust: A Pragmatic Translation Approach

Following zlib’s success, Trifecta launched bzip2-rs in October 2024. Instead of rewriting from scratch, the team used c2rust to automatically translate the original C code into Rust. While this method requires subsequent refactoring and optimization, it accelerates early development and ensures compatibility.

The new library is now available on GitHub and on crates.io, Rust’s official package registry. Its modular design allows developers to compile it purely in Rust or continue relying on system-level libbz2, depending on the project’s needs.

Up Next: xz and zstd

Trifecta is now seeking funding to expand its work to two other widely adopted tools: xz, known for its high compression ratio (albeit slower), and zstd, a modern algorithm that balances compression efficiency and speed.

The project’s long-term vision includes:

  • Matching or exceeding the performance of existing C/C++ implementations
  • Offering drop-in replacements that maintain legacy compatibility
  • Minimizing security risks through memory-safe Rust code and robust tooling
  • Delivering pure Rust implementations tightly integrated into the broader Rust ecosystem
  • Supporting modern targets such as WebAssembly and edge devices

Technical Objectives and Impact

The project also emphasizes cross-platform compilation, avoiding the need for C toolchains. By replacing legacy compression software with memory-safe alternatives, Trifecta aims to reduce the attack surface in countless applications, from embedded systems to browsers and large-scale servers.

The team has already made optimizations for WebAssembly and continues to improve the codebase through community feedback and formal audits.

Get Involved

Trifecta invites developers, tech companies, and public organizations to support the creation of a safer compression software ecosystem. The foundation offers technical support services and guidance for teams looking to migrate from traditional libraries.

Trifecta Tech Foundation proves that it’s possible to enhance compatibility, boost performance, and eliminate legacy risks—all at once—by placing Rust at the heart of critical software infrastructure.

“This is not just about replacing C code line by line — it’s about rethinking how modern infrastructure should behave. Rust offers a real opportunity to make that shift, without sacrificing performance.” — Trifecta Tech Foundation.

Compression Carcinized: Implementing zlib in Rust - Folkert de Vries

References: Trifecta foundation, zlib-rs GitHub Repository and bzip2-rs GitHub Repository

Scroll to Top