perf: Amortise cost of make_secret
for RandomWyHashState
#12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a performance optimisation for
fully_randomised_wyhash
, where new random secrets are instead generated once per runtime and then reused for allRandomWyHashState
s. EachRandomWyHashState
will still have unique/random seeds, just that the secret is now shared. While this reduces the security/entropy between each instance, it shouldn't matter as it is unlikely if ever that different hashers are being compared directly against each other. As long as the secret is new per runtime, this should be sufficient to avoid DOS/prediction attacks. However, if one really desires that extra assurance, I've mademake_secret
public as well as methods to accept a secrets array.Providing this optimisation requires the MSRV to be raised to
1.70.0
, and also requires the featurefully_randomised_wyhash
to be forstd
only.make_secret
beingpub
now plus additional methods should allow forno_std
use-cases to still be considered, though it is up to the user to ensure it is used correctly.Closes #11