BIP 158 Compact Block Filters
Abbreviation: BIP 158
Pronunciation: BIP one-fifty-eight kuhm-PAKT BLOK FIL-ters
Also known as: BIP158 Compact Block Filter, Compact Block Filters, BIP 158
Definition
BIP 158 defines compact block filters as a Golomb-coded set representation of selected Bitcoin block data that lets light clients efficiently test whether a block may contain scripts relevant to them. It specifies the contents and Golomb-coded representation of Bitcoin’s basic compact block filter. The compact structure lets wallets test locally for scripts that may be relevant without sending those scripts to another node.
Overview
BIP 158 specifies how the basic compact block filter is constructed. A node extracts defined elements from a block, including relevant output scripts and certain spent-output scripts, hashes them with a block-specific key, and encodes the resulting set using Golomb-Rice coding.
A wallet can test its own scripts against the filter without revealing those scripts to the node serving the data. A positive result means the block may be relevant and should be downloaded or examined. Because filters are probabilistic, a match can be a false positive, but a correctly created filter should not omit an included element. The filters are compact enough to download for every block, making them useful for privacy-preserving lightweight wallets. Filter headers form a chain that allows clients to detect inconsistent filter data. BIP 158 defines the filter content and encoding. BIP 157 defines the peer-to-peer protocol messages and verification workflow used to distribute the filters.
The filter uses a block-specific key and an encoded set of defined script elements. A wallet transforms its own scripts according to the same rules and tests for possible membership. Correctly constructed filters should not omit included elements, but probabilistic matching can produce false positives. When a filter matches, the wallet downloads and validates the corresponding block or necessary transaction data. The filter itself does not prove that a payment exists, that a transaction is confirmed, or that an output remains unspent. BIP 158 works with BIP 157, which defines how peers serve and verify the filter chain. Keeping the standards separate helps developers distinguish filter construction from synchronization and transport. Implementations should use tested libraries and protocol test vectors because small encoding errors can cause missed wallet activity or unnecessary block downloads.
Key Takeaway
BIP 158 defines Bitcoin’s compact filter data and encoding, while BIP 157 defines how clients retrieve and verify those filters from peers.
Sources
- BIP 158: Compact Block Filters — Bitcoin Improvement Proposals (2026-07-30)