Skip to main content

Crate pallet_randomness_beacon

Crate pallet_randomness_beacon 

Source
Expand description

§Randomness Beacon Aggregation and Verification Pallet

This pallet facilitates the aggregation and verification of randomness pulses from an external verifiable randomness beacon, such as drand’s Quicknet. It enables runtime access to externally sourced, cryptographically secure randomness while ensuring that only properly signed pulses are accepted.

§Overview

  • Provides a mechanism to ingest randomness pulses from an external randomness beacon.
  • Aggregates and verifies pulses using the SignatureVerifier trait.
  • Ensures that the runtime only uses verified randomness for security-critical applications.
  • Stores the latest aggregated signature to enable efficient verification within the runtime.

This pallet is particularly useful for use cases that require externally verifiable randomness, such as fair lotteries, gaming applications, and leader election mechanisms.

§Terminology

  • Randomness Pulse: A cryptographically signed value representing a random output from an external randomness beacon.
  • Round Number: A sequential identifier corresponding to each randomness pulse.
  • Aggregated Signature: A combined (aggregated) cryptographic signature that ensures all observed pulses originate from the trusted randomness beacon.

§Implementation Details

The pallet relies on a SignatureVerifier implementation to aggregate and verify randomness pulses. It maintains the latest observed rounds, validates incoming pulses, and aggregates valid signatures before storing them in runtime storage. It expects a monotonically increasing sequence of beacon pulses delivered in packets of size T::SignatureToBlockRatio, beginning at the genesis round.

To be more specific, if the randomness beacon incrementally outputs pulses A -> B -> C -> D, the genesis round expects pulse A first, and the SignatureToBlockRatio is 2, then this pallet would first expect the ‘aggregated’ pulse AB = A + B, which produces both an aggregated signature (asig) and an aggregated public key (apk). Subsequently, it would expected the next value to be CD = C + D. On-chain, this results in the aggregated signature, ABCD = AB + CD, which we can use to prove we have observed all pulses between A and D.

§Storage Items

  • BeaconConfig: Stores the beacon configuration details.
  • GenesisRound: The first round number from which randomness pulses are considered valid.
  • NextRound: Tracks the next minimum future round number for which a signature can be consumed.
  • Accumulation: Stores the latest aggregated signature for verification purposes.

§Usage

This pallet is designed to securely ingest verifiable randomness into the runtime. Authorized callers (block authors) can inject signatures into the runtime, which are verified on-chain.

§Interface

  • Extrinsics

    • try_submit_asig: Submit an aggregated signature for verification. This is an unsigned extrinsic, intended to be called by and hold a signature produced by the block author.
  • Inherent Implementation

    • This pallet provides an inherent that automatically submits aggregated randomness pulses during block execution.

Run cargo doc --package pallet-randomness-beacon --open to view this pallet’s documentation.

Re-exports§

pub use pallet::*;
pub use weights::*;
pub use types::*;

Modules§

pallet
The pallet module in each FRAME pallet hosts the most important items needed to construct this pallet.
types
weights
Autogenerated weights for pallet_randomness_beacon

Traits§

RandomnessBeaconApi