
Product
Socket Firewall Now Blocks Malicious VS Code and Open VSX Extensions
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.
@leap-network/uniform-random-number
Advanced tools
This Solidity library eliminates modulo bias when using a large number to select from a limited range of numbers.
For example:
We want to use the random number to select a value between 0 and 3.
selection = random() % 4
The above might do, until we realize that:
| random() | selection |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
| 4 | 0 |
| 5 | 1 |
Notice that 0 and 1 are overrepresented. This is modulo bias, and is problematic when making fair selection algorithms.
This library mitigates modulo bias using an algorithm described in this article.
Add to your package.json:
{
"dependencies": {
"@leap-network/uniform-random-number": "pooltogether/uniform-random-number#master"
}
}
import "pooltogether/uniform-random-number/contracts/UniformRandomNumber.sol";
// ...
uint256 randomNumber = uint256(keccak('Hello'));
uint256 upperLimit = 10;
UniformRandomNumber.uniform(randomNumber, upperLimit);
This code has been audited by OpenZeppelin and Quantstamp as part of the PoolTogether codebase.
FAQs
PoolManager Lossless Pool Smart Contracts
We found that @leap-network/uniform-random-number demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.

Research
More than 140 Mastra npm packages were compromised in a supply chain attack that used a typosquatted dependency to deliver a cross-platform infostealer during installation.

Research
/Security News
A new npm package tests AI malware scanners with prompt injection, safety-triggering comments, context flooding, and obfuscated JavaScript.