{"_id":"@chanceprotocol/uniform-random-number","name":"@chanceprotocol/uniform-random-number","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@chanceprotocol/uniform-random-number","version":"0.1.0","description":"PoolManager Lossless Pool Smart Contracts","main":"index.js","repository":{"type":"git","url":"git+ssh://git@github.com/pooltogether/pooltogether-contracts.git"},"author":{"name":"Brendan Asselstine brendan@chanceprotocol.us"},"dependencies":{},"devDependencies":{"chai":"^4.2.0","chai-as-promised":"^7.1.1","solc":"0.5.12","solidity-coverage":"0.7.0-beta.2","eth-gas-reporter":"0.2.0","ethers":"^4.0.40","ganache-cli":"6.7.0","mocha-junit-reporter":"1.23.1","truffle":"5.0.42"},"scripts":{"test":"truffle test --migrations_directory ./migrations/empty","coverage":"COVERAGE=true truffle run coverage --migrations_directory ./migrations/empty","compile":"truffle compile"},"bugs":{"url":"https://github.com/pooltogether/pooltogether-contracts/issues"},"homepage":"https://github.com/pooltogether/pooltogether-contracts#readme","_id":"@chanceprotocol/uniform-random-number@0.1.0","_integrity":"sha512-L+Advwn+g9YJBwtcaBxVj6sk8HF+y6LGnJZ7QbkBO/rz6FESsTKQEWQoimPr2/av1IIqvrCROTdc8XvgHeZvuQ==","_resolved":"/tmp/5e39d7e980edb8528d992ecc1e30dc73/chanceprotocol-uniform-random-number-0.1.0.tgz","_from":"file:chanceprotocol-uniform-random-number-0.1.0.tgz","_nodeVersion":"16.15.1","_npmVersion":"9.6.5","dist":{"integrity":"sha512-L+Advwn+g9YJBwtcaBxVj6sk8HF+y6LGnJZ7QbkBO/rz6FESsTKQEWQoimPr2/av1IIqvrCROTdc8XvgHeZvuQ==","shasum":"d8c65f917e4f19f4b4da4d62e238dd1b4ac99064","tarball":"https://registry.npmjs.org/@chanceprotocol/uniform-random-number/-/uniform-random-number-0.1.0.tgz","fileCount":15,"unpackedSize":44171,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB07zIa3TGZ/fZbF4TJH41ka4c3uuDZZbPGGoGiUoeUUAiEA/Htpj7Zzr6bvmNiOakKcyeEPHKf8SNWj026tUsO5x24="}]},"_npmUser":{"name":"chanceprotocol","email":"chance@netixsol.com"},"directories":{},"maintainers":[{"name":"chanceprotocol","email":"chance@netixsol.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/uniform-random-number_0.1.0_1692257229077_0.8877750503250164"},"_hasShrinkwrap":false}},"time":{"created":"2023-08-17T07:27:09.005Z","0.1.0":"2023-08-17T07:27:09.337Z","modified":"2023-08-17T07:27:09.583Z"},"maintainers":[{"name":"chanceprotocol","email":"chance@netixsol.com"}],"description":"PoolManager Lossless Pool Smart Contracts","homepage":"https://github.com/pooltogether/pooltogether-contracts#readme","repository":{"type":"git","url":"git+ssh://git@github.com/pooltogether/pooltogether-contracts.git"},"author":{"name":"Brendan Asselstine brendan@chanceprotocol.us"},"bugs":{"url":"https://github.com/pooltogether/pooltogether-contracts/issues"},"readme":"# Uniform Random Number\n\n[![CircleCI](https://circleci.com/gh/pooltogether/uniform-random-number.svg?style=svg)](https://circleci.com/gh/pooltogether/uniform-random-number)\n\nThis Solidity library eliminates modulo bias when using a large number to select from a limited range of numbers.\n\nFor example:\n\n- Assume the max unsigned integer is 5\n- random() selects an integer between 0 and 5\n\nWe want to use the random number to select a value between 0 and 3.\n\nselection = random() % 4\n\nThe above might do, until we realize that:\n\n| random() | selection |\n| ---------| --------- |\n| 0 | 0 |\n| 1 | 1 |\n| 2 | 2 |\n| 3 | 3 |\n| 4 | 0 |\n| 5 | 1 |\n\nNotice that 0 and 1 are overrepresented.  This is modulo bias, and is problematic when making *fair* selection algorithms.\n\nThis library mitigates modulo bias using an algorithm described in [this article](https://medium.com/hownetworks/dont-waste-cycles-with-modulo-bias-35b6fdafcf94).\n\n# Installation\n\nAdd to your `package.json`:\n\n```json\n{\n  \"dependencies\": {\n    \"@chanceprotocol/uniform-random-number\": \"pooltogether/uniform-random-number#master\"\n  }\n}\n```\n\n# Usage\n\n```solidity\nimport \"pooltogether/uniform-random-number/contracts/UniformRandomNumber.sol\";\n\n// ...\n\nuint256 randomNumber = uint256(keccak('Hello'));\nuint256 upperLimit = 10;\nUniformRandomNumber.uniform(randomNumber, upperLimit);\n```\n\n# Audit\n\nThis code has been audited by [OpenZeppelin](https://openzeppelin.com/) and [Quantstamp](https://quantstamp.com/) as part of the [PoolTogether codebase](https://github.com/pooltogether/pooltogether-contracts).\n","readmeFilename":"README.md"}