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

Refactor load consensus keys logic in node-data #3525

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

d-sonuga
Copy link
Collaborator

For #3514

@d-sonuga d-sonuga changed the title Refact load consensus keys logic in node-data Refactor load consensus keys logic in node-data Feb 24, 2025
Copy link
Member

@herr-seppia herr-seppia left a comment

Choose a reason for hiding this comment

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

Instead of adding rusk-wallet to node-data it would be better to do the opposite (rusk-wallet is quite a big dependency to add to a light data crate)

So, instead of having node-data that does rusk_wallet::load_consensus_keys(&path_buf, &pwd)?; we should have rusk-wallet that does node_data::save_consensus_keys(....)

@d-sonuga
Copy link
Collaborator Author

@herr-seppia, the point of moving the saving of consensus keys into the rusk-wallet is to put all the hashing and encryption of wallet-related data in the same place so that when changes like the ones required for this issue #3391 are made, changes will only have to be made in one place.

@herr-seppia
Copy link
Member

The only thing I'm strongly opinionated is that we cannot add rusk-wallet as dependency to rusk (and to node-data)

Furthermore. keep in mind that consensus keys storage should not be considered "wallet-related data" imo, but they're indeed "node-related data"
That's why I believe those methods should be exposed by node-data, and the wallet should use it in order to export in a "node" compatible format

@d-sonuga d-sonuga force-pushed the load-consensus-keys branch from d816a11 to f1f762e Compare March 3, 2025 13:23
@d-sonuga d-sonuga requested a review from herr-seppia March 3, 2025 13:55
Copy link
Member

@herr-seppia herr-seppia left a comment

Choose a reason for hiding this comment

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

LGTM overall

Comment on lines -187 to -188
warn!("Your consensus keys are in the old format");
warn!("Consider to export them using a new version of the wallet");
Copy link
Member

Choose a reason for hiding this comment

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

Did you remove the legacy support?
If so, please add it to the changelog


// export key-pair to disk
fs::write(path.with_extension("keys"), bytes)?;
node_data::bls::save_consensus_keys(&path, &filename, &pk, &sk, pwd)?;

Ok((path.with_extension("keys"), path.with_extension("cpk")))
Copy link
Member

Choose a reason for hiding this comment

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

Assuming that the extensions are .keys and .cpk is error prone (chaning node_data will break this)
You could change node_data::bls::save_consensus_keys to return the paths and display them here

use serde::{Serialize, Serializer};

pub fn serialize<S: Serializer>(v: &[u8], s: S) -> Result<S::Ok, S::Error> {
let base64 = BASE64.encode(v);
Copy link
Member

Choose a reason for hiding this comment

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

Is the base64 dependency still used?

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.

2 participants