15 releases

0.0.16 Mar 9, 2024
0.0.15 Feb 29, 2024
0.0.14 Aug 30, 2023
0.0.8 Jul 23, 2023
0.0.6 Mar 22, 2023

#671 in Cryptography


Used in 4 crates

MIT license

67KB
1.5K SLoC

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.

Dependencies

~8–18MB
~267K SLoC