3 ms·
You could just keep hashing until you have enough non-colliding outputs, throwing away any collisions. This is sound as far as I can tell. Relatedly, mapping r
by marcan_42 6y ago
You could just keep hashing until you have enough non-colliding outputs, throwing away any collisions. This is sound as far as I can tell.
Relatedly, mapping real hash functions to bits is also nontrivial to get 100% mathematically correct. As far as I know, the only sound way for hash functions with a fixed number of output bits and a non-power-of-two bloom filter is to truncate to the next power of two, then throw away any results that overflow the filter size and keep trying with new hashes (or repeated hashing). This is thus easy to integrate with avoiding duplicate bits, since you're retrying anyway.
In practice, none of this matters, you can just take a hash output with enough extra bits modulo the Bloom filter size and call it a day. It'll be close enough to uniformly random and non-colliding anyway, for practical filters.