1

I'm writing some code to play around with and test some hidden service things. I need to be able to emulate hidden service directory selection.
HSDirs are calculated by selecting the three closest onion-routers whose identity hash is larger than the hidden service descriptor's descriptor-id, and who also have the HSDir flag.

Which network status document is used to find the HSDirs of a hidden service? Is it correct to use the "cached-microdesc-consensus"?

Additionally how could you get such a document if it wasn't already cached on your computer from Tor? I found this script, however it requires a file, ``cached-consensus'', that I don't have.

edit
The Stem interpreter (which can be accessed using the command tor-prompt) can be used to download consensus documents. For instance with the command: GETINFO ns/all.
Additionally, if HSDirs are selected correctly you should be able to check by making the following HTTP GET request:

http://<HSDir_IP>:<HSDir_DirPort>/<DescriptorID>

I have not yet been able to replicate HSDir selection using this data, however. Either the documents aren't the correct ones or there's some nuance to HSDir selection that isn't obvious.

1

I have gotten the code working now. As far as I can tell the script doesn't work for selecting HSDirs but works for everything else (i.e., calculating descriptor-ids).

HSDir selection was successfully performed as follows: The file "cached-microdesc-consensus" was used. This file is downloaded automatically when Tor is started.

The three onion routers in the consensus which have the HSDir flag and whose identity digest was closest to (and larger than) the descriptor ID were chosen.
Comparisons between descriptor-ids and identity digests were done as string comparisons with both values encoded in base64 (descriptor-ids are encoded by default in base32 and the identity digests in the consensus were encoded as base64).

The results of this were almost the same Tor's own selections; usually one or two were selected incorrectly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.