SigmaRand

SigmaRand is a secure random number generation service for Ergo using the Commit-Reveal protocol. It provides cryptographically secure randomness that is equally unpredictable for all participants, ensuring fair and tamper-proof random number generation for games, lotteries, and smart contracts.

Background

Generating randomness on any blockchain is challenging because every node must come to the same conclusion on the state of the blockchain. Naive approaches to generate randomness can be manipulated by miners or observant attackers. Insecure randomness can be exploited by attackers to gain an unfair advantage in games, lotteries, or any other contracts that rely on random number generation.

Problem Statement

We need a secure random number generation service for Ergo with the following properties:

  • The scheme should be secure.
  • The number generated should be equally unpredictable for all participants, i.e., no participant should have an "upper hand".
  • All participants must agree on the same random number generated.

Cryptographically Secure

Uses the Commit-Reveal protocol to ensure that no participant can manipulate or predict the final random number.

Multi-Party Protocol

Both client and server contribute to the final random number, ensuring equal unpredictability for all participants.

On-Chain Verification

All commitments and reveals are stored on the Ergo blockchain, providing transparent and verifiable randomness.

XOR-Based Generation

Final random number is the XOR of client and server contributions, ensuring neither party can choose an advantageous value.

Cloud-Native Architecture

Built with serverless components (AWS Lambda, Step Functions) for scalable, pay-per-use random number generation.

Smart Contract Integration

Seamlessly integrates with Ergo smart contracts for games, lotteries, and DeFi applications requiring randomness.

The Commit-Reveal Protocol

The Commit-Reveal protocol is a multi-party scheme for generating random numbers. It consists of two phases: commit and reveal.

Commit Phase

  • Each participant generates a random seed
  • Calculates the hash value of their seed
  • Submits a commitment containing the hash
  • Smart contract stores commitments on blockchain

Reveal Phase

  • Participants reveal their original seed values
  • Hash values are verified against commitments
  • Final random number is calculated via XOR
  • Result is stored on-chain for verification

How It Works

  1. Party A generates a random number, randomA.
  2. Party A sends a message with the hash of randomA, hash(randomA). This commits Party A to the value randomA.
  3. Party B sends a message with another random number, randomB.
  4. Party A reveals the value of randomA in a third message.
  5. Both parties accept the random number as randomA ^ randomB, the exclusive OR (XOR) of the two values.

The advantage of using XOR is that the final random number is determined equally by both parties, ensuring that neither party can choose an advantageous "random" value.

Use Cases

  • NFT pack opening and rarity distribution
  • Decentralized lotteries and gambling applications
  • Fair game mechanics in blockchain games
  • Random selection in DAO governance
  • Secure key generation for cryptographic applications
  • Random sampling for statistical analysis

Example: Opening a "Pack" of NFTs

Let's walk through an example problem that uses this service. We have a "pack" token when "opened" will redeem a fixed number of random NFTs of varying "rarity".

  1. The dApp first generates a random number randomA and makes a RegisterRandomNumberGenerationTask API call.
  2. The transaction locks the pack token and hash(randomA) in a UTXO.
  3. Our service then generates randomB and spends this UTXO in the Commit Transaction.
  4. The dApp knows when the Commit Transaction is confirmed using the GetRandomNumberGenerationStatus API.
  5. Once the task is in COMMITTED the dApp reveals randomA using RevealRandomNumber API.
  6. The server then locks the pack token and randomA ^ randomB in the dApp specified contract.
  7. The dApp can now use this random number generated and the pack token to send the end user the required NFTs.

API Endpoints

Register Random Number Generation

POST /beta/random-number/register

Registers a new random number generation task and locks tokens in a UTXO.

Get Task Status

GET /beta/random-number/task/{taskId}

Check the status of a random number generation task.

Reveal Random Number

POST /beta/random-number/reveal

Reveal the client-side random number to complete the protocol.