-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[tor] Add ability to encrypt the Tor private key on disk #6500
[tor] Add ability to encrypt the Tor private key on disk #6500
Conversation
@guggero Oops, sorry, looks like I broke something when trying to fix the onion file stuff, as discussed here: #4458 (comment) But I'm having trouble fixing the issue... First question, if you get a chance: Does moving the onion file stuff to a new package within Tor make sense? Re: this convo #4458 (comment)? If it does make sense to move it... I'm getting the following error that I am struggling to fix
and if I try to do that...
|
Since you last rebased we made the You need to do the following now (that goes for any change to a package that is a submodule, meaning it has its own
Of course for development it makes sense to create PR 1 and PR2 at the same time and just stack the commits of both in the second PR and use a |
@guggero Ah got it, thank you for the explanation! |
Hey @guggero one more question for you! Now I've split the Tor code out into a separate PR. But the Tor changes depend on changes in the keychain and lnencrypt packages. So now I'm getting this response when I try to run "go test" in the Tor module
And when I do go get
Wondering if I need to split out the keychain & lnencrypt changes into a third PR? Or if something else is going on |
Hmm, this is a tough one. I guess what I forgot to mention is that the So this requires some additional refactoring... My suggestion:
|
Got it, thank you @guggero . Will let you know when I have the latest PRs up. |
Sounds good! Will review once you give me the heads up. |
@guggero One more question... so because we're getting rid of all the lnd dependencies in the Tor module, we don't need to split the onionfile code into a new subpackage of Tor, correct? Just want to make sure I before I move that back |
I think the |
76289a9
to
2de8691
Compare
5d25e25
to
b689dfc
Compare
b689dfc
to
08e2683
Compare
Rebased this just fyi. It's ready for a look! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the latest updates!
I think we're getting closer here. The diff can be quite a bit smaller though if we follow @Crypt-iQ's suggestion.
14eb5c9
to
8b0f904
Compare
Can be rebased now and use the |
f7e883b
to
5807076
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the rebase and update. Tested the latest version, all seems to work as advertised 🎉
There are still quite a few nits in there. I'd appreciate a scan of all commits before requesting review (in future PRs) to avoid too many rounds of review.
5807076
to
f98b514
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, LGTM 🎉
f98b514
to
703ffc3
Compare
Thanks @guggero! I made those changes. And sure, I'll definitely keep a closer eye out for those nits & code style guidelines in the future! |
@Crypt-iQ: review reminder |
Needs a rebase. |
…its own package called lnencrypt The functions inside of the crypto.go file in chanbackup (like EncryptPayloadToWriter and DecryptPayloadFromReader) can be used by a lot of things outside of just the chanbackup package. We can't just reference them directly from the chanbackup package because it's likely that it would generate circular dependencies. Therefore we need to move these functions into their own package to be referenced by chanbackup and whatever new functionality that needs them
…vate key on disk It's possible that a user might not want the Tor private key to sit on the disk in plaintext (it is a private key after all). So this commit adds a new flag to encrypt the Tor private key on disk using the wallet's seed. When the --tor.encryptkey flag is used, LND will still write the Tor key to the same file, however it will now be encrypted intead of plaintext. This essentially uses the same method to encrypt the Tor private key as is used to encrypt the Static Channel Backup file.
703ffc3
to
14cc7e5
Compare
@guggero rebased |
This PR replaces #4458. Since I've been making some of the changes for @gkrizek and it's been a bit tricky to manage making PRs into his PRs... we thought it would be nice to have a fresh start. :)
Depends on #6526
Graham's original PR description:
It's possible that a user might not want the Tor private key to sit on the disk in plaintext (it is a private key after all). So this commit adds a new flag to encrypt the Tor private key on disk using the wallet's seed. When the --tor.encryptkey flag is used, LND will still write the Tor key to the same file, however it will now be encrypted instead of plaintext. This essentially uses the same method to encrypt the Tor private key as is used to encrypt the Static Channel Backup file.
Summary of Changes:
Moves the crypto.go file from chanbackup into its own package called lnencrypt. This was needed because we can't directly reference the encryptPayloadToWriter and decryptPayloadFromReader functions from the chanbackup package due to circular dependency issues. Also, I think it's very likely that future enhancements will also want to use these same functions. Thus I've moved them to their own package.
Creates a flag called --tor.encryptkey which encrypts the Tor private key.
When this is set it encrypts the private key and writes the encrypted blob to the same file on disk. This allows users to still keep the same functionality and flows as before (like refreshing a hidden service), but adds protection when running in untrusted environments.