Make entropy source configurable, default to mnemonic#197
Conversation
|
👋 Thanks for assigning @benthecarman as a reviewer! |
|
concept ack |
c95f8ab to
e849521
Compare
|
Should be good for review. |
e849521 to
a26361f
Compare
Anyitechs
left a comment
There was a problem hiding this comment.
Thanks!
Just curious, is there a reason the entropy source are only configurable via the toml file and not added to the env var as well?
| let mut f = fs::OpenOptions::new().create_new(true).write(true).mode(0o600).open(path)?; | ||
| writeln!(f, "{}", mnemonic)?; | ||
| f.sync_all()?; | ||
| fs::set_permissions(path, fs::Permissions::from_mode(0o600))?; |
There was a problem hiding this comment.
shouldn't the f.sync_all() be after we set permissions?
a26361f to
bcb430a
Compare
|
Hi @tnull. I think that this change doesn't do the
Part you described. I've did the following to test:
It seems that:
Also, if I may, I'm not sure that the best path is ignoring any key, as it may confuse the user on what key he is actually using. Maybe the best path forward is fail to boot not only if both config options are present, but if the two files are present or something like that |
Well, it used to, but Ben explicitly requested the backwards compatibility logic to be dropped in #197 (comment) as there are currently only ~5 nodes actually deployed for testing purposes and if this is the new default behavior prior to the actual release, we should be able to at some point even drop the legacy keys_seed behavior entirely. |
Previously ldk-server unconditionally loaded its node entropy from a raw
64-byte file at `<storage_dir>/keys_seed`, which is opaque and cannot be
imported into other wallets. Switch the default to a BIP39 mnemonic
written to `<storage_dir>/keys_mnemonic`, so operators can back up their
node identity as a 24-word phrase and recover on-chain funds with any
standard BIP39-compatible wallet.
Add a `[node.entropy]` config section with two mutually exclusive
fields:
- `mnemonic_file`: path to the BIP39 mnemonic file (defaults to
`<storage_dir>/keys_mnemonic`).
- `seed_file`: legacy raw-seed file path, for installs initialized
before this change.
For backwards compatibility, if neither field is set and a `keys_seed`
file already exists at the storage root, ldk-server continues to use
it. No implicit migration: a raw 64-byte seed cannot be reversed back
into its source mnemonic.
Co-Authored-By: HAL 9000
Review feedback preferred a single explicit entropy source over two mutually exclusive Options. Convert the config to an enum and add CLI and environment overrides so non-TOML deployments can select the entropy path. Require legacy raw seed users to opt in via seed_file so default startup consistently uses the mnemonic path. Set permissions before the final sync so file contents and permission metadata are flushed together. Co-Authored-By: HAL 9000
Node entropy mnemonic creation should share the existing private-file write path instead of keeping a separate implementation, while the legacy seed filename should stay scoped to the tests that need it. Co-Authored-By: HAL 9000
Update the example config and operator-facing docs to reflect the new default of a BIP39 mnemonic at `<storage_dir>/keys_mnemonic`, the mutually exclusive `[node.entropy]` options, and the legacy `keys_seed` backwards-compatibility path. Update the backup table to list both files so legacy operators don't lose track of their existing seed. Co-Authored-By: HAL 9000
Review feedback removed the automatic legacy keys_seed fallback. Update the config docs and sample template so operators know an existing raw seed must be selected explicitly. Document the new CLI and environment names next to the TOML fields so non-file configuration is discoverable. Co-Authored-By: HAL 9000
bcb430a to
367e8d2
Compare
367e8d2 to
ade2e30
Compare
We switch to, by default, creating and reading a BIP39 mnemonic file rather than raw bytes. We however detect the old behavior and will keep using
keys_seedif it is present.