Tls_bloom_filter - OTP's built-in Bloom filter you probably didn't know about

Following @etnt great httpd_router post (pure OTP gems are having a moment!), here’s one more: tls_bloom_filter.erl, tucked away in lib/ssl/src/.

It powers TLS 1.3 anti-replay protection, using a rotating pair of Bloom filters to detect already-seen 0-RTT binders. But look past the TLS context and you’ll find a clean, dependency free Bloom filter with configurable hash functions, bit-array sizes, and false positive rates.

Pure Erlang. Zero deps. Already on your machine.

Between this and @etnt httpd_router, I’m starting to think we need a “Hidden Treasures of OTP” series. Who knows what else is lurking in there?

5 Likes

Just to be clear and avoid any confusion :slight_smile: , httpd_router is not part of OTP,
but perhaps it should? If it was part of OTP (it’s really just one file), then it
would be easy to quickly whip up a nice HTTP API without having to import
any dependencies; often that can be good enough (example usage can be
found in edbg which sets up an API for serving its MCP server).

3 Likes