This article may incorporate text from a large language model .(September 2025) |
libp2p | |
---|---|
Original author | Protocol Labs |
Developer | The libp2p community |
Initial release | c. 2016 |
Stable release | Various (per implementation) |
Written in | Go, JavaScript, Rust, Python, Java, Nim, C++ |
Operating system | Cross-platform |
Type | Network stack, P2P |
License | MIT License, Apache License 2.0 |
Website | libp2p github |
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.
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.
libp2p is built around a set of core concepts that, when combined, provide a complete P2P networking solution.
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]
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:
This describes a peer accessible via an IPv4 address 192.168.1.100, using the TCP protocol on port 8001.
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]
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:
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]
Finding other peers in a decentralised network is a fundamental challenge. libp2p provides several mechanisms for peer discovery:
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]
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]
As libp2p is a specification with multiple implementations in different programming languages. As of 2025, the most mature implementations are:
Other official implementations include: [27]
{{cite journal}}
: CS1 maint: multiple names: authors list (link){{cite web}}
: CS1 maint: numeric names: authors list (link)