# RLN libp2p protocol and usecases ### *Variables and conventions:* **gossipsub-rln** - the name of the p2p pubsub protocol **RLN** - Rate Limiting Nullifier ## Goals: - Provide easy to use p2p PubSub protocol which offers privacy and spam protection on network level - Use the protocol as a building block for applications that need strong privacy and spam resilience - implement the identified use cases described below using the protocol - Create public awareness of the RLN construct and the gossipsub-rln protocol and what could be built with it (usecase demo) ## Target applications: - Peer-to-peer applications that need strong privacy and spam resilience on network level and are not critically resource constrained. ## Project description **gossipsub-rln** is a libp2p protocol which extends the gossipsub-v1.1 protocol and implements the RLN (Rate limit nullifier) primitive. This protocol will be generic addition to the libp2p library's toolkit and could be used as privacy preserving, spam resilient PubSub protocol by various applications. The goal of this project is to provide a building block for p2p application usecases that need strong privacy and spam resilience. The privacy and the spam prevention is implemented on the PubSub protocol level. ## Why it is important Certain applications might require strong spam prevention measures and anti-DOS mechanisms on a broader level of the p2p network. Another necessity is privacy preservation of network's participants. The gossipsub protocol already has security extensions built for spam prevention and other security related topics, specified as gossipsub-v1.1 (addition to the gossipsub-v1.0 protocol specification). However gossipsub-v1.1 doesn't offer privacy protection and the spam prevention measures are not on global network level and are rarely enough. Gossipsub-v1.1 uses a peer-scoring algorithm based on specific logic. However the peer-scoring is implemented locally (per-node) and there is no global view for the whole network. This means that an attacker might be graylisted from a certain node but not from the other nodes, and he can freely spam the other nodes until he gets graylisted there too. Another concern is attacker spinning multiple nodes. In this way the attacker will be able to spam a certain target node from multiple sources. The RLN primitive solves this issues by providing a spam prevention mechanism for private environments which offers group level spam protection (a group can be the whole p2p network), by leveraging ZK-cryptography and economic disincentives for spamming. Waku has already started working on this problem using the RLN primitive, which addresses the needs for their problem ([https://vac.dev/rln-relay](https://vac.dev/rln-relay)). The RLN relay is a wrapper around gossipsub-v1.1 and is part of their tech stack. The main focus of Waku are resource constrained devices. The narrowed focus on a specific target group is a great constrain and certainly limits a lot of potential network participants as well as application usecases. The gossipsub-rln is a generic wrapper that can be used for wide variety of applications and network participants. Very resource constrained devices might be discarded at the moment because of the computation and storage requirements, but the current RLN construct is efficient for the majority of potential network participants and application usecases. The differences between Waku and gossipsub-rln are: - Waku is a family of modular peer-to-peer protocols while gossipsub-rln is just a libp2p protocol - Waku's main target group are resource constrained devices (Limited bandwidth, CPU, memory, disk, battery) that can be also constrained connectivity wise (peers not being publicly connectable and peers being mostly offline). gossipsub-rln is generic and can be used by any peers that meet the RLN's construct computation and storage requirements. ## Use cases [Private message sharing for ETH2 validators](https://hackmd.io/@blagoj/SksjxLaWF) ## Implementation details specification https://hackmd.io/@blagoj/ryBi0HTWK ## Reading list and references - [RLN introductory post](https://medium.com/privacy-scaling-explorations/rate-limiting-nullifier-a-spam-protection-mechanism-for-anonymous-environments-bbe4006a57d) - [RLN overview](https://ethresear.ch/t/semaphore-rln-rate-limiting-nullifier-for-spam-prevention-in-anonymous-p2p-setting/5009) - ethresearch post - [RLN spec](https://hackmd.io/tMTLMYmTR5eynw2lwK9n1w?both) - implementation spec for the construct - [Libp2p docs](https://docs.libp2p.io/) - [Gossipsub-v1.1 spec](https://github.com/libp2p/specs/blob/master/pubsub/gossipsub/gossipsub-v1.1.md) - [WAKU RLN relay](https://vac.dev/rln-relay) - [RLN App](https://github.com/kilic/rlnapp) - typescript PoC for generating and verifying RLN ZK proofs, membership smart contracts and merkle tree provided - [RLN construct](https://github.com/kilic/rln) - implemented in Rust