Engineering

Why We Chose Blake3 Over SHA-256

ByEngineering TeamDecember 20, 20248 min read
════════════════════════════════════════════════════════════════════════════════
Blake3 Merkle Tree Visualization
Fig 2.0 — Merkle Tree Hashing

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:

Benchmark: 1 GB File Hash (AMD Ryzen 9, 16 cores)
Blake3 (Astral)14.0 GB/s
~71 ms
Blake3 (single thread)4.2 GB/s
~238 ms
SHA-2562.0 GB/s
~500 ms
SHA-1 (Git)1.5 GB/s
~667 ms

Why Merkle Trees Matter

Blake3's Merkle tree design isn't just about parallelism—it enables powerful features:

Incremental Updates

When a file changes, we only need to re-hash the affected chunks. For a large file with a small edit, this can mean rehashing kilobytes instead of gigabytes.

Verified Streaming

We can verify data as it arrives over the network, chunk by chunk. No need to download an entire file before checking its integrity.

Proof of Inclusion

Merkle proofs allow us to verify that a specific chunk belongs to a larger object without having the entire object—useful for partial clones and sparse checkouts.

The Security Argument

Some might argue that SHA-256 is "more proven" than Blake3. This is a fair concern, so let's address it directly:

  • Blake3 is based on Blake2, which has been extensively analyzed since 2012
  • The core permutation is derived from ChaCha, used in TLS and SSH
  • The design is conservative, with large security margins
  • The specification and reference implementation are public domain

We're confident that Blake3 provides the security level we need, while delivering dramatically better performance.

Implementation Details

Astral uses the official Blake3 implementation in Go, which includes:

  • SIMD optimizations for x86-64 (AVX2, AVX-512)
  • NEON optimizations for ARM64
  • Automatic parallelization across CPU cores
  • Pure Go fallback for maximum portability

Conclusion

Choosing Blake3 wasn't a difficult decision once we ran the benchmarks. It's faster, more secure than SHA-1, and its Merkle tree design aligns perfectly with VCS requirements. Sometimes, newer really is better.

The performance improvements from Blake3 cascade through everything Astral does. Status checks are faster. Commits are faster. Clones are faster. And we get all of this while maintaining strong cryptographic guarantees.

— The Engineering Team

─────────────────────────────────────