I'm looking to prevent a DDoS attack on a web service, by making the cost of performing an attack prohibitive. Typical users will only need to call out it once a day, and can afford to spend a few CPU cycles on each call, but I want to make it so an attacker making millions of calls would have spend considerably more than I do hosting the service. There's an inherent cost to the service, so I'd like a "proof of work"-like system where I can know the caller has done a specific amount of computation, and can validate that work for cheaper than it costs them.
The message we sign would be something like a timestamp+nonce. On the server side we validate timestamp is fresh, and nonce isn't reused.
Something like bcrypt has the nice property in that it's designed to be costly, has a sliding cost scale, and is intentionally not easy to optimize in hardware. However, there would be a symmetric cost on my side which is a dealbreaker.
Something like RSA signing seems good, the cost to sign is much much greater than the cost to validate*. However, I'm not sure if it's possible to hardware accelerate RSA, and if you could the protection goes out the window. I want an algorithm where the cost/work is an intentional feature, not a byproduct.
Edit: lots of people are suggesting traditional ways to mitigate DDoS attacks. These are great, and are the best first line of defence for traditional services. I'm adding a more detailed explanation of why I'm asking specifically about POW:
- This service is anonymous, with no user account/cookies/etc
- This isn't user facing (no captcha, signups, etc)
- Serving a valid request is somewhat expensive (computationally) so cheaply rejecting invalid requests before processing will save us significant resources (making the service more resilient to DDoS attacks).
- We want to change the economics of the equation: if we make abusing our service more costly than just hosting your own version, then it's not likely to be abused. The service is something anyone could clone, they will just abuse ours to save cost/compute.
- We want to avoid central databases/state-storage as these are typical points of failure/cost in attack/abuse scenarios (and a source of complexity). A "cheap validation" that can be run on cheap and horizontally scaleable edge compute is ideal.
*Source: https://www.fastly.com/blog/is-it-time-for-ecdsa-certificates