RandomnessBeacon

@Serializable
data class RandomnessBeacon(val round: Long, val randomness: String? = null, val signature: String, val previousSignature: String? = null)

A randomness beacon from a drand network.

Drand networks produce randomness beacons at regular intervals (rounds). Each beacon contains a BLS signature over the round number (and optionally the previous signature for chained schemes), and the final randomness value is derived from this signature.

Chained vs Unchained

Drand supports two modes:

  • Chained: Each beacon signs both the round and the previous signature, creating a hash chain. The previousSignature field is populated.

  • Unchained: Each beacon signs only the round number. The previousSignature field is null. This mode enables timelock encryption.

Read more: https://drand.love/docs/cryptography/#randomness

Constructors

Link copied to clipboard
constructor(round: Long, randomness: String? = null, signature: String, previousSignature: String? = null)

Properties

Link copied to clipboard

The final randomness value for this beacon. Returns randomness if present, otherwise computes SHA-256(signature). This is the value you should use for random number generation.

Link copied to clipboard
@SerialName(value = "previous_signature")
val previousSignature: String? = null

Hex-encoded previous signature (optional, for chained mode). In chained mode, this links the current beacon to the previous one. In unchained mode, this is null.

Link copied to clipboard

The previousSignature decoded from hex to bytes, or null. Used for chained signature verification.

Link copied to clipboard
val randomness: String? = null

Hex-encoded randomness bytes (optional, may be null). When present, this is the pre-computed randomness value. When null, randomness is derived via SHA-256 of the signature.

Link copied to clipboard

The derivedRandomness decoded from hex to bytes. The actual random bytes you can use in your application.

Link copied to clipboard
val round: Long

The round number for this beacon (must be positive). Round numbers start at 1 and increment sequentially.

Link copied to clipboard

The round number as an 8-byte big-endian array. Used internally for signature verification.

Link copied to clipboard

Hex-encoded BLS signature bytes (required). This signature can be verified against the network's public key and proves the authenticity of this beacon.

Link copied to clipboard

The signature decoded from hex to bytes. Used for cryptographic verification operations.

Functions

Link copied to clipboard

Validate this beacon has well-formed data