First pass at proof of work client for Arti
This is a first pass at hooking up the client side of onion service proof-of-work, using the algorithm implementation that's already checked in.
Adds protocol support for the PoW parameters and solution, and some new client-side logic for adjusting the effort and running the puzzle in an algorithm-independent way.
Tested with the 'onion-pow-example' tool: https://gitlab.torproject.org/tpo/onion-services/onion-pow-example The tool uses c-tor still both to host the service and to generate load, but I connect to its URL using arti successfully and see its Ok result with good PoW solution.
It's missing configuration support. We use the default equix
options. This is usually fine, but we have an opportunity to implement an option equivalent to c-tor's 'CompiledProofOfWorkHash' if we like. We could also add more config options for the client-side effort settings that are hardcoded in c-tor, if we like.
It performs each solve on a single-use thread. This isn't horrible but we probably want this to have some kind of thread pool with limited and configurable concurrency, mediated by the rtcompat layer.
Right now we use only one CPU core. We could use multiple cores and solve faster in most cases, using additional code at the tor_hspow::client layer.
I started implementing cancellation support but it's incomplete. Like in c-tor, solves will always run to completion. (We have a relatively small maximum effort because of this)
Currently solves are performed only as-needed, without any kind of queueing. We could be smarter both about not wasting completed solutions and about overlapping the solve with other operations.
The 'equix' crate is pure Rust and it's all new code, but we have it released under the LGPL out of respect for the license of the algorithm's original implementation. These crates are not included in the build unless we have the non-default "hs-pow" feature.
I'm suggesting we try enabling hs-pow by default in the "arti" command line tool. I don't see any downsides, and this will give us behavior similar to the Tor Browser or to Debian's packaging of c-tor.