| Crates.io | miden-pow-rate-limiter |
| lib.rs | miden-pow-rate-limiter |
| version | 0.12.4 |
| created_at | 2025-11-11 00:19:54.446496+00 |
| updated_at | 2025-12-05 22:35:36.767855+00 |
| description | Miden Proof-of-Work rate limiter |
| homepage | https://miden.xyz |
| repository | https://github.com/0xMiden/miden-faucet |
| max_upload_size | |
| id | 1926450 |
| size | 46,672 |
This crate provides a proof-of-work (PoW) functionality, implementing a rate-limiting mechanism based on computational challenges.
The PoW rate limiter operates through a challenge-response mechanism:
The PoW rate limiter uses a domain concept to provide isolated rate limiting for different services or use cases. A domain is a 32-byte identifier that represents a unique service or context that requests challenges.
The PoWRateLimiterConfig struct allows you to customize the behavior of the rate limiter:
challenge_lifetime: How long a challenge remains valid after generation. After this duration, challenges expire and cannot be submitted. Choose based on expected solving time and security requirements.
growth_rate: Controls how aggressively difficulty increases with more active challenges. The number of active challenges gets multiplied by the growth rate to compute the load difficulty, so higher values mean more aggressive rate limiting.
baseline: Sets the initial difficulty baseline. Higher baseline values make challenges harder from the start. Range: 0-32.
cleanup_interval: How often the system removes expired challenges from memory.
A challenge solution is valid when:
H(challenge_string, nonce) interpreted as a big-endian u64 is less than the targetThe system automatically adjusts challenges difficulty based on usage and the request complexity.
The challenge target $t$ is computed as follows:
$$ t = \dfrac{2^{64}} {d} $$
We call $d$ "difficulty" such that $log_2(d)$ is the number of bits of work that we need to do to solve the challenge. We compute it as:
$$ d = 2^b \centerdot c \centerdot n \centerdot g $$
Where:
Overall, as more users solve challenges the difficulty increases, providing automatic rate limiting.
This project is MIT licensed.