Bloom Filter
A compact probabilistic filter used by older light clients to ask peers for possibly relevant transactions.
Basically
A bloom filter is a tool used by lightweight Bitcoin wallets to request relevant transactions. It was designed to avoid revealing addresses, but Bitcoin's version still leaked address information.
Key Takeaways
- A bloom filter is a space-efficient probabilistic data structure that can tell you an element is "definitely not in a set" or "possibly in a set," producing false positives but never false negatives.
- Bitcoin's BIP 37 used bloom filters to let SPV clients request only relevant transactions from full nodes, but this approach leaked wallet addresses to connected peers.
- Compact block filters (BIP 157/158) replaced bloom filters as the preferred light client approach by moving filtering to the client side, eliminating the privacy leak entirely.
What Is a Bloom Filter?
A bloom filter is a probabilistic data structure invented by Burton H. Bloom in 1970, and it answers a simple question: "Is this element in the set?" The answer is either "definitely no" or "probably yes." The one-sided certainty makes bloom filters useful wherever fast, space-efficient set membership testing matters more than absolute precision.
Bitcoin introduced bloom filters through BIP 37 (2012) to help lightweight wallets sync with the network without downloading every transaction. An SPV client would construct a bloom filter containing its wallet addresses and send it to a full node, which would then relay only matching transactions. The approach worked but came with a critical flaw: the filter itself revealed which addresses the client cared about, undermining user privacy.
How It Works
A bloom filter consists of a bit array of m bits, all initially set to 0, and k independent hash functions. Each hash function maps an input to one of the m positions in the array.
Inserting Elements
You can add an element to the filter by passing it through all k hash functions. Each function returns a position in the bit array. Set every returned position to 1.
Querying Elements
You can test whether an element is in the set by hashing it with the same k functions. Then check the corresponding bit positions.
False Positive Rate
The probability of a false positive after inserting n elements into an m-bit filter with k hash functions is approximately given by a formula. That formula uses n, m and k.
A bloom filter requires only about 9.6 bits per element at a 1% false positive rate, regardless of element size. This extreme space efficiency made bloom filters attractive for bandwidth-constrained SPV clients. Storing thousands of Bitcoin addresses, each 20+ bytes, requires only a few kilobytes of filter data.
Bloom Filters in Bitcoin (BIP 37)
BIP 37, authored by Mike Hearn and Matt Corallo in October 2012, added bloom filter support to the Bitcoin peer-to-peer protocol. The goal was to let SPV clients receive only wallet-relevant transactions instead of downloading every transaction in every block.
BIP 37 Protocol Messages
BIP 37 used MurmurHash3 (32-bit) for its hash functions. Each function was seeded by the formula nHashNum * 0xFBA4C795 + nTweak, where nTweak is a random value chosen by the client.
The Privacy Problem
BIP 37 reduced bandwidth for light clients but introduced a severe privacy leak. A full node receiving a bloom filter can test candidate addresses against it to determine which addresses belong to the client. With the low false positive rates used by real wallets, the filter effectively broadcast the client's entire address set to any connected peer.
Research Findings
A 2014 paper by Gervais, Karame, Gruber, and Capkun, "On the Privacy Provisions of Bloom Filters in Lightweight Bitcoin Clients," ACSAC 2014, demonstrated that an SPV client using fewer than 20 Bitcoin addresses risked revealing almost all of them to any connected full node. With just 10 addresses in the filter, the probability of correctly identifying them was approximately 0.99.
Researcher Jonas Nick analysed BitcoinJ in 2015, when it was the most widely used SPV library, powering Android Wallet and MultiBit. He found that BitcoinJ included both public keys and public key hashes in its bloom filter, reducing the effective false positive rate to approximately 0.0000000213; a fresh wallet with 271 public keys produced roughly one false positive when scanned against the entire blockchain, meaning nearly every address could be identified. His conclusion was that SPV users had "practically zero wire privacy."
Three Attack Vectors
These weaknesses led Bitcoin Core to disable BIP 37 bloom filter serving by default in version 0.19.0 (November 2019). The cited reasons were both the privacy problems and denial-of-service risks, as processing bloom filters is CPU-intensive and could be weaponised against nodes.
The Replacement: Compact Block Filters
BIP 157/158, authored by Olaoluwa Osuntokun, Alex Akselrod, and Jim Posen in 2017, took the opposite approach to light client filtering. Instead of clients sending filters to servers in server-side filtering, full nodes generate deterministic filters for each block and clients download and test them locally in client-side filtering.
Compact block filters use Golomb-Rice coded sets instead of bloom filters, achieving better compression, and the basic filter type has a false positive rate of approximately 1 in 784,931. When a filter matches, the client downloads the full block from any peer; the total monthly bandwidth for downloading all filters is approximately 70 MB. The Bitcoin light clients and SPV explained research article offers a deeper look at how SPV clients evolved.
Other Uses in Bitcoin
Bitcoin Core also uses rolling bloom filters internally beyond BIP 37. They optimise transaction relay.
These internal uses are separate from BIP 37. They do not expose filters to external peers, avoiding the privacy issues that plagued SPV bloom filtering.
Why It Matters
The bloom filter story in Bitcoin is a case study in the tension between efficiency and privacy. BIP 37 solved a real problem: mobile wallets needed a way to sync without downloading the entire blockchain. But the solution leaked enough information that researchers could identify wallet addresses with near-certainty.
The replacement, compact block filters, trades slightly more bandwidth for genuine privacy. The same design philosophy carries forward into modern Bitcoin layer-2 protocols: solutions like Spark prioritise both efficiency and privacy, using techniques like FROST threshold signatures to avoid exposing sensitive information while keeping operations lightweight.
False Positives Are Unavoidable
Any bloom filter will occasionally report that an element is in the set when it is not. Applications where false positives have consequences, such as triggering unnecessary block downloads, must size the filter carefully. Reducing the false positive rate requires more bits per element, increasing memory and bandwidth costs.
No Deletion Support
Standard bloom filters are append-only, and once a bit is set to 1, it cannot be cleared without rebuilding the entire filter. BIP 37 reflected this limitation: there was a filteradd command but no filterremove. Variants like counting bloom filters support deletion but require more memory.
Privacy Remains a Concern for Legacy Clients
Bitcoin Core disabled BIP 37 by default in 2019, but some older nodes still serve bloom filter requests with the -peerbloomfilters=1 option enabled, so SPV wallets that still rely on BIP 37 continue to leak address information to connected peers. Users concerned about privacy should use wallets that support compact block filters (BIP 157/158) or connect to their own full node. The glossary entry is for informational purposes only and does not constitute financial or investment advice; always do your own research before using any protocol or technology.