Libp2p

libp2p
Original authorProtocol Labs
DeveloperThe libp2p community
Initial releasec. 2016
Stable release
Various (per implementation)
Written inGo, JavaScript, Rust, Python, Java, Nim, C++
Operating systemCross-platform
TypeNetwork stack, P2P
LicenseMIT License, Apache License 2.0
Websitelibp2p.io
github.com/libp2p

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.

History

[edit]

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.

Core Concepts

[edit]

libp2p is built around a set of core concepts that, when combined, provide a complete P2P networking solution.

Peer Identity (PeerID)

[edit]

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)

[edit]

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

[edit]

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

[edit]

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)

[edit]

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

[edit]

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

[edit]

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

[edit]

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]

Implementations

[edit]

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]

References

[edit]
  1. ^ a b "What is libp2p?". IPFS Documentation. Retrieved 2025-09-14.
  2. ^ Stengele, Oliver; Droll, Jan; Hartenstein, Hannes (2025-06-02). "Supply-Chain-Aligned Software Auditing and Usage Justification via Distributed Ledgers". 2025 IEEE International Conference on Blockchain and Cryptocurrency (ICBC). IEEE. pp. 1–5. doi:10.1109/ICBC64466.2025.11114608. ISBN 979-8-3315-4135-4.
  3. ^ "Consensus Layer". Ethereum Documentation. Retrieved 2025-09-15.
  4. ^ "Filecoin Libraries". Filecoin specification. Retrieved 2025-09-15.
  5. ^ Cristea, Alexandru-Gabriel; Alboaie, Lenuta; Panu, Andrei; Radulescu, Vlad (2020). "Offline but still connected with IPFS based communication". Procedia Computer Science. 176: 1606–1612. doi:10.1016/j.procs.2020.09.183.
  6. ^ a b "Peers". libp2p Documentation. Retrieved 2025-09-14.
  7. ^ Si, Haiping; Li, Weixia; Wang, Qingyi; Cao, Haohao; Bacao, Fernando; Sun, Changxia (2023-11-15). "A secure cross-domain interaction scheme for blockchain-based intelligent transportation systems". PeerJ Computer Science. 9 e1678. doi:10.7717/peerj-cs.1678. ISSN 2376-5992. PMC 10703034. PMID 38077614.
  8. ^ Guidi, Barbara; Michienzi, Andrea; Ricci, Laura (2021-12-06). "A libP2P Implementation of the Bitcoin Block Exchange Protocol". Proceedings of the 2nd International Workshop on Distributed Infrastructure for Common Good. ACM. pp. 1–4. doi:10.1145/3493426.3493822. ISBN 978-1-4503-9169-6.
  9. ^ a b Ramaguru, R.; Sindhu, M.; Sethumadhavan, M. (2019), Singh, Mayank; Gupta, P.K.; Tyagi, Vipin; Flusser, Jan (eds.), "Blockchain for the Internet of Vehicles", Advances in Computing and Data Sciences, vol. 1045, Singapore: Springer Singapore, pp. 412–423, doi:10.1007/978-981-13-9939-8_37, ISBN 978-981-13-9938-1, retrieved 2025-10-05
  10. ^ Seemann, Marten; Inden, Max; Vyzovitis, Dimitris (2022). "Decentralized Hole Punching". 2022 IEEE 42nd International Conference on Distributed Computing Systems Workshops (ICDCSW). pp. 96–98. doi:10.1109/ICDCSW56584.2022.00027. ISBN 978-1-6654-8879-2.
  11. ^ Malik, Muhammad Anjum; Pleuger, Tobias; Recker, Stephan (2023). "Peer-to-Peer Approach for Edge Computing Services". 2023 IEEE International Conference on Cloud Computing Technology and Science (CloudCom). pp. 200–207. doi:10.1109/CloudCom59040.2023.00041. ISBN 979-8-3503-3982-6.
  12. ^ G, Pratiksha Narasimha Nayak; Dey, Nimisha; N, Neha; Hariprasad, Malavika; S, Sandhya; Moharir, Minal; Akram, Muteeb (2022). "A Detail Survey on QUIC and its Impact on Network Data Transmission". 2022 6th International Conference on Trends in Electronics and Informatics (ICOEI). pp. 378–385. doi:10.1109/ICOEI53556.2022.9777199. ISBN 978-1-6654-8328-5.
  13. ^ a b Antelmi, Alessia; D’Ambrosio, Giuseppe; Petta, Andrea; Serra, Luigi; Spagnuolo, Carmine (2022). "A Volunteer Computing Architecture for Computational Workflows on Decentralized Web". IEEE Access. 10: 98993–99010. Bibcode:2022IEEEA..1098993A. doi:10.1109/ACCESS.2022.3207167. ISSN 2169-3536.
  14. ^ Lopes, Elio Jordan; Kataria, Shaolin; Keshav, Shashank; Ikram, Sumaiya Thaseen; Ghalib, Muhammad Rukunuddin; Shankar, Achyut; Krichen, Moez (2022). "Live video streaming service with pay-as-you-use model on Ethereum Blockchain and InterPlanetary file system". Wireless Networks. 28 (7): 3111–3125. doi:10.1007/s11276-022-03009-6. ISSN 1022-0038.
  15. ^ a b c Ángel, Niebla-Montero; Iván, Froiz-Míguez; Paula, Fraga-Lamas; M., Fernández-Caramés, Tiago (2025). "Design, Implementation and Practical Evaluation of an Opportunistic Communications Protocol Based on Bluetooth Mesh and libp2p". Sensors. 25 (4): 1190. arXiv:2503.00976. Bibcode:2025Senso..25.1190N. doi:10.3390/s25041190. ISSN 1424-8220. PMID 40006419.{{cite journal}}: CS1 maint: multiple names: authors list (link)
  16. ^ a b "Stream Multiplexing". libp2p Documentation. Retrieved 2025-09-14.
  17. ^ Dias, David; Benet, Juan (2016), Bozzon, Alessandro; Cudre-Maroux, Philippe; Pautasso, Cesare (eds.), "Distributed Web Applications with IPFS, Tutorial", Web Engineering, vol. 9671, Cham: Springer International Publishing, pp. 616–619, doi:10.1007/978-3-319-38791-8_60, ISBN 978-3-319-38790-1, retrieved 2025-10-05
  18. ^ Zhao, Wanli; Fujita, Satoshi (2025). "Hashgraph Over the Edge: Achieving Byzantine Fault Tolerance in Decentralized P2P Frameworks". IEEE Access. 13: 153035–153055. Bibcode:2025IEEEA..1353035Z. doi:10.1109/ACCESS.2025.3604512. ISSN 2169-3536.
  19. ^ Henningsen, Sebastian; Rust, Sebastian; Florian, Martin; Scheuermann, Björn (2020). "Crawling the IPFS Network". 2020 IFIP Networking Conference (Networking): 679–680.
  20. ^ Trautwein, Dennis; Schubotz, Moritz; Gipp, Bela (2021). "Introducing Peer Copy - A Fully Decentralized Peer-to-Peer File Transfer Tool". 2021 IFIP Networking Conference (IFIP Networking): 1–2. arXiv:2305.02049. doi:10.23919/IFIPNetworking52078.2021.9472842. ISBN 978-3-9031-7639-3.
  21. ^ Costa, Pedro Ákos; Leitão, João; Psaras, Yannis (2023), Patiño-Martínez, Marta; Paulo, João (eds.), "Studying the Workload of a Fully Decentralized Web3 System: IPFS", Distributed Applications and Interoperable Systems, vol. 13909, Cham: Springer Nature Switzerland, pp. 20–36, doi:10.1007/978-3-031-35260-7_2, ISBN 978-3-031-35259-1, retrieved 2025-10-06
  22. ^ Manakhari, Sushanth S.; Jadhav, Ajinkya P. (2025), Arabnia, Hamid R.; Takata, Masami; Deligiannidis, Leonidas; Rivas, Pablo (eds.), "Enhancing Data Security with Decentralized Cloud Storage: An IPFS Approach", Grid, Cloud, and Cluster Computing; Quantum Technologies; and Modeling, Simulation and Visualization Methods, vol. 2257, Cham: Springer Nature Switzerland, pp. 27–39, doi:10.1007/978-3-031-85884-0_3, ISBN 978-3-031-85883-3, retrieved 2025-10-06
  23. ^ Huang, Ken (2023), Huang, Ken; Budorin, Dyma; Tan, Lisa JY; Ma, Winston (eds.), "Chain Security: Nodes, Algorithm, and Network", A Comprehensive Guide for Web3 Security, Future of Business and Finance, Cham: Springer Nature Switzerland, pp. 31–60, doi:10.1007/978-3-031-39288-7_2, ISBN 978-3-031-39287-0, retrieved 2025-10-06
  24. ^ De Cristo, Flaviene Scheidt; Meira, Jorge Augusto; Eisenbarth, Jean-Philippe; State, Radu (2024). "A 9-dimensional Analysis of GossipSub over the XRP Ledger Consensus Protocol". NOMS 2024-2024 IEEE Network Operations and Management Symposium. pp. 1–7. doi:10.1109/NOMS59830.2024.10575688. ISBN 979-8-3503-2793-9.
  25. ^ de Cristo, Flaviene Scheidt; Shbair, Wazen M.; Trestioreanu, Lucian; State, Radu (2023). "Pub/Sub Dissemination on the XRP Ledger". 2023 IEEE Latin-American Conference on Communications (LATINCOM). pp. 1–6. doi:10.1109/LATINCOM59467.2023.10361857. ISBN 979-8-3503-2687-1.
  26. ^ Frey, Davide; Mostefaoui, Achour; Perrin, Matthieu; Roman, Pierre-Louis; Taïani, François (2023). "Differentiated Consistency for Worldwide Gossips". IEEE Transactions on Parallel and Distributed Systems. 34 (1): 1–15. Bibcode:2023ITPDS..34P9150F. doi:10.1109/TPDS.2022.3209150. ISSN 1558-2183.
  27. ^ The libp2p Foundation. "A modular network stack". libp2p. Retrieved September 19, 2025.{{cite web}}: CS1 maint: numeric names: authors list (link)

Sources

[edit]