Skip to content

Conversation

@distractedm1nd
Copy link
Contributor

@distractedm1nd distractedm1nd commented Nov 5, 2025

Resolves #302
Wanted to open as a suggestion for dealing with #302, and starting a discussion:

Would it not be better to integrate this behavior directly into the initialization command (with a flag), rather than adding a new command? 2 steps rather than 3 is already a big improvement from a product perspective, let alone removing the requirement of having the extra binary.

But this draft PR is just a placeholder to discuss it, just don't want to waste time in a direction that isn't useful. Obviously there would still be a lot to change+improve here.

Copy link
Collaborator

@str4d str4d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial feedback. Depending on how the UX ends up shaping out for configuring the different possible alternative wallet encryption mechanisms (including plugins #252), it may be better to have a dedicated CLI method for each, and remove init-wallet-encryption (instead doing what it does now inside each of the dedicated methods). But we can start by prototyping the combined UX inside init-wallet-encryption.

Comment on lines 29 to 35
let sk = age::x25519::Identity::generate();
let pk = sk.to_public();

// Q: should we also include timestamp?
writeln!(out, "# public key: {}", pk).map_err(|e| ErrorKind::Init.context(e))?;
writeln!(out, "{}", sk.to_string().expose_secret())
.map_err(|e| ErrorKind::Init.context(e))?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, what I should do is expose the file-generator code from inside rage-keygen somewhere under age::cli_common for reuse. Then it would also benefit from translations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried to tackle this for a bit but gave up - moving the generator (where the localized strings are found) into cli_common means moving those strings over to age/i18n, and adding chrono as a dependency. Is this what you meant?

Exposing instead only the file creation might be an option? But then we don't really gain much at all from doing so.

I've updated the code now without making a PR to rage - maybe it'll help thinking about what to expose upstream.

.map_err(|e| ErrorKind::Init.context(e))?;

info!("Encryption identity file created at {}", path.display());
info!("Public key: {}", pk);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The recipient is irrelevant to Zallet users.

Suggested change
info!("Public key: {}", pk);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pub(crate) struct InitWalletEncryptionCmd {
/// Creates the encryption identity file if it does not already exist.
#[arg(short)]
pub(crate) create: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this being a bool, we should take an enum with variants corresponding to both unencrypted (what is currently implemented) and passphrase-encrypted, so we cover both of the currently-documented use cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@distractedm1nd distractedm1nd marked this pull request as ready for review November 10, 2025 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a zallet CLI command to generate encryption-identity.txt

2 participants