Skip to content

feat(contracts): [SC-011] Commit-Reveal Random Number Generator (RNG) with Slashing for Non-Disclosure - #1719

Closed
theoneesi wants to merge 1 commit into
StellarDevHub:mainfrom
theoneesi:feat/sc-011-commit-reveal-rng-slashing
Closed

theoneesi wants to merge 1 commit into
StellarDevHub:mainfrom
theoneesi:feat/sc-011-commit-reveal-rng-slashing

Conversation

@theoneesi

Copy link
Copy Markdown

Overview

Resolves #1632

Identifier: SC-011
Domain Category: Cryptographic Games & Randomness
Difficulty: Hard
Deployment Priority: Medium

Problem Statement

On-chain miners and validators can frontrun and manipulate pseudorandom numbers derived directly from block timestamps and headers.

Implementation Details

Implemented a secure commit-reveal randomness beacon contract with deposit staking, non-disclosure slashing, and stake redistribution:

  1. Entropy Generation & Accumulation (contracts/commit_reveal_rng/src/entropy.rs):
    • Participants commit SHA-256 hashes of secret salts during the commit phase ( = \text{SHA256}(s)$).
    • In the reveal phase, valid secrets are verified against stored commitments and element-wise XORed into the running entropy accumulator.
    • Upon finalisation, the accumulator is hashed using SHA-256 to generate verifiable, uniform random output resistant to single-party bias.
  2. Deposit Staking, Slashing & Redistribution (contracts/commit_reveal_rng/src/slashing.rs):
    • Added deposit stake support via token transfer on commitment (commit_with_deposit).
    • Honest revealers have their initial deposit refunded upon disclosing their secret (
      eveal).
    • After the reveal deadline, unrevealed commitments have their stakes confiscated (slash_non_revealers).
    • Confiscated stakes from non-revealers are redistributed equally among honest revealers (
      edistribute_slashed_stake).
  3. Core Integration & Interface (contracts/commit_reveal_rng/src/lib.rs):
    • Modularized entropy.rs and slashing.rs into the main RNG crate.
    • Preserved backward compatibility for zero-deposit commit rounds and existing VRF consumer interfaces.
    • Added comprehensive unit and integration tests verifying happy path entropy generation, hash mismatch panics, non-disclosure slashing, and token stake confiscation and redistribution.

Acceptance Criteria Verification

  • Rejects reveals that do not match the previously committed hash.
  • Generates unpredictable uniform random numbers resistant to single-party bias.
  • Confiscates and redistributes stakes of non-revealing participants.
  • All 11 unit & integration tests pass with 0 failures (cargo test -p commit-reveal-rng).

@vercel

vercel Bot commented Oct 18, 2026

Copy link
Copy Markdown

@p3ris0n is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel.

A member of the Team first needs to authorize it.

@theoneesi theoneesi closed this Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SC-011] Commit-Reveal Random Number Generator (RNG) with Slashing for Non-Disclosure

2 participants