BIP157¶
Overview¶
BIP157 (Bitcoin Improvement Proposal 157) is an improvement proposal for the Bitcoin light client protocol that defines a light client protocol based on deterministic block content filters. This protocol works in conjunction with BIP158, which defines the Compact Block Filters data structure.
BIP157/158 aims to provide a lightweight Bitcoin client with a blockchain synchronization method that protects privacy while conserving bandwidth. It is an improved replacement for the BIP37 Bloom filter approach.
How It Works¶
Filter Generation (BIP158) Full nodes use BIP158 to create Golomb-Rice coded sets (GCS) for each block. These sets, called "filters," contain all relevant data in the block (such as addresses, transaction outputs, etc.).
Filter Distribution (BIP157) 1. Light clients download compact block filters from full nodes 2. Clients check the filters locally to see if there are any transactions relevant to them 3. If a match is found, the client downloads the full block to retrieve the relevant transactions 4. If there is no match, the client skips the block without downloading it
Advantages Over Other Approaches¶
Compared to BIP37 Bloom Filters - Better privacy: Clients do not reveal their addresses to nodes - More secure: Reduces the risk of attacks on honest nodes - Server-friendly: Full nodes bear less computational burden
Compared to Address Index Servers (e.g., Electrum) - Better privacy: No need to query a server for specific addresses - Lower server requirements: Requires less storage and CPU - More decentralized: Does not depend on specific index servers
Trade-offs - BIP157/158 consumes more bandwidth under normal conditions than either of the above two protocols - Requires downloading filters for all blocks (though filters are very small)
Bitcoin Core Support¶
- Bitcoin Core supports serving BIP157-type filters starting from v0.21.0
- Nodes can provide BIP157-compliant block filters to other nodes via the P2P network
- Wallets can use BIP157 for fast rescanning
Use Cases¶
- Mobile wallets: Lightweight Bitcoin wallets running on mobile devices
- Fast synchronization: Quickly syncing historical transactions for new wallets
- Privacy protection: Not revealing addresses to third parties
- Decentralization: Connecting directly to the P2P network without relying on centralized services
Recommended Reading¶
Related Concepts¶
- BIP37 Bloom Filters
- BIP158 Compact Block Filters
- Light Client (SPV)
- Golomb-Rice Coding
- P2P Network