-
Notifications
You must be signed in to change notification settings - Fork 63
feat: Initial version of a key generation utility for ream #757
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
Conversation
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.
Most of the comments are about cosmetics for codebase consistency (like inlining variable in the logs...), and left some questions that comes into my mind while reading your code. Great job!
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.
Here is some feedback
@ch4r10t33r |
It may seem like overkill at the moment, but this is the direction we’re heading. We should keep the code we’ve already built instead of removing it now and having to add it back later. |
@ch4r10t33r Not all comments are resolved, please take a look. |
My apologies, the comments didnt show up at my end. I have now addressed them all. |
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.
Spotted some suspicious things with several issues (dependency, code formatting...)
Also there are some comments that are not resolved but marked as resolved. Please check those again.
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.
Left some feedback
Co-authored-by: Kolby Moroz Liebl <[email protected]>
Co-authored-by: Kolby Moroz Liebl <[email protected]>
Co-authored-by: Kolby Moroz Liebl <[email protected]>
Co-authored-by: Kolby Moroz Liebl <[email protected]>
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.
Also could you please change the PR title? account_manager changes
are quite vague
Updated. |
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.
LGTM
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.
Here is some feedback
wallet_index: u32, | ||
activation_epoch: u32, | ||
num_active_epochs: u32, | ||
passphrase: &str, |
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.
I think this function should be implemented on the PrivateKey struct, the PublicKey is a derivative of the PrivateKey
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.
I am not sure what you mean. Are you referring to the passphrase
? That is used as a seed to generate the keypair.
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.
pub fn generate_keys(
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.
There is already a generate function in the private key module:
pub fn generate<R: Rng>( |
The generate_keys function in the account manager is simply a wrapper around it, adding functionality such as determining the salt.
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.
it is fine to add another, generate_keys
is just floating around right now, well it is a constructor for an object
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.
I am not sure why this was marked as resolved, pub fn generate_key_pair_with_salt(
should be a member of the PrivateKey struct
`
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.
I'm not clear on your point. I thought you wanted me to rename both functions.
The generate_key_pair_with_salt
function belongs to the account_manager
crate, as it’s a core feature of account_manager
, not the private key. We’ll expand this functionality with alternative approaches. The private key remains unaffected by these changes and shouldn’t need updates whenever we adjust the strategy in account_manager
.
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.
Dropping my thoughts here:
How about adding a function
pub fn derive_wallet_rng(
seed_phrase: &str,
wallet_index: u32,
passphrase: &str,
) -> ChaCha20Rng
And use it like:
PrivateKey::generate(&mut derive_wallet_rng(...), ...)
?
So that we can remove generate_key*
function name which derives some convo here.
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.
Sure, I can rename the function. But my main point of contention is that the functionality should remain in account_manager rather than PrivateKey.
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.
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.
PR looks great, good work 🥳
What was wrong?
To-Do