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

Replace SHA-512 hashing function with the ~10 times faster BLAKE3. #2530

Open
wants to merge 13 commits into
base: py3
Choose a base branch
from
Open

Replace SHA-512 hashing function with the ~10 times faster BLAKE3. #2530

wants to merge 13 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 13, 2020

blake3

BLAKE3 is a cryptographic hash function that is:

  • Much faster than MD5, SHA-1, SHA-2, SHA-3, and BLAKE2.
  • Secure, unlike MD5 and SHA-1. And secure against length extension,
    unlike SHA-2.
  • Highly parallelizable across any number of threads and SIMD lanes,
    because it's a Merkle tree on the inside.
  • Capable of verified streaming and incremental updates, again
    because it's a Merkle tree.
  • A PRF, MAC, KDF, and XOF, as well as a regular hash.
  • One algorithm with no variants, which is fast on x86-64 and also
    on smaller architectures.

The chart below shows BLAKE3's performance on modern server hardware, an Intel Cascade
Lake-SP 8275CL processor:

speed

BLAKE3 paper: https://github.com/BLAKE3-team/BLAKE3-specs/blob/master/blake3.pdf


This is my last attempt to contribute to this repository and the third time I changed the requirements.txt to include only gevent>=1.4.0! If this pull request is not going to be merged than this is going to be fastest fork of "ZeroNet". For that matter I going to rename it and will be not called "ZeroNet" anymore!

I would like to give a huge thanks to @imachug and @filips123 for they great and hard work on this software, keep up the good work guys! 🤗

I wish that not @HelloZeroNet (@shortcutme) owns this repository. 😢 It would be in better hands with @imachug for example. @imachug is way more respectful and active than the current "owner" 😡.

@ghost ghost changed the title Replace SHA-512 hashing function with the ~100 times faster BLAKE3. Replace SHA-512 hashing function with the ~10 times faster BLAKE3. Apr 13, 2020
@purplesyringa
Copy link
Contributor

Performance is a problem for ZeroNet given that it's written in Python. Hashes are checked really often (see a recent "Eternal Word" issue), so making them faster is important. BLAKE3 looks like a good alternative, but changing the hash function without backward compatibility is wrong. We could add both blake3 and sha512 fields when signing and check blake3 on new versions and sha512 on old versions on verifying.

@ghost
Copy link
Author

ghost commented Apr 13, 2020

@imachug I'm not in favor of backward compatibility, at least not creating or signing sites with sha512. Downloading the content which hashed by sha512 is enough.
Creating, signing new content should be hashed using blake3.

                else:  # Backward compatibility
                    hash_type = "sha1"

until now this ☝️ was in ContentManager.py and turned out that is useless, so I removed. Adding back sha512 instead of sha1 will still fail. There was no backward compatibility at all using this code.

At this point I see that this is going to be the fastest fork of ZeroNet. The @HelloZeroNet repository comes not even close to the speed of this fork with blake3.

peer-to-peer-network added 4 commits April 15, 2020 16:27
No need for "- ZeroNet_" in title
Everyone should resign they sites, no need for backward compatibility. 🙄
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.

1 participant