Problem Statement / Feature Objective
Several contract operations require unpredictable randomness (meter sampling for audit, operator selection for reward distribution, dispute resolution). The current approach uses block hash, which is predictable by validators and can be manipulated with MEV-style attacks. A deterministic random beacon must be implemented using a commit-reveal scheme with threshold signing (BLS) by a set of authorized beacon operators. The beacon produces a new random value every 10 ledgers that is unbiasable, publicly verifiable, and available to all contracts via cross-contract call.
Technical Invariants & Bounds
- Beacon operators: 11 operators (selected by governance); threshold = 7-of-11 BLS signatures.
- Round interval: every 10 ledgers (~50 seconds). Round =
current_ledger / 10.
- Protocol: commit phase (ledger 0-3): operators submit
SHA256(secret); reveal phase (ledger 4-9): operators submit (secret, BLS_sig_share). Beacon = SHA256(all_revealed_secrets).
- On-chain verification: aggregate BLS signature verification using BLS12-381 pairing check; gas target < 50,000.
- Storage: only store the latest
(round_number, beacon_value, aggregated_signature, signer_set_hash).
- Historical beacon: any contract can query
get_beacon(round_number) for the last 1000 rounds; older rounds are pruned.
- Slashing: operator who commits but fails to reveal is slashed (bond loss) and replaced.
Codebase Navigation Guide
contracts/random-beacon/src/lib.rs — new beacon contract.
contracts/random-beacon/src/round.rs — round state machine (commit/reveal/finalize).
contracts/random-beacon/src/bls.rs — BLS signature aggregation and verification.
contracts/random-beacon/src/slashing.rs — operator slashing logic for commit-no-reveal.
contracts/random-beacon/src/interface.rs — get_beacon(round) query interface for other contracts.
Problem Statement / Feature Objective
Several contract operations require unpredictable randomness (meter sampling for audit, operator selection for reward distribution, dispute resolution). The current approach uses block hash, which is predictable by validators and can be manipulated with MEV-style attacks. A deterministic random beacon must be implemented using a commit-reveal scheme with threshold signing (BLS) by a set of authorized beacon operators. The beacon produces a new random value every 10 ledgers that is unbiasable, publicly verifiable, and available to all contracts via cross-contract call.
Technical Invariants & Bounds
current_ledger / 10.SHA256(secret); reveal phase (ledger 4-9): operators submit(secret, BLS_sig_share). Beacon =SHA256(all_revealed_secrets).(round_number, beacon_value, aggregated_signature, signer_set_hash).get_beacon(round_number)for the last 1000 rounds; older rounds are pruned.Codebase Navigation Guide
contracts/random-beacon/src/lib.rs— new beacon contract.contracts/random-beacon/src/round.rs— round state machine (commit/reveal/finalize).contracts/random-beacon/src/bls.rs— BLS signature aggregation and verification.contracts/random-beacon/src/slashing.rs— operator slashing logic for commit-no-reveal.contracts/random-beacon/src/interface.rs—get_beacon(round)query interface for other contracts.