golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.84k stars 17.51k forks source link

x/crypto: add BLAKE3 support #36632

Open dsseng opened 4 years ago

dsseng commented 4 years ago

What version of Go are you using (go version)?

$ go version
go version go1.13.5 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/sh7dm/.cache/go-build"
GOENV="/home/sh7dm/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/sh7dm/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build981542473=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I found a new cryptographical hash function named BLAKE3: https://github.com/BLAKE3-team/BLAKE3 It also has Go implementation: https://github.com/lukechampine/blake3

What did you expect to see?

BLAKE3 support in Go

What did you see instead?

No BLAKE3 support in Go

dsseng commented 4 years ago

I can integrate https://github.com/lukechampine/blake3 in x/crypto

ALTree commented 4 years ago

Hi,

No BLAKE3 support in Go

There is support for BLAKE3 in Go. It's here: https://github.com/lukechampine/blake3 . You can download the library using go get and use it in your projects.

I can integrate https://github.com/lukechampine/blake3 in x/crypto

I don't think you can, unless the code author(s) sign the CLA and agree to re-license the code (it's MIT, I don't know if it's compatible with Go's BSD licence). In any case it's not as simple as "copy the code in lukechampine/blake3, and paste it in x/crypto".

What you are asking is for a (semi)-officially supported BLAKE3 implementation in x/crypto. This is a fair request, but someone will have to do the work and maintain the code in the future. Is not as simple as dumping another implementation in x/crypto and leaving it there.

dsseng commented 4 years ago

Sure, all of this should be allowed by owner of repo, but we can just import and export the module from x/crypto

lukechampine commented 4 years ago

I'd be happy to transfer my package over to x/crypto. It could really use an asm implementation, and perhaps being "blessed" by Google will motivate someone to contribute one. However, BLAKE3 is very new -- AFAIK, no one has published a proper cryptanalysis or an attack yet. So we probably want to wait for more scrutiny before adding it.

dsseng commented 4 years ago

Oh, hello! I vote for adding it now, but of course it's for the decision on Go developers. I'm really happy that you're interested in improving standard libs too!

oconnor663 commented 4 years ago

https://github.com/zeebo/blake3 was published recently under CC0, with optimized AVX2 and SSE4.1 implementations.

sargun commented 3 years ago

It's been about a year since this was last discussed. Have there been any more thoughts?

lukechampine commented 3 years ago

Well, I have an update on my previous comment:

It could really use an asm implementation, and perhaps being "blessed" by Google will motivate someone to contribute one.

I've since added (avo-generated) asm for AVX2 and AVX-512 myself, so performance should be at least competitive with zeebo/blake3 and the official Rust implementation (I haven't benchmarked it on a proper desktop machine yet).

LorenzoZaccagnini commented 1 year ago

any update?