{"id":26685368,"url":"https://github.com/tahirmurata/vero","last_synced_at":"2025-09-26T15:56:16.749Z","repository":{"id":225637891,"uuid":"766475272","full_name":"tahirmurata/vero","owner":"tahirmurata","description":"The vero package generates random numbers for online casinos games such as dice, roll, crash, etc.","archived":false,"fork":false,"pushed_at":"2024-03-08T22:38:32.000Z","size":39703,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-23T11:23:19.349Z","etag":null,"topics":["algorithms","alogrithm","casino","gamble","go","golang","hash","provably-fair","stake"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tahirmurata.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-03T11:25:08.000Z","updated_at":"2024-11-14T16:55:58.000Z","dependencies_parsed_at":"2024-06-21T13:10:58.584Z","dependency_job_id":null,"html_url":"https://github.com/tahirmurata/vero","commit_stats":null,"previous_names":["pastc/vero","tahirmurata/vero"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tahirmurata%2Fvero","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tahirmurata%2Fvero/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tahirmurata%2Fvero/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tahirmurata%2Fvero/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tahirmurata","download_url":"https://codeload.github.com/tahirmurata/vero/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245632414,"owners_count":20647194,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","alogrithm","casino","gamble","go","golang","hash","provably-fair","stake"],"created_at":"2025-03-26T10:15:23.033Z","updated_at":"2025-09-26T15:56:11.713Z","avatar_url":"https://github.com/tahirmurata.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vero\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/pastc/vero.svg)](https://pkg.go.dev/github.com/pastc/vero/v2)\n\nThe vero package generates random numbers for online casinos games such as dice, roll, crash, etc.\n\nAll the algorithms are provably fair.\n\n## Install\n\n```shell\ngo get github.com/pastc/vero/v2\n```\n\n## Features\n\n- No third-party dependencies\n- As minimal as possible\n- Provably fair\n- Many games:\n  - Crash\n  - Dice\n  - Roll\n  - Plinko\n\n## Guide\n\n### Common arguments\n\n```go\n// Generated automatically. Is private and is changed periodically. It should become public after being decommissioned.\nvar serverSeed string\n\n// Generated uniquely to each player. Can be changed anytime by the player themselves.\nvar clientSeed string\n\n// Generated automatically. Is public and is changed periodically.\nvar publicSeed string\n\n// A number that is incremented by 1 for each game played.\nvar nonce int\n\n// A number that is incremented by 1 if the randomly generated value goes out of bounds and eventually exhausts all available random numbers within the available hash.\n// Should be 0 when calling the function from outside.\nvar iteration int\n```\n\n### Crash\n\n#### Arguments\n\n```go\nvar serverSeed string\n// houseEdge i.e, percentage that the house gets.\nvar houseEdge float64\n```\n\n#### Example\n\n```go\n// Remember to divide the crashPoint by 100 to get the percentage\ncrashPoint, err := vero.Crash(serverSeed, houseEdge)\nif err != nil {\n  log.Fatal(err)\n}\n```\n\n#### Explanation\n\n1. The function calculates an HMAC-SHA256 hash using the `serverSeed` and a combined `seed`. This hash is used as a\n   source of randomness.\n\n2. The most significant 52 bits of the hash are extracted and interpreted as a hexadecimal number, which is then\n   converted to an integer (`h`).\n\n3. The value `e` (2^52) is calculated, which is approximately 4.5035e+15. This value represents the maximum value that\n   can be represented precisely in the mantissa of a 64-bit floating-point number.\n\n4. The function then calculates the crash point multiplier (`result`) using the values of `h` and `e`. The\n   formula `(100*e - float64(h)) / (e - float64(h))` maps the value of `h` (which is in the range `[0, e]`) to a value\n   in the range `[100, infinity]`.\n\n5. The `houseEdgeModifier` is calculated based on the specified house edge percentage. For example, if the house edge is\n   5%, the `houseEdgeModifier` will be 0.95 with the lowest crashing point of 100.\n\n6. The final crash point multiplier (`endResult`) is calculated by multiplying result by `houseEdgeModifier` and\n   ensuring that it is at least 100 (the minimum crash point).\n\n7. The function returns the crash point multiplier `endResult` as an integer, which represents the crash point\n   multiplier.\n\n### Dice\n\n#### Arguments\n\n```go\nvar serverSeed string\nvar clientSeed string\nvar nonce int\nvar iteration int\n```\n\n#### Example\n\n```go\n// Remember to divide the value by 100 to get a number from 0 to 99.99\nvalue, err := vero.Dice(serverSeed, clientSeed, nonce, 0)\nif err != nil {\n  log.Fatal(err)\n}\n```\n\n#### Explanation\n\n1. The function calculates an HMAC-SHA512 hash using the `serverSeed` and a combined `seed`. This hash is used as a\n   source of randomness.\n\n2. The `GetLucky` function extracts a substring of length 5 from the `hash` string starting at the position `index*5`.\n   This substring is then converted from a hexadecimal string to an integer. The function returns the random integer and\n   any error that may have occurred during the conversion.\n\n3. The for loop ensures that the `lucky` integer is above 10^6 (1000000) since it will be divided by 10^4 (10000) later.\n\n   1. If it is under 10^6, then the `index` is incremented by 1 and the `GetLucky` is called again.\n\n   2. This continues until the `index` goes out of bounds. If that happens, the `Dice` function is called with the `iteration` value incremented by 1.\n\n4. The final number (`luckyNumber`) is calculated by using the formula `math.Mod(float64(lucky), math.Pow(10, 4))` which\n   divides the value of lucky by 10^4 (10000) and gets the remainder. This ensures that the final number is in the range\n   of `[0, 9999]`.\n\n5. The function returns the random value `luckyNumber`.\n\n#### Explanation\n\n### Roll\n\n#### Arguments\n\n```go\nvar serverSeed string\nvar publicSeed string\nvar nonce int\n// maximum represents the maximum value that can be rolled, counting from 0.\n//\n// Example if maximum is 5:\n// 0, 1, 2, 3, 4\nvar maximum int\n```\n\n#### Example\n\n```go\n// Use something like a map to map the value to colors, bait, etc.\nvalue, err := vero.Roll(serverSeed, publicSeed, nonce, maximum)\nif err != nil {\n  log.Fatal(err)\n}\n```\n\n#### Explanation\n\n1. The function calculates an HMAC-SHA256 hash using the `serverSeed` and a combined `seed`. This hash is used as a\n   source of randomness.\n\n2. The `GetRandomInt` function extracts a substring of length 13 from the `hash` string starting at the position `0`.\n\n   1. This substring is then converted from a hexadecimal string to an integer.\n\n   2. The value `e` (2^52) is calculated, which is approximately 4.5035e+15. This value represents the maximum value\n      that can be represented precisely in the mantissa of a 64-bit floating-point number.\n\n   3. The formula `math.Floor((float64(valueFromHash) / e) * float64(max))` calculates a random number that is in the\n      range of `[0, max]`.\n\n   4. The function returns the random integer and any error that may have occurred during the conversion.\n\n3. The function returns the random value `rollValue`.\n\n### Plinko\n\n#### Arguments\n\n```go\nvar serverSeed string\nvar clientSeed string\nvar nonce int\nvar iteration int\n// rows represents the number of rows in the triangle.\nvar rows int\n```\n\n#### Example\n\n```go\n// column represents the index of the column that the ball dropped into.\ncolumn, err := vero.Plinko(serverSeed, clientSeed, nonce, 0, rows)\nif err != nil {\n  log.Fatal(err)\n}\n```\n\n#### Explanation\n\n```\nCount it like this.\n\n0      0\n1     0 1\n2    0 1 2\n3   0 1 2 3\n```\n\n1. Variable `coordinate` is initialised to track the net deviation from the center position.\n\n2. The for loop loops for any number in the range `[0, rows]`.\n\n   1. The function calculates an HMAC-SHA256 hash using the `serverSeed` and a combined `seed`. This hash is used as a\n      source of randomness.\n\n   2. The `GetLucky` function extracts a substring of length 5 from the `hash` string starting at the\n      position `index*5`. This substring is then converted from a hexadecimal string to an integer. The function\n      returns the random integer and any error that may have occurred during the conversion.\n\n   3. The for loop ensures that the `lucky` integer is above 10^6 (1000000) since it will be divided by 10^4 (10000)\n      later. If it is under 10^6, then the `index` is incremented by 1 and the `GetLucky` is called again. This\n      continues until the `index` goes out of bounds. If that happens, the `Dice` function is called with\n      the `iteration` value incremented by 1.\n\n   4. The final number (`luckyNumber`) is calculated by using the formula `math.Mod(float64(lucky), math.Pow(10, 4))`\n      which divides the value of lucky by 10^4 (10000) and gets the remainder. This ensures that the final number is in\n      the range of `[0, 9999]`.\n\n   5. If the luckyNumber is in the range of `[0, 4999]` the ball goes to the left. (coordinate -= 1)\n\n      If the luckyNumber is in the range of `[5000, 9999]` the ball goes to the right. (coordinate += 1)\n\n3. The function returns the column number `(rows + coordinate) / 2` that the ball landed on.\n\n## Documentation\n\nFull `go doc` style documentation for the package can be viewed online without\ninstalling this package by using the GoDoc site here:\nhttps://pkg.go.dev/github.com/pastc/vero\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftahirmurata%2Fvero","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftahirmurata%2Fvero","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftahirmurata%2Fvero/lists"}