jaybaird / python-bloomfilter

Scalable Bloom Filter implemented in Python
MIT License
1.62k stars 330 forks source link

HMAC enabled Bloom filter and Scalable Bloom Filter #15

Open AmritKumar opened 10 years ago

AmritKumar commented 10 years ago

Provides an HMAC extension to the existing implementation. The filters now also have the possibility to use keyed hash functions.

jaybaird commented 10 years ago

My guess is you're trying to do something similar to what is outlined here? – https://www.uni-due.de/~hq0215/documents/Draft_Ottawa_Bloom.pdf

A couple of things are sticking out to me immediately:

  1. hashmac should be a boolean since it's a flag. But, this might be mitigated by...
  2. I'm thinking this functionality should be a subclass of the filter itself instead of a flag, e.g. HMACBloomFilter, etc.

What do you think?

AmritKumar commented 10 years ago

Basically, one would wish to use hmac instead of hash function in a scenario where only specific entities have the right to insert elements in the filter or check for belonging in it. To this end, the entities may share a common secret key and generate hmac for each item. Similarly checking for belonging would require ownership of the key. Such a filter may prevent Denial-of-service attacks against certain services.

Indeed, a more cleaner code would be to create a subclass HMACBloomFilter which would have an attribute key.