Open Source Algorithm

Verification

Our algorithm is fully disclosed. You can verify any DiceTrust draw independently — without having to trust us.

Downloads
Quick Start

Node.js

Terminal
# Download script
curl -O https://dicetrust.de/verify/dicetrust-verify.js

# Run example
node dicetrust-verify.js

Browser

HTML
<script src="https://dicetrust.de/verify/dicetrust-verify.js"></script>
<script>
  const result = await DiceTrust.verifyDraw({
    participants: [
      { id: '1', name: 'Alice' },
      { id: '2', name: 'Bob' },
    ],
    drandRound: 12345678,
    winnersCount: 1,
  });
  console.log(result);
</script>
Algorithm — dicetrust-v1.0

The DiceTrust algorithm combines a commitment scheme with decentralized randomness to guarantee tamper-proof draws.

01

Participant Hash

The participant list is sorted alphabetically by ID and hashed. This hash is displayed before the draw and cannot be changed.

participants.sortBy(id)
participantHash = SHA256(JSON.stringify(participants))
02

drand Randomness

The next drand round is set. drand is a decentralized network of 10+ independent operators that generates public random numbers.

// drand quicknet: new randomness every 3 seconds
drandRound = currentRound + 2
drandRandomness = fetch(api.drand.sh/{round}).randomness
03

Seed Derivation

The final seed is calculated from all public inputs. Since all inputs are public, anyone can recalculate the seed.

input = participantHash | drandRound | drandRandomness
seed = SHA256(input)  // 64 hex characters
04

Deterministic Draw

The seed initializes a Mulberry32 PRNG and the participant list is shuffled using Fisher-Yates. The first N entries are the winners.

seedNumber = parseInt(seed[0:8], 16)  // First 8 hex → 32-bit
rng = Mulberry32(seedNumber)
shuffled = FisherYatesShuffle(participants, rng)
winners = shuffled.slice(0, winnersCount)
Verifying a Draw

To verify a DiceTrust draw, you need the data from the results page:

verify-example.js
const { verifyDraw } = require('./dicetrust-verify.js');

// Data from the DiceTrust result page
const result = await verifyDraw({
  participants: [
    { id: 'abc123', name: 'Participant 1' },
    { id: 'def456', name: 'Participant 2' },
    { id: 'ghi789', name: 'Participant 3' },
  ],
  drandRound: 12345678,
  winnersCount: 1,

  // Optional: Expected values from the result page
  expectedParticipantHash: 'a1b2c3d4...',
  expectedSeed: 'e5f6g7h8...',
  expectedWinnerIds: ['def456'],
});

if (result.valid) {
  console.log('✓ Draw verified!');
  console.log('Winners:', result.details.winners);
} else {
  console.log('✗ Verification failed:');
  result.errors.forEach(e => console.log('  -', e.message));
}