Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3: Allow migration from Tor to Onionbalance #10

Closed
asn-d6 opened this issue Apr 6, 2020 · 4 comments
Closed

v3: Allow migration from Tor to Onionbalance #10

asn-d6 opened this issue Apr 6, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@asn-d6
Copy link
Member

asn-d6 commented Apr 6, 2020

Allow operators to migrate their onion service from tor to onionbalance.

This means that we need to parse the v3 private key and make it into an onionbalance private key. Let's hope that the ed25519 private key formats don't prove too complicated here.

@asn-d6 asn-d6 added the enhancement New feature or request label Apr 6, 2020
@asn-d6
Copy link
Member Author

asn-d6 commented Apr 7, 2020

OK this is not an easy feature but it should be possible. Here are some notes.

The reason is that Tor stores the identity private key of onion services in a special format (let's call it the Tor format here, but it's also what bittorrent uses) so that it can support key blinding. In particular, it stores private keys in a (a, RH) format.

OTOH, the Python3 cryptography module that Onionbalance and stem uses, do ed25519 private keys with the standard (seed, A) format.

Unfortunately, it's not possible to go from the Tor format to the standard format, which means that we can't read the identity private key of a real Tor instance, and translate it to a format that stem will understand, and then pass it to stem, and do things normally.

This means that the only solution here is to parse the private identity key of Tor, and then create a wrapper class for that private key in Onionbalance that will emulate the behavior of a standard ed25519 format in terms of duck-typing. Then pass that emulated standard private key to stem and let it use it.

I already did something similar for stem in the past, so I think I can re-use that code here. However, I would need to pay close attention because this is a complicated procedure.

@asn-d6
Copy link
Member Author

asn-d6 commented Apr 7, 2020

I'm encountering issues with the approach outlined in the comment above.

It might not be possible to do duck-typing wrapper classes for hazmat keys because stem actually checks that the received identity private key is a hazmat key with stem.util._pubkey_bytes() in https://github.com/torproject/stem/blob/master/stem/descriptor/hidden_service.py#L1338 and https://github.com/torproject/stem/blob/cc492696ca89f9f0ebe481f2f7a38a40eff1d893/stem/descriptor/hidden_service.py#L1153.

I then thought of tricking _pubkey_bytes() by passing it directly as bytes but it seems like later in the code it is being used directly as a hazmat key: https://github.com/torproject/stem/blob/master/stem/descriptor/hidden_service.py#L1350

So I think this approach is busted. Seems like I need to think of something smarter, or write a patch for stem and then implement this in Onionbalance....

@asn-d6
Copy link
Member Author

asn-d6 commented Apr 7, 2020

Please see #17 for an approach here!!!!

@asn-d6
Copy link
Member Author

asn-d6 commented Apr 14, 2020

Done with #17! Issue #24 will improve the UX here, but we can close this for now!

@asn-d6 asn-d6 closed this as completed Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant