dee: Rust implementation of drand

Documentation License crates.io

dee is a tool to retrieve public randomness generated by drand beacon. 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.

Install

bash cargo install dee

Usage

```bash dee chain add mainnet https://api.drand.sh # Add a new beacon dee get --set-upstream mainnet 1000 # Fetch round 1000 and set upstream to mainnet dee get --format json # Fetch latest mainnet round as json

dee chain add testnet https://testnet0-api.drand.cloudflare.com/f3827d772c155f95a9fda8901ddd59591a082df5ac6efe3a479ddb1f5eeb202c # Add a new beacon dee chain info testnet # Retrieve information about testnet beacon ```

Seeding your Random Number Generator

You can leverage drand randomness as a seed for PRNG systems.

bash

bash RANDOM=$(dee get --format json | jq -r '.randomness'); echo $RANDOM $RANDOM $RANDOM

Python

```python import random

random.seed(int("dee-randomness", 16))

print(random.random()) print(random.random()) print(random.random()) ```

Rust

```rust use rand::prelude::*; use randseeder::{Seeder, SipHasher}; use randpcg::Pcg64;

fn main() { // In one line: let mut rng: Pcg64 = Seeder::from("dee-rng").makerng(); println!("{}", rng.genrange(0..100)); println!("{}", rng.genrange(0..100)); println!("{}", rng.genrange(0..100)); } ```

Details

This client supports validation of chained and unchained randomness, both with signature on G1 and on G2.