provablyfair

package module
v0.0.0-...-6930c7b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2020 License: MIT Imports: 8 Imported by: 1

README

provablyfair

Provably fair generator

Referenced from https://github.com/tyler-smith/provablyfair-dice

This is changed based on private usage.

Example usage

  serverSeed, err := provablyfair.GenerateNewSeed(32)
	if err != nil {
		panic(err)
	}
	client := &provablyfair.Client{
		ServerSeed: serverSeed,
	}

  clientSeed, err := provablyfair.GenerateNewSeed(32)
	if err != nil {
		panic(err)
	}

  rollNum, serverSeed, nonce, err := client.Generate(clientSeed)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateNewSeed

func GenerateNewSeed(byteCount int) ([]byte, error)

GenerateNewSeed generate new seed

func Verify

func Verify(clientSeed []byte, serverSeed []byte, nonce uint64, randNum float64) (bool, error)

Verify takes a state and checks that the supplied number was fairly generated

func VerifyFromString

func VerifyFromString(clientSeed, serverSeed string, nonce uint64, randNum float64) (bool, error)

VerifyFromString verify from string clientSeed and serverSeed

Types

type Client

type Client struct {
	ServerSeed []byte
	Nonce      uint64
	// contains filtered or unexported fields
}

Client Provably fair client

func (*Client) Generate

func (c *Client) Generate(clientSeed []byte) (float64, []byte, uint64, error)

Generate generate new number between 0 and 100. Returns (new number, serverSeed, nonce, error)

func (*Client) GenerateFromString

func (c *Client) GenerateFromString(clientSeed string) (float64, []byte, uint64, error)

GenerateFromString generate new number from hex string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL