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 MurmurHash3 with BLAKE3 in Hash module #96

Open
jasone opened this issue Oct 22, 2020 · 2 comments
Open

Replace MurmurHash3 with BLAKE3 in Hash module #96

jasone opened this issue Oct 22, 2020 · 2 comments
Labels

Comments

@jasone
Copy link
Contributor

jasone commented Oct 22, 2020

Replace MurmurHash3 with BLAKE3 in the Hash module. With this change, hashing is no longer susceptible to pre-image attacks, so we don't need to randomly seed hashing anymore, and it may make sense to tweak the API to no longer refer to seed when removing the seeding logic.

BLAKE3 has some parallel hashing capabilities, so add something like hash_map in addition to hash_fold to expose this parallelism.

While performing this refactor, consider whether to idiomatically incorporate type ID into the hashes, as a mechanism for reducing brittleness when serializing composite data types.

@jasone
Copy link
Contributor Author

jasone commented Feb 16, 2021

In the long run, we may want to provide a function which can compute a hash for any immutable value. This would be a somewhat magical polymorphic function, in that it would use RTTI to traverse the value's transitive closure. However, the result would be pure, and it would commonly save hashing boilerplate in applications.

module Hash: sig
    module State: sig
        type t
        module Gen: sig
            val hash_a: 'a\& -> t -> t

This feature won't be worth the trouble in the bootstrap Basis though.

@jasone
Copy link
Contributor Author

jasone commented Oct 8, 2021

Right now Basis has to specially handle u128 in order to avoid cyclical dependencies. With the conversion to BLAKE3 this special handling would instead have to be for u256. However, we can refactor the Intw functors to enable generating a subset of the normal integer API that excludes Identifiable (and therefore hashing-related APIs). A call to the more limited Intw functor can be used instead of having a duplicate implementation of the relevant functions. Such a refactor should precede conversion to BLAKE3.

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

No branches or pull requests

1 participant