Hey everyone,
Today, I'm excited to share a new tool I've been working on, something a bit different from my usual Hive-specific scripts but definitely useful for a community I also love: tabletop roleplayers! Introducing the Ultimate Dice Roller, now live at:
https://dice.thecrazygm.com
Why Another Dice Roller? Provable Fairness!
We all love the feel of physical "click-clack math rocks," but when playing RPGs online (like over Discord, Roll20, etc.), we often rely on digital rollers. How do you really know they're fair and not just spitting out pre-determined numbers or being influenced in some way?
The goal of the Ultimate Dice Roller is to be provably fair. This means that every roll generates a cryptographic proof that can, in theory, be independently verified by anyone, assuring you that the outcome was truly based on the inputs and a transparent process.
How Does the "Provably Fair" Part Work (Simply Put)?
The system uses a few key pieces of information to generate a roll:
- Server Seed: A secret piece of data known by the server.
- Client Seed: A piece of data provided or known by your browser/client.
- Nonce: A number that starts at 0 and typically increases with each roll made with the same server/client seed pair. This ensures you get a different result even if the seeds stay the same for a bit.
Here’s a simplified rundown of what happens when you roll:
- Your browser and the server establish a
client_seed
and aserver_seed
. (Currently, for this proof-of-concept version, both of these are generated randomly for each interaction to demonstrate the mechanism). - These seeds, along with the
nonce
, are combined. Specifically, a message likeclient_seed:nonce
is created. - This message is then cryptographically hashed with the
server_seed
using a standard algorithm called HMAC-SHA256. This produces a unique, long hexadecimal string (the "proof"). - This hexadecimal proof string is then used to determine your dice results. For example, a chunk of the hex string is converted to a number, and then a modulo operation gives you the die face (e.g.,
(number_from_hash % 20) + 1
for a d20). - Crucially, after the roll, the tool shows you the
server_seed
it used, yourclient_seed
, thenonce
, the finalproof
(hash), and of course, your dice results. With all these inputs, anyone can re-run the exact same calculation and verify that the dice results match the given proof.
The provably_fair_roll
function in the backend takes these seeds and the nonce, creates the HMAC-SHA256 digest, and then deterministically derives the dice results from that digest.
Future Plans: Hive Integration for True Randomness!
Right now, as a proof of concept, the server_seed
and client_seed
are generated randomly by the application. The next big step to make this truly and transparently provably fair is to tie the seed generation to an external, unpredictable, and publicly verifiable source. My plan is to integrate this with the Hive blockchain by using hashes from the latest Hive blocks to generate the server_seed
(and potentially influence the client_seed
generation). This way, the "secret" server seed isn't just generated by my server but is derived from a public, immutable ledger.
Not as Fun as Physical Dice, But Great for Online Play!
I know, I know, it's not quite the same tactile joy as rolling your favorite set of magical lucky dice. But for online games, especially in Discord or other platforms where you need a quick, reliable, and trustworthy dice roll, I think this will be a great utility.
Here's a peek at the interface:
The tool features quick roll input (like 2d6+3
), dice cards for common types, and a roll history. And, of course, there's a page where you can take the details from any roll and verify the proof yourself .
Check it Out!
Give it a whirl at https://dice.thecrazygm.com and let me know what you think! It's still a work in progress, especially with the Hive integration for seeds still to come, but the core provably fair mechanism is there to play with.
As always,
Michael Garcia a.k.a. TheCrazyGM