Adnl Rs

ADNL implementation in Rust
Alternatives To Adnl Rs
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Bifrost200
2 days ago9gpl-3.0Rust
A parachain focused on building bridges of chains based on PoS consensus.
Layr51
5 years ago14JavaScript
A decentralized (p2p) file storage system built atop Kademlia DHT that enforces data integrity, privacy, and availability through sharding, proofs of retrievability, redundancy, and encryption, with smart-contract powered incentive scheme
Jelectrum39
a year ago11mitJava
An Electrum Server written in Java
Blockcloud27
5 years agoC
An advanced Blockchain-based TCP/IP.
Structured P2p Overlay Network11
4 years agogpl-3.0Python
Final Year Project @HKU Department of Computer Science | HGFRR includes a new peer-to-peer network protocol that improves communication efficiency and security among peers, and an implementation of a fast, secure blockchain system on top of this P2P network.
Go Blockchain11
6 years agoGo
Blockchain simulator written in Go
Electrum9
5 years agomitGo
Electrum protocol client
Blockchainserver8
6 years agoC++
Blockchainserver implementation.
Adnl Rs7
4 months agoRust
ADNL implementation in Rust
Modood.github.io6
3 years agootherHTML
Blogs are here to stay.
Alternatives To Adnl Rs
Select To Compare


Alternative Project Comparisons
Readme

ADNL

Minimal ADNL implementation in Rust (client-server only, without p2p for now). Specification of ADNL is available here.

Feature Implemented?
ADNL Client
ADNL Server
ADNL P2P
no_std
ed25519 libs curve25519_dalek + x25519_dalek

Quickstart

Run this example: cargo run --example time --features "std dalek"

use adnl::{AdnlBuilder, AdnlClient};
use std::error::Error;
use std::net::{SocketAddrV4, TcpStream};
use x25519_dalek::StaticSecret;

pub fn connect(
    ls_public: &str,
    ls_ip: &str,
    ls_port: u16,
) -> Result<AdnlClient<TcpStream>, Box<dyn Error>> {
    // decode liteserver public key
    let remote_public: [u8; 32] = base64::decode(ls_public)?
        .try_into()
        .map_err(|_| "bad public key length")?;

    // generate private key
    let local_secret = StaticSecret::new(rand::rngs::OsRng);

    // use TcpStream as a transport for our ADNL connection
    let transport = TcpStream::connect(SocketAddrV4::new(ls_ip.parse()?, ls_port))?;

    // build handshake using random session keys, encrypt it with ECDH(local_secret, remote_public)
    // then perform handshake over our TcpStream
    let client = AdnlBuilder::with_random_aes_params(&mut rand::rngs::OsRng)
        .perform_ecdh(local_secret, remote_public)
        .perform_handshake(transport)
        .map_err(|e| format!("{:?}", e))?;
    Ok(client)
}

fn main() -> Result<(), Box<dyn Error>> {
    // create AdnlClient
    let mut client = connect(
        "JhXt7H1dZTgxQTIyGiYV4f9VUARuDxFl/1kVBjLSMB8=",
        "65.21.74.140",
        46427,
    )?;

    // already serialized TL with gettime query
    let mut query = hex::decode("7af98bb435263e6c95d6fecb497dfd0aa5f031e7d412986b5ce720496db512052e8f2d100cdf068c7904345aad16000000000000")?;

    // send over ADNL, use random nonce
    client
        .send(&mut query, &mut rand::random())
        .map_err(|e| format!("{:?}", e))?;

    // receive result into vector, use 8192 bytes buffer
    let mut result = Vec::<u8>::new();
    client
        .receive::<_, 8192>(&mut result)
        .map_err(|e| format!("{:?}", e))?;

    // get time from serialized TL answer
    println!(
        "received: {}",
        u32::from_le_bytes(result[result.len() - 7..result.len() - 3].try_into()?)
    );
    Ok(())
}
Popular Blockchain Projects
Popular Tcp Projects
Popular Blockchain Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Rust
Blockchain
Tcp