Allow seed to be specified as a string.#1863
Open
webern wants to merge 1 commit intoDataDog:mainfrom
Open
Conversation
Add a Seed newtype wrapping [u8; 32] with custom deserialization that accepts either a 32-element byte array (existing behavior) or a plain string. String seeds are hashed with SHA-256 to produce the 32 seed bytes, so "black cat" and "umbrella" each yield a unique but consistent seed without forcing users to supply raw byte arrays.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Add a Seed newtype wrapping [u8; 32] with custom deserialization that accepts either a 32-element byte array (existing behavior) or a plain string. String seeds are hashed with SHA-256 to produce the 32 seed bytes, so "black cat" and "umbrella" each yield a unique but consistent seed without forcing users to supply raw byte arrays.
Motivation
Sorry this is a bit of a drive-by PR. But I noticed we keep copying the same array over and over, basically always using the same seed, because we are too lazy to edit those u8s. A colleague suggested maybe they would open a PR to maybe make it possible to just bloop a string there and have it hashed stably, so I scooped him and opened a PR.
Related issues
It just makes it easier to bloop your stable seed when copying a lading config.