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

Split Secret Manager traits #1756

Closed
wants to merge 37 commits into from
Closed

Conversation

DaughterOfMars
Copy link

Description of change

This PR splits the SecretManage trait and refactors the trait to unify the essential functions for a wallet.

Links to any relevant issues

Closes #1490

@DaughterOfMars DaughterOfMars linked an issue Jan 11, 2024 that may be closed by this pull request
Copy link
Member

@thibault-martinez thibault-martinez left a comment

Choose a reason for hiding this comment

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

Please fix conflicts

Ok(m.generate(&options).await?)
}
#[cfg(feature = "private_key_secret_manager")]
SecretManager::PrivateKey(_) => todo!(),
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO

Copy link
Author

Choose a reason for hiding this comment

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

So all of these are here because I'm not sure what we want to do if you try to generate multiple keys using a private key secret manager (which can only ever give you one key). Should we give that key, even if it doesn't match the provided config? Or return an error?

Ok(m.generate(&options).await?)
}
#[cfg(feature = "private_key_secret_manager")]
SecretManager::PrivateKey(_) => todo!(),
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO

Ok(m.generate(&options).await?)
}
#[cfg(feature = "private_key_secret_manager")]
SecretManager::PrivateKey(_) => todo!(),
Copy link
Contributor

Choose a reason for hiding this comment

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

TODO

type Error: std::error::Error + Send + Sync;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct PublicKeyOptions {
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason again to have this instead of Bip44 directly?

Copy link
Contributor

Choose a reason for hiding this comment

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

Bip44 is not our type, but we could also make it a PublicKeyOptions(Bip44)?

Copy link
Author

Choose a reason for hiding this comment

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

I've thought about changing it, but of course then there's the mismatch between generating a single key and multiple

Copy link
Member

Choose a reason for hiding this comment

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

Okay, but should we maybe name it Bip44PublicKeyOptions to make its purpose clearer?

Copy link
Author

Choose a reason for hiding this comment

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

Hmm..I'll think about it.

Copy link
Member

Choose a reason for hiding this comment

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

It's not very important, so you can resolve whether you do or not

match block_indexes.get(&required_address) {
// If we already have an [Unlock] for this address, add a [Unlock] based on the address type
Some(block_index) => match required_address {
Address::Ed25519(_) | Address::ImplicitAccountCreation(_) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this actually still be Address::ImplicitAccountCreation? It was converted in L227, right?

}
}
impl<T> SecretManageExt for T {}
Copy link
Contributor

Choose a reason for hiding this comment

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

T: SecretManage bound?

Copy link
Author

Choose a reason for hiding this comment

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

why?

Comment on lines +381 to +382
bip32_change: chain.change.harden().into(),
bip32_index: chain.address_index.harden().into(),
Copy link
Member

Choose a reason for hiding this comment

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

Before this was part of the remainder, but now it's just provided to this function which I think can be wrong if the remainder address isn't an Ed25519 address
So if remainder address != Ed25519, return None for the remainder_bip32 and below only go in this part if let Some(remainder_output) = remainder_output { if it's Some

Copy link
Author

Choose a reason for hiding this comment

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

Since you understand this better, would you push the change?

Copy link
Member

Choose a reason for hiding this comment

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

I think it depends on #1756 (comment), if we bring this back, then we can also do this part different

Copy link
Author

Choose a reason for hiding this comment

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

that's fair

Comment on lines -144 to -146
/// The chain derived from seed, only for ed25519 addresses
#[serde(with = "option_bip44", default)]
pub chain: Option<Bip44>,
Copy link
Member

Choose a reason for hiding this comment

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

So do we bring this back for signing with multiple different addresses in inputs?

Copy link
Author

Choose a reason for hiding this comment

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

might have to :c

Comment on lines +432 to +435
PublicKeyOptions::new(bip.coin_type)
.with_account_index(bip.account)
.with_internal(bip.change != 0)
.with_address_index(bip.address_index),
Copy link
Member

Choose a reason for hiding this comment

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

Can now just be PublicKeyOptions::from(bip), also in more places

Copy link
Author

Choose a reason for hiding this comment

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

ah, good point, thanks

@thibault-martinez
Copy link
Member

Working on a better solution.

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.

Reconsider what should be part of SecretManager or not
4 participants