drand_core

Crates.iodrand_core
lib.rsdrand_core
version0.0.16
sourcesrc
created_at2023-03-01 15:07:54.532841
updated_at2024-03-09 20:42:38.608039
descriptionA drand client library.
homepagehttps://github.com/thibmeu/drand-rs/tree/main/drand_core
repositoryhttps://github.com/thibmeu/drand-rs
max_upload_size
id798095
size109,239
Thibault (thibmeu)

documentation

README

drand-core: Rust implementation of drand

Documentation License crates.io

drand-core is a library to retrieve public randomness generated by drand beacons. It features an HTTP client, and verification method.

The format specification is at drand.love/docs/specification. drand was designed in Scalable Bias-Resistant Distributed Randomness.

The reference interroperable Go implementation is available at drand/drand.

Tables of Content

Features

  • Retrieve and verify drand randomness
  • Built-in beacon time estimation
  • Chain and unchained randomness
  • Signatures verification on G1 and G2
  • Interroperability with Go and JS implementation
  • wasm32 compatible library

What's next

  • P2P randomness retrieval

Installation

Environment CLI Command
Cargo (Rust 1.74+) cargo install drand_core

The library is tested against the following targets: x86_64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf, aarch64-unknown-linux-gnu, wasm32-unknown-unknown

Usage

Retrieve the latest beacon from https://drand.cloudflare.com.

use drand_core::HttpClient;

// Create a new client.
let client: HttpClient = "https://drand.cloudflare.com".try_into().unwrap();

// Get the latest beacon. By default, it verifies its signature against the chain info, and correlates the returned round number with the chain genesis time.
let latest = client.latest()?;

Code examples are provided in drand_core/examples. You can run them using cargo run --examples <name>.

Common remotes

ID Remote Timelock encryption
quicknet-cloudflare https://drand.cloudflare.com/52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971 Yes
quicknet-pl https://api.drand.sh/52db9ba70e0cc0f6eaf7803dd07447a1f5477735fd3f661792ba94600c84e971 Yes
mainnet-cloudflare https://drand.cloudflare.com No
mainnet-pl https://api.drand.sh No

drand_core does not come with a default remote beacon. You should decide whichever suit your needs.

More beacon origins are available on drand website.

Security Considerations

This library has not been audited. Please use at your sole discretion.

License

This project is under the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be MIT licensed as above, without any additional terms or conditions.

Commit count: 131

cargo fmt