GithubHelp home page GithubHelp logo

lukechampine / blake3 Goto Github PK

View Code? Open in Web Editor NEW
346.0 346.0 25.0 127 KB

An AVX-512 accelerated implementation of the BLAKE3 cryptographic hash function

License: MIT License

Go 32.13% Assembly 67.87%
blake3 hash

blake3's People

Contributors

lukechampine avatar renthraysk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blake3's Issues

go get fails due to signed shift

% go get lukechampine.com/blake3       
# lukechampine.com/blake3
../../../lukechampine.com/blake3/blake3.go:302:16: invalid operation: 1 << i (shift count type int, must be unsigned integer)

Windows binary

Dear Luke,
Could you be so kind to generate .exe for the rest of us who are mere Windows users w/o compiler?
I am eager to try b3sum implemented in Go, because @oconnor663 is in no hurry to fix Rust’s one.

How to verify the digest of the whole file when digests of file parts are known

From my reading of Blake3 paper, and my understanding of Merkle trees in general, I think this should be doable in theory: if I have Blake3 digests of parts of a file, I should be able to calculate the digest of the whole (by building the tree of digests and then getting the root). But I don't think this module's API exposes enough to make it work, or am I missing something?

NewFromDerivedKey vs NewDeriveKey

Well done getting this up so quickly! Any feedback on how the reference implementation could be improved? Any parts that were confusing? Did you happen to find Section 5.1.2 in the spec that talks about what's going on with add_chunk_chaining_value? :)

Some thoughts about this comment:

NewFromDerivedKey returns a Hasher whose key was derived from the supplied context string.

That's true, but it's also kind of an implementation detail. The intention isn't really for users to know about or think about this "context key". Instead, the word "key" in the name derive_key/new_derive_key refers to the output of the function. The intention is that the user starts with a context string and some key material, and the output is a context-specific derived subkey.

In that sense, it might make more sense to use the name NewDeriveKey or something like that? What do you think?

How to compute the Sum512 of a stream of data without fixed known length

Hello,

I’m curious to know if it’s possible to compute the hash of a data stream without knowing its length in advance, and to do this without storing the entire data in RAM. Ideally, the hash should be updated incrementally.

As a beginner, this might seem like a simple question. I understand that to compute the hash, the data needs to be divided into chunks of 1024 bytes.

To put it in simpler terms, I want to write a Hash class that has a method void HashByte(*byte). This method would take an arbitrary number of bytes as input and maintain a “partial hash” in memory, which is updated incrementally every time N bytes arrive from the stream.

Another method, byte[64] Close(void), would return the 512-bit hash as an array of 64 bytes, representing the entire received stream.

for example:

hash = New Hash()
hash.HashBytes(byte[] "This is the first array of byte.")
hash.HashBytes(byte[] " <A VERY LONG STRING>.") // Here can be added even few MiB of data
hash.HashBytes(byte[] "") //Nothing is added
hash.HashBytes(byte[] " This is the second")
hash.HashBytes(byte[] ".") // Just 1 byte is added
byte[64] result0 = hash.close()

byte[64] result1 = Sum512(byte[] "This is the first array of byte. <A VERY LONG STRING>. This is the second.")

result0 should be equal to result1

Is it possible and how can I do?

Many thanks

Support newer cpuid

Hi,

While packaging this for Debian, we have cpuid v2 in the repository and I needed to get it to compile with that version.

The patch for compatibility with cpuid v2 is simple:

--- a/cpu.go
+++ b/cpu.go
@@ -5,6 +5,6 @@
 import "github.com/klauspost/cpuid"
 
 var (
-	haveAVX2   = cpuid.CPU.AVX2()
-	haveAVX512 = cpuid.CPU.AVX512F()
+	haveAVX2   = cpuid.CPU.Supports(cpuid.AVX2)
+	haveAVX512 = cpuid.CPU.Supports(cpuid.AVX512F)
 )

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.