DEV Community

Jodhi
Jodhi

Posted on • Edited on

BLAKE3 Go Libraries simple comparison

Official Go Library for BLAKE3 is not available at the time of this post.

But, we have two alternative:
github.com/lukechampine/blake3
A pure Go implementation of the BLAKE3 cryptographic hash function

github.com/zeebo/blake3
Pure Go implementation of BLAKE3 with AVX2 and SSE4.1 acceleration

CPU used: intel i7-8550U

Simple benchmark code

package main

import (
    "bytes"
    "encoding/hex"
    "fmt"
    "testing"

    zeeboBLAKE3 "github.com/zeebo/blake3"
    lukechampineBLAKE3 "lukechampine.com/blake3"
)

var longBytes = bytes.Repeat([]byte("A"), 1000000)

func benchmarkLukechampine(b *testing.B) {
    for i := 0; i < b.N; i++ {
        hasher := lukechampineBLAKE3.New(32, nil)
        hasher.Write([]byte(longBytes))
        hex.EncodeToString(hasher.Sum(nil))
    }
}
func benchmarkZeebo(b *testing.B) {
    for i := 0; i < b.N; i++ {
        hasher := zeeboBLAKE3.New()
        hasher.Write([]byte(longBytes))
        hex.EncodeToString(hasher.Sum(nil))
    }
}

func main() {
    fmt.Println("lukechampine 1st test:", testing.Benchmark(benchmarkLukechampine))
    fmt.Println("zeebo 1st test:", testing.Benchmark(benchmarkZeebo))
    fmt.Println("lukechampine 2nd test:", testing.Benchmark(benchmarkLukechampine))
    fmt.Println("zeebo 2nd test:", testing.Benchmark(benchmarkZeebo))
}

The result

lukechampine 1st test:      577    2171834 ns/op
zeebo 1st test:     4146        302500 ns/op
lukechampine 2nd test:      532    2282167 ns/op
zeebo 2nd test:     3448        331177 ns/op

Performance wise, the zeebo lib is faster. This benchmark is still limited since other resources not taken into consideration. If you guys want to try BLAKE3 hasher online or generate fancy text. Thank you.

Top comments (1)

Collapse
 
finale_f0e1 profile image
Finale

I've got opposite results:

lukechampine 1st test:    11245     105725 ns/op
zeebo 1st test:     4268            249835 ns/op
lukechampine 2nd test:    10000     106014 ns/op
zeebo 2nd test:     4334            246182 ns/op
Enter fullscreen mode Exit fullscreen mode

My hardware and software:

CPU: Intel Xeon W-2135
RAM: 128 GB ECC
OS: Linux Fedora 42
Go: go1.24.3 linux/amd64
go.mod content/versions:

go 1.24.3

require (
    github.com/zeebo/blake3 v0.2.4
    lukechampine.com/blake3 v1.4.1
)

require (
    github.com/klauspost/cpuid/v2 v2.2.10 // indirect
    golang.org/x/sys v0.33.0 // indirect
)
Enter fullscreen mode Exit fullscreen mode