Top Qs
Timeline
Chat
Perspective
Libp2p
Modular network stack and open-source library From Wikipedia, the free encyclopedia
Remove ads
libp2p is a modular network stack and open-source library that enables developers to build decentralised, peer-to-peer (P2P) applications. It originated part of the InterPlanetary File System (IPFS) and was later spun off into a standalone project.[1] The software was developed to provide a set of tools for handling the networking challenges of P2P systems. This includes peer discovery, routing, identity management, and secure communication. There are multiple implementations of libp2p across multiple programming languages.[2] Major projects like Ethereum's consensus layer[3] and Filecoin[4] use libp2p as their foundational networking layer.
This article may incorporate text from a large language model. (September 2025) |
Remove ads
History
libp2p was developed by Juan Benet and the team at Protocol Labs during the development of IPFS.[5] The team recognised that building a robust P2P network required solving a set of recurring problems that were not specific to file sharing. Instead of creating a monolithic networking layer tightly coupled to IPFS, they designed a modular and extensible framework that could be abstracted away and used by any P2P application.
The project was separated from the main IPFS codebase to encourage independent development and adoption. This decision proved successful, as libp2p has become a fundamental building block for many other decentralised protocols, allowing their developers to focus on application-level logic rather than reinventing the networking wheel. The project is maintained as an open-source initiative with contributions from a global community of developers.
Remove ads
Core Concepts
Summarize
Perspective
libp2p is built around a set of core concepts that, when combined, provide a complete P2P networking solution.
Peer Identity (PeerID)
In a libp2p network, every node, or "peer," is uniquely identified by a PeerID. A PeerID is the cryptographic hash of a peer's public key. This design provides a secure and verifiable identity system. When two peers communicate, they can use the other's public key to encrypt communications and verify signatures, ensuring authenticity and preventing impersonation.[6]
Multiaddress (multiaddr)
Locating peers across different network protocols and locations is addressed using multiaddress (or multiaddr).[7] This is a self-describing network address that allows for multiple layers of addressing information.[8] A host can have multiple multiaddrs, advertising all the ways it can be reached.[9]
For example, a multiaddr might look like:
- /ip4/192.168.1.100/tcp/8001
This describes a peer accessible via an IPv4 address 192.168.1.100, using the TCP protocol on port 8001.
Transports
libp2p is transport-agnostic, meaning it can operate over various network transport protocols.[9] Common transports include:
A machine running libp2p can listen for incoming connections on multiple transports simultaneously which increases the likelihood of successful connections between peers across different network environments.[15]
Stream Multiplexing
To reduce the overhead of opening each new connection libp2p relies on stream multiplexing.[16] This allows multiple independent, bi-directional streams to run concurrently over a single underlying transport connection, enabling different application-level protocols to operate without interference.[17]
libp2p achieves this in two ways:
- For transports like TCP that do not natively support streams, libp2p layers a dedicated multiplexer protocol (such as mplex or yamux) on top of the connection.[18]
- For modern transports like QUIC and WebRTC, libp2p leverages the protocol's built-in, native multiplexing capabilities directly, without needing an additional layer.
Protocol Negotiation (multistream-select)
When a peer initiates a new stream to another peer, libp2p uses a mechanism called multistream-select. The peer proposes a protocol identifier (e.g., /ipfs/bitswap/1.2.0), and the listening peer either accepts it or rejects it. This allows peers to support multiple protocols and versions simultaneously and ensures that both sides of a conversation understand each other.[15]
Peer Discovery
Finding other peers in a decentralised network is a fundamental challenge. libp2p provides several mechanisms for peer discovery:
- Bootstrap Lists: A list of known, peer addresses used by new nodes to join the network.[19]
- mDNS: Used for discovering peers on a local area network (LAN).[20]
- Distributed Hash Table (DHT): For discovering peers on the wider internet, libp2p networks often employs a Kademlia-based DHT. A peer can query the DHT to find the addresses of other peers.[21]
Secure Communication
When two peers connect, they upgrade their connection to a secure channel using protocols like TLS 1.3[22] or Noise.[15] This protects against eavesdropping and man-in-the-middle attacks.[23]
Publish/Subscribe
The most widely used implementation of a publish/subscribe (PubSub) system is GossipSub[24]. This is a scalable and resilient gossip protocol that propagates messages through the network by having peers gossip with a random subset of their neighbours.[25] This is used extensively for tasks like block and transaction propagation in blockchain networks.[26]
Remove ads
Implementations
As libp2p is a specification with multiple implementations in different programming languages. As of 2025, the most mature implementations are:
- go-libp2p (Go)
- js-libp2p (JavaScript)
- rust-libp2p (Rust)
Other official implementations include:[27]
References
Sources
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads