Bitcoin Forum
May 25, 2024, 04:27:06 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Provably Fair Script  (Read 1188 times)
Th0ur007 (OP)
Full Member
***
Offline Offline

Activity: 210
Merit: 101


View Profile
May 29, 2016, 05:40:38 PM
 #1

Hello,

I am looking for a provably fair script. I am not sure how the backend process of Provably fair system works.
Can anyone of you provide me with a script, example or a guide where i can have a look?

Looking for some help.
Cheers.
crairezx20
Legendary
*
Offline Offline

Activity: 1638
Merit: 1046



View Profile
May 29, 2016, 05:49:04 PM
 #2

Hello,

I am looking for a provably fair script. I am not sure how the backend process of Provably fair system works.
Can anyone of you provide me with a script, example or a guide where i can have a look?

Looking for some help.
Cheers.
Why dont you try to search it in github maybe you can find what you mean.. honestly i dont know what you want to this script..  you mean its a provably fair checker script?

Try to find here https://github.com/search?utf8=%E2%9C%93&q=Provably+Fair
Th0ur007 (OP)
Full Member
***
Offline Offline

Activity: 210
Merit: 101


View Profile
May 29, 2016, 05:51:57 PM
 #3

Hello,

I am looking for a provably fair script. I am not sure how the backend process of Provably fair system works.
Can anyone of you provide me with a script, example or a guide where i can have a look?

Looking for some help.
Cheers.
Why dont you try to search it in github maybe you can find what you mean.. honestly i dont know what you want to this script..  you mean its a provably fair checker script?

Try to find here https://github.com/search?utf8=%E2%9C%93&q=Provably+Fair
I dont want a provably fair checker, But i need the provably fair script.
Alesfatalis
Member
**
Offline Offline

Activity: 83
Merit: 10

Node.js | Java | C Developer


View Profile
May 31, 2016, 05:05:36 PM
 #4

Here you have an implemention of a provably fair system:
Code:
    //the seed pair itself
            var clientSeed = "your client seed"; //dont forget to exclude the dash and the nonce!
            var serverSeed = "your server seed";

            //bet made with seed pair (excluding current bet)
            var nonce      = 0;

            //crypto lib for hmac function
            var crypto = require('crypto');

            var roll = function(key, text) {

                //create HMAC using server seed as key and client seed as message
                var hash = crypto.createHmac('sha512', key).update(text).digest('hex');

                var index = 0;

                var lucky = parseInt(hash.substring(index * 5, index * 5 + 5), 16);

                //keep grabbing characters from the hash while greater than
                while (lucky >= Math.pow(10, 6)) {
                    index++;
                    lucky = parseInt(hash.substring(index * 5, index * 5 + 5), 16);

                    //if we reach the end of the hash, just default to highest number
                    if (index * 5 + 5 > 128) {
                        lucky = 99.99;
                        break;
                    }
                }

                lucky %= Math.pow(10, 4);
                lucky /= Math.pow(10, 2);

                return lucky;
            }
            console.log(roll(serverSeed, clientSeed+'-'+nonce));
           

You can run this script with node.js. This shows how you calculate the outcome of a dice roll. You just have to make sure that as long as your user is playing with a serverSeed you don't reveal it to him only the hash of the seed is revealed. Make sure to use for each user another serverSeed. The clientSeed is chosen by the user.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!