-
Notifications
You must be signed in to change notification settings - Fork 432
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
Hasher2Rng #627
Comments
After slightly more thought, there is seemingly nothing At least for probabilistic data structures that do not store any key, then our lowest level interface need only map from a borrowed key to an
Above this, you want some user friendly approach like
We've slightly more boilerplate from |
I'll close this but feel free to express opinions on my questions from my opening comment. |
You want an RNG...
... you have some unmentioned random state you wish to convert to a
You state that you don't need collision resistance, so I presume an attacker cannot control the random state used? In this case do you even need a cryptographic hash function? I have no idea what you are trying to achieve. Where does your random state come from?
I believe padding with zeros is fine so long as the 128-bit output of
I think this is vaguely what I tried to do in #554, but using Keccak is based on a sponge construction allowing variable length output and so should be straightforward to implement let mut hash = Shake128::default();
hash.process(input_data);
let mut seed = <ChaChaRng as SeedableRng>::Seed::default();
hash.xof_result().read(&mut seed);
let mut rng = ChaChaRng::from_seed(seed); |
Yes, there would be random state for DoS protection, like in the pseudocode I wrote. Also my I think #554 sounds optimal, but it'd need cryptoanalysis. Thanks! |
So you have random state, and wish to use it to seed a CSPRNG used for DoS protection. Using a hash function with variable length input and output is a convenient way to convert the input state to the required seed type — but, cryptographically, is it any stronger than converting the state via transmutation with truncation or zero-extension as required? If the same random state is used for multiple seeds, then some mechanism needs to be used to ensure each one is unique (continuing to read from the same parent RNG / extensible-output hash, or perhaps overwriting the state with hash function output). But otherwise I'm not sure that using a hash function to scramble the state actually helps. Maybe your |
Yes DoS protection. And the Yes if
|
Yes, perhaps. BTW |
We need rejection sampling in probabilistic data structures whose size is not a power of two, so maybe just using
rand
for the sampling side makes sense.We could do this in a fully cryptographic setting by using any cryptographic hash function like Blake2b that outputs a
[u8; 32]
seed forChaChaRng
, but I'm curious if anyone has a nicer scheme?Actually, we only need
SipHasher
like protection for the key, not full collision resistance, so I'm unsure about optimal primitives choices here. Thoughts?It's seemingly fine to go from
SipHasher128
toChaChaRng
by padding with either zeros or another hash key, this sounds messy.I'm also curious if there is a cleaner form for the cryptographic setting: We could
impl
ingRngCore
for some SHAKE variant. I think many Keccek variants are faster than SHA3 but I'd still kinda expect this to be slow. Is anyone aware of a nice XOF like transformation from Blake2b to ChaCha? It's likely nicer to anyone re-implementing this in another language to just seed with a[u8; 32]
, probably just as fast, but I'm curious if anyone tweaked this further.The text was updated successfully, but these errors were encountered: