Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull in code for BLAKE2b hash function #9

Merged
merged 5 commits into from
Jul 2, 2019
Merged

Pull in code for BLAKE2b hash function #9

merged 5 commits into from
Jul 2, 2019

Conversation

pdyraga
Copy link
Member

@pdyraga pdyraga commented Jul 1, 2019

Refs: #2
Closes: #4

In this PR we pull in the code for BLAKE2b hash from golang.org/x/crypto. This will allow us to add BLAKE2b hash precompile (see https://github.com/ethereum-cat-herders/PM/issues/64) - if needed - using the same library as the one we use in go-ethereum for F compression function precompile.

Having all the official test vectors for BLAKE2b here allowed getting rid of the autogenerated test vectors for F compression function. I left just a couple of them and added a code transforming them to the same test vector format as the one used in go-ethereum precompile tests.

The F compression function is placed in a separate package so that we can pull only this function from go-ethereum with govendor.

The code and test vectors of Blake2B checksum have been pulled in to
this library. It will allow us to define precompiles for Blake2b
checksums, if needed. Additionally, we can now test against vectors from
RFC instead of autogenerating vectors just for F.

I have also modified F implementation removing the loop over block
content. According to the RFC, this loop is not a part of F function -
see `blake2b_update` C function in the RFC for reference.
All our test vectors for F functions are autogenerated. Since we now
test entire checksum, we do not need so many test vectors just for F
function.

I left less than 20 test vectors, from which we'll generate go-ethereum
test cases for F precompile.
This will let us to import only F code from projects that require only F
compression function and use govendor to manage dependencies (hello,
go-ethereum!)
@pdyraga pdyraga requested a review from mhluongo July 1, 2019 15:55
@pdyraga
Copy link
Member Author

pdyraga commented Jul 1, 2019

Hey @mhluongo can I ask you for reviewing this PR?

@mhluongo
Copy link
Member

mhluongo commented Jul 1, 2019

Also looking for another Gopher here @dimpar

@mhluongo mhluongo requested a review from dimpar July 1, 2019 21:52
Copy link
Contributor

@dimpar dimpar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't deep dive into everything, but tests and pkg reorganisation looks good to me.

@dimpar dimpar merged commit 02884c6 into master Jul 2, 2019
@dimpar dimpar deleted the hashes branch July 2, 2019 09:51
@pdyraga
Copy link
Member Author

pdyraga commented Jul 2, 2019

🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test vectors from golang Blake2b/s
3 participants