provably-fair | PHP implementation of Bustabit 's Provably Fair system

 by   rogervila PHP Version: 3.0.0-rc.2 License: No License

kandi X-RAY | provably-fair Summary

kandi X-RAY | provably-fair Summary

provably-fair is a PHP library. provably-fair has no vulnerabilities and it has low support. However provably-fair has 3 bugs. You can download it from GitHub.

PHP implementation of Bustabit's Provably Fair system. Demo here.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              provably-fair has a low active ecosystem.
              It has 12 star(s) with 1 fork(s). There are 2 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              provably-fair has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of provably-fair is 3.0.0-rc.2

            kandi-Quality Quality

              provably-fair has 3 bugs (0 blocker, 0 critical, 2 major, 1 minor) and 13 code smells.

            kandi-Security Security

              provably-fair has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              provably-fair code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              provably-fair does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              provably-fair releases are available to install and integrate.
              Installation instructions are not available. Examples and code snippets are available.
              It has 258 lines of code, 27 functions and 15 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed provably-fair and discovered the below as its top functions. This is intended to give you an instant insight into provably-fair implemented functionality, and help decide if they suit your requirements.
            • Checks if the hash is divisible .
            • Calculate the hash .
            • Generate a server seed
            • Assert that hash algorithm is valid .
            • Assert that seed is valid
            • Set value .
            • Get value .
            Get all kandi verified functions for this library.

            provably-fair Key Features

            No Key Features are available at this moment for provably-fair.

            provably-fair Examples and Code Snippets

            No Code Snippets are available at this moment for provably-fair.

            Community Discussions

            Trending Discussions on provably-fair

            QUESTION

            How to generate provably fair dice rolls in C#?
            Asked 2017-Jun-13 at 14:58

            I looked into provably fair random numbers, and came across this website: https://dicesites.com/provably-fair

            First off, what class should be used for the server sided hash? There are so many hash algorithms like SHA512, SHA256 or SHA384Cng and I do not understand the difference between them.

            Second off, what method would be used to convert from the unhashed seed to the hashed seed, and what method would be used to take the string for the seed provided by the user into account during the hash creation. Also, is the nonce simply added at the end of the string provided by the user in order to prevent duplicate hashes?

            Third off, I do not understand why the hashed server seed is originally a SHA256 hash but is later used to calculate a HMAC SHA512 hash.

            Lastly, what would be used to convert the first 5 characters of the final generated hash to a roll number?

            I have had no luck in finding any examples of any random number generators that use a server seed and client seed, only things like System.Security.Cryptography.RandomNumberGenerator.

            ...

            ANSWER

            Answered 2017-Jun-13 at 14:58

            The page you link to describes the process, however I will try to go in to more detail and provide a C# example.

            First there are two hashings that happen. One general hash to prove that the server is not changing the server key as you gamble, this hash is not secret and is given to the player at the start of play. There is also a keyed hash (called a HMAC) to actually generate the dice rolls and uses a combination of the server key, the data the user provided, and a number that counts up.

            Here is the process that happens:

            1. The server generates a secret key for the play session and sets a counter to 0.
            2. SHA256 is used on the key to generate a hash, this hash is given to the player. This hash is not used in any math to generate the dice rolls, it is only used for verification by the player.
            3. The player requests a dice roll and provides a phrase to be used in the generation of the number.
            4. The server uses a SHA512-HMAC using secret key as the key then the string the user provided plus "-" plus the number of the counter set in step 1 to generate a hash.
            5. The server increments the counter by 1, this is done because the same server key is used every time and if the same user string was used it would just generate the same number over and over.
            6. The server takes the first 21 bits of the hash generated, converts it to a int, it then checks to see if the int is larger than 999999 if it is it keeps repeating till it finds a number that is not over 999999.
            7. It takes the number from step 6 and does number%(10000)/100.0 on it to get a floating point number.
            8. That floating point number is returned to the user.
            9. Either repeat starting at step 3 for a new roll or continue to step 10.
            10. The player signals the play session is over. The server returns the secret key to the user and restarts at step 1.

            The user once he gets the secret key from step 10 can hash it using SHA256 and check that he gets the same hash he was told at the start of the play session. He can then re-do all the steps the server did now that he has the secret key and verify that the server did not fake any dice rolls.

            How to do this in code:

            Source https://stackoverflow.com/questions/44508758

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install provably-fair

            You can download it from GitHub.
            PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/rogervila/provably-fair.git

          • CLI

            gh repo clone rogervila/provably-fair

          • sshUrl

            git@github.com:rogervila/provably-fair.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link