Skip to content

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

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

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

Conversation

@p3ris0n

@p3ris0n p3ris0n commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Overview

This pull request implements key smart contracts for the Web3 Student Lab Post-Wave Production Deployment Initiative, covering on-chain cryptographic randomness, educational content management and verification, continuous token streaming, and multi-party treasury security.

Closes #1632
Closes #1633
Closes #1629
Closes #1630


Detailed Changes by Module

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

Closes #1632

  • Domain Category: Cryptographic Games & Randomness
  • Key Files:
    • contracts/commit_reveal_rng/src/lib.rs
    • contracts/commit_reveal_rng/src/entropy.rs
    • contracts/commit_reveal_rng/src/slashing.rs
  • Implementation Highlights:
    • Designed and deployed a commit-reveal randomness beacon contract resistant to miner/validator frontrunning and timestamp manipulation.
    • Implemented secure participant registration accepting secret salt hashes during the commit phase ($H = \text{SHA256}(s)$) alongside deposit escrow (commit_with_deposit).
    • Implemented 32-byte bitwise XOR entropy accumulation (xor_bytes32, accumulate_entropy) across valid salt disclosures, hashed via SHA-256 upon finalization (finalize_entropy) to guarantee uniform random output resistant to single-party bias.
    • Built an automated deposit slash and redistribution mechanism: refunds collateral to honest revealers, slashes deposits of participants failing to disclose secrets prior to deadline (slash_non_revealers), and redistributes confiscated collateral equally among honest participants (redistribute_slashed_stake).

2. [SC-012] On-Chain Content Management System (CMS) with Versioned Content Merkle Roots

Closes #1633

  • Domain Category: Content Integrity & Versioning
  • Key Files:
    • contracts/content_management_system/src/lib.rs
    • contracts/content_management_system/src/versioning.rs
  • Implementation Highlights:
    • Implemented an immutable on-chain curriculum and challenge registry ensuring course materials and exam specifications cannot be tampered with.
    • Enforced strict role-based access control (RBAC), verifying that only authenticated course author addresses can publish new curriculum iterations or update metadata.
    • Retained an immutable, append-only historical version log linking each curriculum version with its corresponding IPFS content identifier (CID) and Merkle root.
    • Built on-chain cryptographic verification allowing student exercise and challenge solutions to be authenticated against the immutable version Merkle root.

3. [SC-008] Real-Time Sablier-Style Payment Streaming Contract with Cliff & Cancellation Refunds

Closes #1629

  • Domain Category: Payments & Token Streaming
  • Key Files:
    • contracts/payment_streaming/src/lib.rs
    • contracts/payment_streaming/src/stream.rs
    • contracts/payment_streaming/src/types.rs
  • Implementation Highlights:
    • Created a linear payment streaming smart contract on Soroban enabling granular, continuous disbursement of educational grants and student stipends.
    • Implemented precise integer math for the linear accrual formula: $\text{accrued} = \text{deposit} \times \frac{t - t_{\text{start}}}{t_{\text{end}} - t_{\text{start}}}$.
    • Enforced a hard cliff timestamp barrier: strictly prohibits token withdrawals by the recipient before the cliff timestamp has elapsed.
    • Added equitable stream cancellation logic: automatically disburses accrued tokens up to the cancellation timestamp to the recipient while refunding the unvested remaining balance to the stream creator.

4. [SC-009] Multisig Wallet Contract with M-of-N Thresholds, Time-Locks & Emergency Freeze

Closes #1630

  • Domain Category: Security & Multi-Party Control
  • Key Files:
    • contracts/multisig_wallet_timelock/src/lib.rs
    • contracts/multisig_wallet_timelock/src/signers.rs
    • contracts/multisig_wallet_timelock/src/execution.rs
  • Implementation Highlights:
    • Developed an $M$-of-$N$ threshold multisig contract eliminating single-owner admin accounts as central points of failure in treasury operations.
    • Built proposal lifecycle handlers supporting proposal submission, independent cryptographic approvals from verified signer addresses, and parameter-validated execution.
    • Enforced validation invariants ($1 \le M \le N$, no duplicate signers, no duplicate approvals per signer key).
    • Integrated an emergency freeze switch callable by designated security council members that immediately halts all outbound contract transactions during anomalous or critical conditions until formally unfreezed.

Acceptance Criteria Checklist


Verification & Testing

  • Unit and integration tests for each contract crate pass with 0 failures (cargo test --workspace).
  • Edge cases validated:
    • Commit salt mismatch rejections and post-deadline reveal slashing.
    • Non-author publication unauthorized exceptions and Merkle proof verification.
    • Pre-cliff withdrawal reverts and mid-stream cancellation split calculations.
    • Below-threshold multisig execution rejection, duplicate signer rejection, and frozen transaction execution blocks.

@drips-wave

drips-wave Bot commented Oct 18, 2026

Copy link
Copy Markdown

@p3ris0n Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment