opencontainers / go-digest

Common digest package used across the container ecosystem
https://www.opencontainers.org/
Other
184 stars 60 forks source link

Add BLAKE3 hash function #61

Closed sargun closed 3 years ago

sargun commented 3 years ago

This adds the default BLAKE3 hash function with a default output size of 256-bit. If we want to add support for other sizes in the future, I suggest that we do something like blake3-512 or blake3_512. Given that BLAKE3 can have an arbitrary output size, I'm unsure which "variants" we should add.

sargun commented 3 years ago

See: https://github.com/opencontainers/image-spec/issues/819

vbatts commented 3 years ago

to what extent is github.com/zeebo/blake3 still being vetted? Even comparing to golang.org/x/crypto/blake2b as a more reliable option?

sargun commented 3 years ago

@vbatts that's blake2b which is != blake3. I can also add blake2b, but it's a fundamentally different hash.

sargun commented 3 years ago

We use zeebo/blake3 in prod. Blake2 doesn't have formal specifications for XOF, or a a tree hash, whereas blake3 does. IIRC, there are variants of blake2b that support XOF and tree hash, but AFAIK, they're not formalized.

vbatts commented 3 years ago

ah, i wasn't saying that "2b" and "3" were the same or equivalent. I was more commenting on how established the implementation is, for the golang team to have an implementation of blake2b that they "support", vs a community member's implementation of blake3

sargun commented 3 years ago

Please see: https://github.com/opencontainers/go-digest/pull/62

This PR can move forward if we add a "sub-module" that has the blake3 bits, and people can import that in order to get that function to register.

AkihiroSuda commented 3 years ago

Can we have blake3.go in a separate pacakge: github.com/opencontainers/go-digest/blake3

sargun commented 3 years ago

That's my plan.

vbatts commented 3 years ago

Is this still a draft?

sargun commented 3 years ago

@vbatts it's good to go. I have one small additional change of moving around the definition of the digest (name), but that can be next.

sargun commented 3 years ago

@vbatts This should be ready for review. @AkihiroSuda Changes since last time:

sargun commented 3 years ago

@AkihiroSuda Do you have any outstanding concerns?

AkihiroSuda commented 3 years ago

@dmcgowan PTAL