Rust libp2p and tokio demo

Overview

Rust libp2p and tokio demo

This repository contains code to show basic usage of the async programming using tokio and p2p - libp2p library in Rust. The docs for the crate can be found here. This code base contains a simple implementation demonstrating the use. Here we have a simple stdio based implementation that lets peers create and share Memos. A memo is a simple note with a title and body. Notes can be public if you publish the Memo or private. Public Memos can be looked up by any peer and can also be shared with peers.

Showcasing Fundamentals and Concepts

  • Rust fundamentals
  • async programming
  • Using libp2p
  • Using the noise protocol for encryption.

How it works

Our goal is to share memos which contains a title and body. We create nodes using libp2p. Each node starts up and publishes itself on mdns and creates a peer_id which is an identifier that uniquely identifies the node's private key. Each node binds to the ip address and starts a pub/sub subscription. The communication between peers is encrypted using the noise protocl. The messages passed are json messages. Each client recieves messages and based on the mode value of the message decices how the message needs to be routed. Each message type has its handler which processes the message. The interesting part is the use of asyncio to make the code event driven and not block on io waits. The use of mDNS to discover peers available.

Docs

Docs can be found in the docs folder and on github pages.

Running the code

Currently there is nopublished binaries. We need to run this on two or more nodes on the same network. We can run it using :

RUST_LOG=info cargo run

The following commands are available via stdin.

  • ls p - List Peers.
  • ls m - List local memos.
  • ls m all - List all public memos from known peers.
  • ls m {peer_id} - List all public memos from peer specified by peer_id.
  • create m Title|Body - Create a new memo.
  • publish m {id} - Set the public flag on the memo and publish to all known

Limitations

This is a very simple and not considered production worthy or secure.

  • No implementation of commandline parsing to select the storage json for Memo.json
  • The implementation of autoincrementing id's for memos is purely local and does not take into account id collisions between peers etc.
  • Security - Although the communication between peers is encrypted very little is done in the way of authenticating peers.
You might also like...
A simple and secure rust command-line tool to protect your text by encrypting and decrypting it using the robust AES-256 algorithm.

Secret Keeper A simple and secure command-line tool to protect your text by encrypting and decrypting it using the robust AES-256 algorithm. Built wit

Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world.
Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world.

Note to readers: On December 1, 2020, the Libra Association was renamed to Diem Association. The project repos are in the process of being migrated. A

A safe implementation of the secure remote password authentication and key-exchange protocol (SRP), SRP6a and legacy are as features available.

Secure Remote Password (SRP 6 / 6a) A safe implementation of the secure remote password authentication and key-exchange protocol (SRP version 6a). Ver

Retrieving SSH and GPS keys from GitHub and GitLab

Dormarch Retrieving SSH and GPS keys from GitHub and GitLab Usage After having installed Dormarch, you can see all the options with dormarch -h. To re

Terabethia - A Bridge and Messaging Protocol between Ethereum and the Internet Computer.
Terabethia - A Bridge and Messaging Protocol between Ethereum and the Internet Computer.

Terabethia - A Bridge Between Ethereum & the Internet Computer Terabethia is a bridge between Ethereum & the Internet Computer that contracts in both

A guide for Mozilla's developers and data scientists to analyze and interpret the data gathered by our data collection systems.

Mozilla Data Documentation This documentation was written to help Mozillians analyze and interpret data collected by our products, such as Firefox and

Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world.
Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world.

Note to readers: On December 1, 2020, the Libra Association was renamed to Diem Association. The project repos are in the process of being migrated. A

Library with support for de/serialization, parsing and executing on data-structures and network messages related to Bitcoin
Library with support for de/serialization, parsing and executing on data-structures and network messages related to Bitcoin

Rust Bitcoin Library with support for de/serialization, parsing and executing on data-structures and network messages related to Bitcoin. Heads up for

Fiddi is a command line tool that does the boring and complex process of checking and processing/watching transactions on EVM compatible Blockchain.

Fiddi is a command line tool that does the boring and complex process of checking and processing/watching transactions on EVM compatible Blockchain.

Owner
anant asthana
Blockchain - Polkadot, Solana, Ethereum, Rust, Python, Scala, Solidity. ML - Tensorflow, Pytorch Others - GCP/AWS Cloud architecture
anant asthana
Episub: Proximity Aware Epidemic PubSub for libp2p

Libp2p-episub: Proximity Aware Epidemic PubSub for libp2p This Rust library implements a libp2p behaviour for efficient large-scale pub/sub protocol b

Terra 4 Jan 17, 2022
A very bare-bone Block Chain demo that purely implemented by Rust and yew

Intro bloc is one of bare-bone blockchain demo written by Rust, Yew during my learning BlockChain, about years ago. see demo here It just demonstrate

null 4 Dec 16, 2022
Demo: Connect Phala's Fat Contract to external storage services, both centralized (Amazon s3) and decentralized .

This demo shows how to connect Phala's Fat Contract to external storage services, both centralized (Amazon s3) and decentralized (Arweave/Filecoin thr

Christopher Fok 2 Aug 30, 2022
A demo app covering building an eBPF load-balancer in Rust

eBPF Rust UDP LoadBalancer Demo This is an example of creating a UDP load-balancer in Rust as an eXpress Data Path (XDP) type eBPF program using the a

Shane Utt 17 Jan 5, 2023
Rust-Rocket framework template Demo

rocketapp Rust-Rocket framework template Demo dependencies are defined in Cargo.toml Clone as: git clone https://github.com/srikantgdev/rocketapp [op

Srikant Gudi 3 Oct 27, 2022
A demo of the Internet Computer's Bitcoin API

Bitcoin Integration Demo A demo of the bitcoin endpoints on the Internet Computer. This demo is already deployed to the IC, so you can already try it

Islam El-Ashi 8 Jul 2, 2022
Simple node and rust script to achieve an easy to use bridge between rust and node.js

Node-Rust Bridge Simple rust and node.js script to achieve a bridge between them. Only 1 bridge can be initialized per rust program. But node.js can h

Pure 5 Apr 30, 2023
IBC modules and relayer - Formal specifications and Rust implementation

ibc-rs Rust implementation of the Inter-Blockchain Communication (IBC) protocol. This project comprises primarily four crates: The ibc crate defines t

Informal Systems 296 Dec 31, 2022
Fast and efficient ed25519 signing and verification in Rust.

ed25519-dalek Fast and efficient Rust implementation of ed25519 key generation, signing, and verification in Rust. Documentation Documentation is avai

dalek cryptography 563 Dec 26, 2022
Complete Ethereum and Celo wallet implementation and utilities in Rust

ethers.rs Complete Ethereum and Celo wallet implementation and utilities in Rust Documentation Extensive documentation and examples are available here

Georgios Konstantopoulos 1.5k Jan 8, 2023