#chord #dht #web3 #p2p #wasm

no-std rings-core

Chord DHT implementation with ICE

12 releases

0.3.0 Sep 21, 2023
0.2.6 Jun 29, 2023
0.2.5 Mar 16, 2023
0.2.1 Dec 20, 2022
0.2.0 Jul 26, 2022

#4 in #dht-network

Download history 5/week @ 2023-07-30 11/week @ 2023-08-06 52/week @ 2023-08-13 26/week @ 2023-08-20 30/week @ 2023-08-27 11/week @ 2023-09-03 33/week @ 2023-09-10 46/week @ 2023-09-17 10/week @ 2023-09-24 15/week @ 2023-10-01 5/week @ 2023-10-08 11/week @ 2023-10-15 22/week @ 2023-10-22 21/week @ 2023-10-29 11/week @ 2023-11-05 8/week @ 2023-11-12

62 downloads per month
Used in 2 crates

GPL-3.0 license

11K SLoC

Rings Network

Rings Core

rings-node cargo docs


The Rings Network architecture is streamlined into five distinct layers.

Runtime Layer

The design goal of Rings Network is to enable nodes to run in any environment, including browsers, mobile devices, Linux, Mac, Windows, etc. To achieve this, we have adopted a cross platform compile approach to build the code. For non-browser environments, we use pure Rust implementation that is independent of any system APIs, making our native implementation system agnostic. For browser environments, we compile the pure Rust implementation to WebAssembly (Wasm) and use web-sys, js-sys, and wasm-bindgen to glue it together, making our nodes fully functional in the browser.

Transport Layer

The implementation of WebRTC and WebAssembly in Rings Network provides several advantages for users. Firstly, the browser-based approach means that users do not need to install any additional software or plugins to participate in the network. Secondly, the use of WebRTC and WebAssembly enables the network to have a low latency and high throughput, making it suitable for real-time communication and data transfer.

WebRTC, or Web Real-Time Communication, provides browsers and mobile apps with real-time communication capabilities through simple APIs. With WebRTC, users can easily send audio, video, and data streams directly between browsers, without the need for any plug-ins or extra software. At the same time, the Rings Network has some special optimizations for the WebRTC handshakes process.

Assuming Node A and Node B want to create a WebRTC connection, they would need to exchange a minimum of three messages with each other:

ICE Scheme:

  1. Peer A: { create offer, set it as local description } -> Send Offer to Peer B
  2. Peer B: { set receiveed offer as remote description create answer set it as local description Send Answer to Peer A }
  3. Peer A: { Set receiveed answer as remote description }

Network Layer

The Rings Network is a structured peer-to-peer network that incorporates a distributed hash table (DHT) to facilitate efficient and scalable lookups. The Chord algorithm is utilized to implement the lookup function within the DHT, thereby enabling effective routing of messages and storage of key-value pairs in a peer-to-peer setting. The use of a DHT, incorporating the Chord algorithm, guarantees high availability in the Rings Network, which is critical for handling the substantial number of nodes and requests typically present in large-scale peer-to-peer networks.

Protocol Layer

In the protocol layer, the central design concept revolves around the utilization of a Decentralized Identifier (DID), which constitutes a finite ring in abstract algebra. The DID is a

-bit identifier that enables the construction of a mathematical structure that encompasses the characteristics of both a group and a field. It is comprised of a set of elements with two binary operations, addition and multiplication, which satisfy a set of axioms such as associativity, commutativity, and distributivity. The ring is deemed finite due to its having a finite number of elements. Finite rings are widely employed in various domains of mathematics and computer science, including cryptography and coding theory.

Application Layer

The nucleus of Rings Network is similar to the Actor Model, and it requires that each message type possess a Handler Trait. This allows for the separation of processing system messages, network messages, internal messages, and application-layer messages.


~472K SLoC