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

BLAKE3 Hashing over 32 -bytes Input #563

Merged
merged 8 commits into from
Nov 30, 2022

Conversation

itzmeanjan
Copy link
Contributor

Along with 64 -bytes input, we can also hash 32 -bytes message, using BLAKE3.

Cost of hashing 32 -bytes: 4820 -cycles.

Note
Cost of hashing 64 -bytes is lower ( i.e. 4806 -cycles ) because in case of 32 -bytes message one needs to pad input with zeros to make it 64 -bytes, which is BLAKE3 block size. Read more about padding rule here.

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
…hashing

Now cost of blake3 hashing over 32 -bytes input: 4820 -cycles

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
@Dominik1999
Copy link
Contributor

Does that mean it would also be faster to use the 64-bytes implementation for a hashchain instead of the 32-bytes?

@itzmeanjan
Copy link
Contributor Author

Does that mean it would also be faster to use the 64-bytes implementation for a hashchain instead of the 32-bytes?

64 -bytes input case is cheaper in terms of VM cycles, which can prove to be faster in execution time, if hashchain is fairly long enough. Though it calls for much larger input to hashchain routine.

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you! I left a few small comments inline.

miden/tests/integration/stdlib/crypto/blake3.rs Outdated Show resolved Hide resolved
miden/tests/integration/stdlib/crypto/blake3.rs Outdated Show resolved Hide resolved
stdlib/asm/crypto/hashes/blake3.masm Outdated Show resolved Hide resolved
stdlib/asm/crypto/hashes/blake3.masm Outdated Show resolved Hide resolved
Following suggestion 0xPolygonMiden#563 (comment)

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
@itzmeanjan
Copy link
Contributor Author

itzmeanjan commented Nov 30, 2022

At commit ae4258a

Routine VM Cycles
Blake3 2-to-1 hashing 4798
Blake3 1-to-1 hashing 4812

@itzmeanjan
Copy link
Contributor Author

Looks good! Thank you! I left a few small comments inline.

Thanks for the review. Can you please take a look once again ?

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
@itzmeanjan
Copy link
Contributor Author

Resolved merge conflict 34e9e3c

itzmeanjan added a commit to itzmeanjan/miden that referenced this pull request Nov 30, 2022
Following suggestions from 0xPolygonMiden#563 (comment)

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

All looks good! Thank you!

@itzmeanjan itzmeanjan merged commit 6c3a4f6 into 0xPolygonMiden:next Nov 30, 2022
@itzmeanjan itzmeanjan deleted the blake3-32B branch November 30, 2022 15:40
bobbinth pushed a commit that referenced this pull request Dec 10, 2022
Following suggestion #563 (comment)

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
bobbinth pushed a commit that referenced this pull request Dec 10, 2022
See #563 (comment)
Also see #563 (comment)

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
bobbinth pushed a commit that referenced this pull request Dec 10, 2022
Following suggestions from #563 (comment)

Signed-off-by: Anjan Roy <hello@itzmeanjan.in>
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.

3 participants