# libp2p Rust Notes ---- #### Documentation Link [DOCS link](https://docs.libp2p.io/concepts/introduction/overview/) #### What is Libp2p: libp2p is a modular system of protocols, specifications and libraries that enable the development of peer-to-peer network applications. #### Benefits of Libp2p libp2p lets all users preserve their network identity, overcome network censorship, and communicate over different transport protocols. #### Transport Layer Protocols used TCP, QUIC, WebSocket, WebTransport and WebRTC #### Peer Identity libp2p uses public key cryptography as the basis of peer identity 1. libp2p gives each peer a globally unique “name”, in the form of a PeerId. 2. The PeerId allows anyone to retrieve the public key for the identified peer, which enables secure communication between peers. #### Peer Routing Peer routing is the process of discovering peer addresses by leveraging the knowledge of other peers. #### Peer Messsaging libp2p defines a pubsub specification for sending messages to all peers subscribed to a given “topic”. #### libp2p **Transport** defines how to send bytes on the network, a **NetworkBehaviour** defines what bytes to send on the network. A **Multiaddr** is a self-describing network address and protocol stack that is used to establish connections to peers. #### What problems does libp2p solve? 1. Data Transmission 2. Peer Identity 3. Secure Communication 4. Peer Routing 5. Content discovery 6. Peer messaging ## [Addressing](https://docs.libp2p.io/concepts/fundamentals/addressing/) * Flexible addressing system ### Multiaddress It is a convention for encoding multiple layers of addressing information into single `future-proof` path structure. It allows many layers of addressing to be combined and used together. ### DHT The Kademlia Distributed Hash Table is used in libp2p to provide peer discovery and content routing. In simple terms, a hash table is a set of records in which every record holds a key -> value mapping. In a distributed hash table, the records are spread across the network, which means that every node holds a subset of records. When searching for a specific record, we do not have a centralized registry; therefore, we must ask peers in the network until the record is found. This search is not random however, but guided by the DHT distance metric. #### Distance Metric The distance metric represents the distance between two IDs