When we set out to build Astral, one of our first architectural decisions was choosing a hash function. It might seem like a minor detail, but in a version control system, hashing is foundational. Every object, every commit, every piece of data flows through this algorithm. Get it wrong, and you're building on sand.
The Legacy Problem
Git uses SHA-1, a hash function designed in 1995 by the NSA. At the time, it was considered cryptographically secure. Things have changed.
In 2017, researchers demonstrated the first practical SHA-1 collision—two different files producing the same hash. While Git has implemented mitigations, the fundamental weakness remains. More practically, SHA-1 is slow.
Our Requirements
We needed a hash function that was:
- Fast: Hashing should never be the bottleneck
- Secure: 256-bit security level minimum
- Parallel: Takes advantage of modern CPUs
- Incremental: Can hash streaming data efficiently
- Portable: Works across all platforms
The Candidates
We evaluated several options:
SHA-256
The obvious successor to SHA-1. It's secure, well-understood, and widely implemented. But it's still fundamentally a 1990s design, optimized for hardware that no longer exists. On modern CPUs, SHA-256 runs at roughly 2 GB/s—respectable, but far from optimal.
SHA-3 (Keccak)
The latest NIST standard. It's theoretically elegant but was designed primarily for hardware implementation. On software, it's often slower than SHA-256.
Blake3
A 2020 hash function designed by a team that includes cryptographers from the Zcash Foundation. Blake3 is:
- 7x faster than SHA-256 on single threads
- Highly parallel: scales linearly with cores
- Merkle tree based: perfect for incremental hashing
- 256-bit secure: no known weaknesses
The Benchmarks
We ran extensive benchmarks across different hardware. Here are the results hashing a 1 GB file:
